summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-01-29 13:29:43 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-08-29 20:10:47 +0900
commitbf85e8c94daf3073128168d131edb930ce05eace (patch)
tree56e9262e3d53e60e2013e7de6aa4eb78ee057e70
parentdc8059d9ca1d7fc0ea241df73c16bb2a2bf2cce5 (diff)
remove margin param. and replace it with a relative "rectangle"
Relative rectangle - x1, y1, x2, y2 with valid values in the range between 0.0 and 1.0, where 0, 0 is top left corner and 1, 1 is the bottom right corner of the control rectangle. Change-Id: I2b782a43e91328cf43dc0722e50c55414fb3e867 Reviewed-on: https://gerrit.libreoffice.org/68691 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 2f8eb233b8de5a7a3a7b997734290b20bf86bd14)
-rw-r--r--vcl/inc/widgetdraw/WidgetDefinition.hxx29
-rw-r--r--vcl/source/gdi/FileDefinitionWidgetDraw.cxx12
-rw-r--r--vcl/source/gdi/WidgetDefinition.cxx18
-rw-r--r--vcl/source/gdi/WidgetDefinitionReader.cxx35
-rw-r--r--vcl/uiconfig/theme_definitions/definition.xml11
5 files changed, 70 insertions, 35 deletions
diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx b/vcl/inc/widgetdraw/WidgetDefinition.hxx
index 486d61802654..f1035c694cfe 100644
--- a/vcl/inc/widgetdraw/WidgetDefinition.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -37,7 +37,6 @@ public:
DrawCommand(DrawCommandType aType)
: maType(aType)
, mnStrokeWidth(-1)
- , mnMargin(0)
{
}
@@ -46,7 +45,6 @@ public:
Color maStrokeColor;
Color maFillColor;
sal_Int32 mnStrokeWidth;
- sal_Int32 mnMargin;
};
class VCL_DLLPUBLIC RectangleDrawCommand : public DrawCommand
@@ -55,10 +53,19 @@ public:
sal_Int32 mnRx;
sal_Int32 mnRy;
+ float mfX1;
+ float mfY1;
+ float mfX2;
+ float mfY2;
+
RectangleDrawCommand()
: DrawCommand(DrawCommandType::RECTANGLE)
, mnRx(0)
, mnRy(0)
+ , mfX1(0.0f)
+ , mfY1(0.0f)
+ , mfX2(1.0f)
+ , mfY2(1.0f)
{
}
};
@@ -66,8 +73,17 @@ public:
class VCL_DLLPUBLIC CircleDrawCommand : public DrawCommand
{
public:
+ float mfX1;
+ float mfY1;
+ float mfX2;
+ float mfY2;
+
CircleDrawCommand()
: DrawCommand(DrawCommandType::CIRCLE)
+ , mfX1(0.0f)
+ , mfY1(0.0f)
+ , mfX2(1.0f)
+ , mfY2(1.0f)
{
}
};
@@ -139,10 +155,11 @@ public:
std::vector<std::shared_ptr<DrawCommand>> mpDrawCommands;
- void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
- sal_Int32 nRx, sal_Int32 nRy, sal_Int32 nMargin);
- void addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
- sal_Int32 nMargin);
+ void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor, float fX1,
+ float fY1, float fX2, float fY2, sal_Int32 nRx, sal_Int32 nRy);
+ void addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor, float fX1,
+ float fY1, float fX2, float fY2);
+
void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2,
float fY2);
};
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 9b4aa8a8c8c9..209ed169773e 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -124,10 +124,8 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
{
auto const& rCircleDrawCommand
= static_cast<CircleDrawCommand const&>(*pDrawCommand);
- Point aRectPoint(nX + 1 + rCircleDrawCommand.mnMargin,
- nY + 1 + rCircleDrawCommand.mnMargin);
- Size aRectSize(nWidth - 1 - 2 * rCircleDrawCommand.mnMargin,
- nHeight - 1 - 2 * rCircleDrawCommand.mnMargin);
+ Point aRectPoint(nX + 1, nY + 1);
+ Size aRectSize(nWidth - 1, nHeight - 1);
tools::Rectangle aRectangle(aRectPoint, aRectSize);
tools::Polygon aPolygon(aRectangle.Center(), aRectangle.GetWidth() >> 1,
@@ -143,11 +141,9 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
case DrawCommandType::LINE:
{
auto const& rLineDrawCommand = static_cast<LineDrawCommand const&>(*pDrawCommand);
- Point aRectPoint(nX + 1 + rLineDrawCommand.mnMargin,
- nY + 1 + rLineDrawCommand.mnMargin);
+ Point aRectPoint(nX + 1, nY + 1);
- Size aRectSize(nWidth - 1 - 2 * rLineDrawCommand.mnMargin,
- nHeight - 1 - 2 * rLineDrawCommand.mnMargin);
+ Size aRectSize(nWidth - 1, nHeight - 1);
rGraphics.SetFillColor();
rGraphics.SetLineColor(rLineDrawCommand.maStrokeColor);
diff --git a/vcl/source/gdi/WidgetDefinition.cxx b/vcl/source/gdi/WidgetDefinition.cxx
index 36d362479c27..8b717a035c91 100644
--- a/vcl/source/gdi/WidgetDefinition.cxx
+++ b/vcl/source/gdi/WidgetDefinition.cxx
@@ -89,28 +89,36 @@ WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString co
}
void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth,
- Color aFillColor, sal_Int32 nRx, sal_Int32 nRy,
- sal_Int32 nMargin)
+ Color aFillColor, float fX1, float fY1, float fX2,
+ float fY2, sal_Int32 nRx, sal_Int32 nRy)
{
std::shared_ptr<DrawCommand> pCommand(std::make_shared<RectangleDrawCommand>());
pCommand->maStrokeColor = aStrokeColor;
pCommand->maFillColor = aFillColor;
pCommand->mnStrokeWidth = nStrokeWidth;
- pCommand->mnMargin = nMargin;
RectangleDrawCommand& rRectCommand = static_cast<RectangleDrawCommand&>(*pCommand);
rRectCommand.mnRx = nRx;
rRectCommand.mnRy = nRy;
+ rRectCommand.mfX1 = fX1;
+ rRectCommand.mfY1 = fY1;
+ rRectCommand.mfX2 = fX2;
+ rRectCommand.mfY2 = fY2;
mpDrawCommands.push_back(std::move(pCommand));
}
void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth,
- Color aFillColor, sal_Int32 nMargin)
+ Color aFillColor, float fX1, float fY1, float fX2,
+ float fY2)
{
std::shared_ptr<DrawCommand> pCommand(std::make_shared<CircleDrawCommand>());
pCommand->maStrokeColor = aStrokeColor;
pCommand->maFillColor = aFillColor;
pCommand->mnStrokeWidth = nStrokeWidth;
- pCommand->mnMargin = nMargin;
+ CircleDrawCommand& rCircleCommand = static_cast<CircleDrawCommand&>(*pCommand);
+ rCircleCommand.mfX1 = fX1;
+ rCircleCommand.mfY1 = fY1;
+ rCircleCommand.mfX2 = fX2;
+ rCircleCommand.mfY2 = fY2;
mpDrawCommands.push_back(std::move(pCommand));
}
diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx
index bc9ce749dfad..7f45a99b1aff 100644
--- a/vcl/source/gdi/WidgetDefinitionReader.cxx
+++ b/vcl/source/gdi/WidgetDefinitionReader.cxx
@@ -185,12 +185,20 @@ void WidgetDefinitionReader::readDrawingDefinition(tools::XmlWalker& rWalker,
if (!sRy.isEmpty())
nRy = sRy.toInt32();
- sal_Int32 nMargin = 0;
- OString sMargin = rWalker.attribute("margin");
- if (!sMargin.isEmpty())
- nMargin = sMargin.toInt32();
+ OString sX1 = rWalker.attribute("x1");
+ float fX1 = sX1.isEmpty() ? 0.0 : sX1.toFloat();
+
+ OString sY1 = rWalker.attribute("y1");
+ float fY1 = sY1.isEmpty() ? 0.0 : sY1.toFloat();
+
+ OString sX2 = rWalker.attribute("x2");
+ float fX2 = sX2.isEmpty() ? 1.0 : sX2.toFloat();
+
+ OString sY2 = rWalker.attribute("y2");
+ float fY2 = sY2.isEmpty() ? 1.0 : sY2.toFloat();
- rpState->addDrawRectangle(aStrokeColor, nStrokeWidth, aFillColor, nRx, nRy, nMargin);
+ rpState->addDrawRectangle(aStrokeColor, nStrokeWidth, aFillColor, fX1, fY1, fX2, fY2,
+ nRx, nRy);
}
else if (rWalker.name() == "circ")
{
@@ -203,12 +211,19 @@ void WidgetDefinitionReader::readDrawingDefinition(tools::XmlWalker& rWalker,
if (!sStrokeWidth.isEmpty())
nStrokeWidth = sStrokeWidth.toInt32();
- sal_Int32 nMargin = 0;
- OString sMargin = rWalker.attribute("margin");
- if (!sMargin.isEmpty())
- nMargin = sMargin.toInt32();
+ OString sX1 = rWalker.attribute("x1");
+ float fX1 = sX1.isEmpty() ? 0.0 : sX1.toFloat();
+
+ OString sY1 = rWalker.attribute("y1");
+ float fY1 = sY1.isEmpty() ? 0.0 : sY1.toFloat();
+
+ OString sX2 = rWalker.attribute("x2");
+ float fX2 = sX2.isEmpty() ? 1.0 : sX2.toFloat();
+
+ OString sY2 = rWalker.attribute("y2");
+ float fY2 = sY2.isEmpty() ? 1.0 : sY2.toFloat();
- rpState->addDrawCircle(aStrokeColor, nStrokeWidth, aFillColor, nMargin);
+ rpState->addDrawCircle(aStrokeColor, nStrokeWidth, aFillColor, fX1, fY1, fX2, fY2);
}
else if (rWalker.name() == "line")
{
diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml
index 91c473f290a6..0fdbdb659683 100644
--- a/vcl/uiconfig/theme_definitions/definition.xml
+++ b/vcl/uiconfig/theme_definitions/definition.xml
@@ -57,11 +57,10 @@
<pushbutton>
<part value="Entire">
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
- <rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" rx="5" ry="5" margin="0"/>
+ <rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" rx="7" ry="7" />
</state>
-
<state enabled="true" focused="any" pressed="any" rollover="true" default="any" selected="any" button-value="any">
- <rect stroke="#007AFF" fill="#007AFF" stroke-width="1" rx="5" ry="5" margin="0"/>
+ <rect stroke="#007AFF" fill="#007AFF" stroke-width="1" rx="7" ry="7" />
</state>
</part>
</pushbutton>
@@ -69,11 +68,11 @@
<radiobutton>
<part value="Entire">
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="false">
- <circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/>
+ <circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" />
</state>
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="true">
- <circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/>
- <circ stroke="#007AFF" fill="#007AFF" stroke-width="1" margin="3"/>
+ <circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" />
+ <circ stroke="#007AFF" fill="#007AFF" stroke-width="1" x1="0.1" y1="0.1" x2="0.9" y2="0.9"/>
</state>
</part>
</radiobutton>