From f5fe9fc5a4136a696f07c4bd3567d85348ec42d9 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 4 Aug 2017 16:22:23 +0200 Subject: Add ObjectMode coordinate mode to QGradient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø Reviewed-by: Allan Sandfeld Jensen --- tests/auto/other/lancelot/paintcommands.cpp | 5 +++-- .../auto/other/lancelot/scripts/gradientxform_object.qps | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'tests/auto/other/lancelot') diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 45429624f5..377b98fa41 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -106,7 +106,8 @@ const char *PaintCommands::spreadMethodTable[] = { const char *PaintCommands::coordinateMethodTable[] = { "LogicalMode", "StretchToDeviceMode", - "ObjectBoundingMode" + "ObjectBoundingMode", + "ObjectMode" }; const char *PaintCommands::sizeModeTable[] = { @@ -2394,7 +2395,7 @@ void PaintCommands::command_gradient_setSpread(QRegularExpressionMatch re) void PaintCommands::command_gradient_setCoordinateMode(QRegularExpressionMatch re) { - int coord = translateEnum(coordinateMethodTable, re.captured(1), 3); + int coord = translateEnum(coordinateMethodTable, re.captured(1), 4); if (m_verboseMode) printf(" -(lance) gradient_setCoordinateMode %d=[%s]\n", coord, diff --git a/tests/auto/other/lancelot/scripts/gradientxform_object.qps b/tests/auto/other/lancelot/scripts/gradientxform_object.qps index d785a008c0..dcc718072f 100644 --- a/tests/auto/other/lancelot/scripts/gradientxform_object.qps +++ b/tests/auto/other/lancelot/scripts/gradientxform_object.qps @@ -62,7 +62,22 @@ repeat_block row restore end_block block +save translate 400 0 brushRotate 30.0 brushScale 1.5 .5 repeat_block block +restore + +drawText 80 400 "BRUSH XFORM, OBJECT BOUNDING MODE" +drawText 500 400 "BRUSH XFORM, OBJECT MODE" + +translate 0 400 +brushTranslate 0.5 0.5 +brushRotate 180.0 +brushTranslate -0.5 -0.5 +repeat_block block + +translate 400 0 +gradient_setCoordinateMode ObjectMode +repeat_block block -- cgit v1.2.3