summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2020-06-30 16:49:52 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-07-07 14:13:41 +0200
commitc0971961cf11097c787c67b5892d6209f89662e7 (patch)
treeb79bda05f2376f669feecb8987ee71457275b7a7
parentc68fc819f78312c17ef6c4aee20a3759a2b10280 (diff)
tdf#130991 Fit the drop-down arrow into its rect
Looking at the original fixed-size arrow painting code replaced in commit b62c43d1200e524369d9c7c2bd1dad3044efd672 ("Anti-alias toolbar button drop-downs."), it used some fixed values of 5 and 3 to match the arrow box width of 11. The new code assumes the width is the expected arrow size, minus a minimal margin to separate the arrow from the button border, and there is enough height available. Based on these assumptions, the code now scales, positions and paints the triangle to fill the available space. Change-Id: Ied721e494d105106086ef6252e72ae7395eafe08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97537 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de> (cherry picked from commit 1cb897a0f65ba066d1e81b62c70c3e46bbdb7ba8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97583 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> (cherry picked from commit b0315eb69c62f2108983e6a4b2177cf28a2663bf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97687 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--vcl/source/window/toolbox.cxx31
1 files changed, 16 insertions, 15 deletions
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 3b0d6b5a5f7e..77df4fddcacb 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2387,27 +2387,28 @@ static void ImplDrawDropdownArrow(vcl::RenderContext& rRenderContext, const tool
rRenderContext.SetFillColor(COL_BLACK);
}
- float fScaleFactor = rRenderContext.GetDPIScaleFactor();
-
tools::Polygon aPoly(4);
- long width = round(rDropDownRect.getHeight()/5.5) * fScaleFactor; // scale triangle depending on theme/toolbar height with 7 for gtk, 5 for gen
- long height = round(rDropDownRect.getHeight()/9.5) * fScaleFactor; // 4 for gtk, 3 for gen
- if (width < 4) width = 4;
- if (height < 3) height = 3;
+ // the assumption is, that the width always specifies the size of the expected arrow.
+ const long nMargin = round(2 * rRenderContext.GetDPIScaleFactor());
+ const long nSize = rDropDownRect.getWidth() - 2 * nMargin;
+ const long nHalfSize = (nSize + 1) / 2;
+ const long x = rDropDownRect.Left() + nMargin + (bRotate ? (rDropDownRect.getWidth() - nHalfSize) / 2 : 0);
+ const long y = rDropDownRect.Top() + nMargin + (rDropDownRect.getHeight() - (bRotate ? nSize : nHalfSize)) / 2;
- long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
- long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
-
- long halfwidth = (width+1)>>1;
aPoly.SetPoint(Point(x, y), 0);
- aPoly.SetPoint(Point(x + halfwidth, y + height), 1);
- aPoly.SetPoint(Point(x + halfwidth*2, y), 2);
+ if (bRotate) // >
+ {
+ aPoly.SetPoint(Point(x, y + nSize), 1);
+ aPoly.SetPoint(Point(x + nHalfSize, y + nHalfSize), 2);
+ }
+ else // v
+ {
+ aPoly.SetPoint(Point(x + nHalfSize, y + nHalfSize), 1);
+ aPoly.SetPoint(Point(x + nSize, y), 2);
+ }
aPoly.SetPoint(Point(x, y), 3);
- if (bRotate) // TESTME: harder ...
- aPoly.Rotate(Point(x,y+height/2),2700);
-
auto aaflags = rRenderContext.GetAntialiasing();
rRenderContext.SetAntialiasing(AntialiasingFlags::EnableB2dDraw);
rRenderContext.DrawPolygon( aPoly );