diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2017-08-04 16:22:23 +0200 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2018-06-22 10:42:33 +0000 |
commit | f5fe9fc5a4136a696f07c4bd3567d85348ec42d9 (patch) | |
tree | cbfd3a39c9eeaa5ae11a8469bcd5431bedc06f77 /src/gui/painting/qbrush.cpp | |
parent | 99d4f0026f90681974f6fd1d23941e5b69024796 (diff) |
Add ObjectMode coordinate mode to QGradient
The ObjectBoundingMode coordinate mode of QGradient allows specifying
the gradient coordinates relative to the object being painted. But if
the gradient brush also has a transformation, that transformation is
applied in the logical, not object, coordinate space. That behavior is
counterintuitive. However, changing it now would break existing
code. Instead, we introduce a new coordinate mode enum with the
expected behavior, and document the old one as deprecated.
This prepares to fix the bugs below in qtsvg, by making
it possible to specify the same behavior in Qt as SVG has.
[ChangeLog][QtGui][QGradient] Add ObjectMode coordinate mode
[ChangeLog][Important Behavior Changes] QDataStream version bumped up to 18 to account for changes in the serialization of QGradient.
Task-number: QTBUG-59978
Task-number: QTBUG-67995
Change-Id: I8820a2555359812f3e1a46e37d6ac2cc29a2091d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qbrush.cpp')
-rw-r--r-- | src/gui/painting/qbrush.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index c667454cd2..f8185f5db8 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -1077,7 +1077,10 @@ QDataStream &operator<<(QDataStream &s, const QBrush &b) s << type_as_int; if (s.version() >= QDataStream::Qt_4_3) { s << int(gradient->spread()); - s << int(gradient->coordinateMode()); + QGradient::CoordinateMode co_mode = gradient->coordinateMode(); + if (s.version() < QDataStream::Qt_5_12 && co_mode == QGradient::ObjectMode) + co_mode = QGradient::ObjectBoundingMode; + s << int(co_mode); } if (s.version() >= QDataStream::Qt_4_5) @@ -1562,14 +1565,19 @@ QGradientStops QGradient::stops() const \value LogicalMode This is the default mode. The gradient coordinates are specified logical space just like the object coordinates. + \value ObjectMode In this mode the gradient coordinates are + relative to the bounding rectangle of the object being drawn, with + (0,0) in the top left corner, and (1,1) in the bottom right corner + of the object's bounding rectangle. This value was added in Qt + 5.12. \value StretchToDeviceMode In this mode the gradient coordinates are relative to the bounding rectangle of the paint device, with (0,0) in the top left corner, and (1,1) in the bottom right corner of the paint device. - \value ObjectBoundingMode In this mode the gradient coordinates are - relative to the bounding rectangle of the object being drawn, with - (0,0) in the top left corner, and (1,1) in the bottom right corner - of the object's bounding rectangle. + \value ObjectBoundingMode This mode is the same as ObjectMode, except that + the {QBrush::transform()} {brush transform}, if any, is applied relative to + the logical space instead of the object space. This enum value is + deprecated and should not be used in new code. */ /*! |