summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-01-29 13:45:12 +0100
committerTomaž Vajngerl <quikee@gmail.com>2019-03-04 22:17:31 +0100
commit1042c2c5a349588c03a00f45c77fb1b8f1f1d4ea (patch)
tree10ede984159757296d4988627cc3d637b3d228c0 /vcl
parent2f8eb233b8de5a7a3a7b997734290b20bf86bd14 (diff)
use basegfx to convert circle/roundrect to a polygon
The tools::Polygon functions to draw a circle, roundrect are lower quality. Change-Id: I6226ac917d600b2a14a99c9a27aa371233799e16 Reviewed-on: https://gerrit.libreoffice.org/68692 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/FileDefinitionWidgetDraw.cxx37
1 files changed, 22 insertions, 15 deletions
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 209ed169773e..bc46bcbdd67f 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -15,6 +15,9 @@
#include <rtl/bootstrap.hxx>
#include <config_folders.h>
+#include <basegfx/range/b2drectangle.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
namespace vcl
{
namespace
@@ -101,12 +104,15 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
{
auto const& rRectDrawCommand
= static_cast<RectangleDrawCommand const&>(*pDrawCommand);
- Point aRectPoint(nX, nY);
- Size aRectSize(nWidth - 1, nHeight - 1);
- tools::Polygon aPolygon(tools::Rectangle(aRectPoint, aRectSize),
- rRectDrawCommand.mnRx, rRectDrawCommand.mnRy);
- basegfx::B2DPolygon aB2DPolygon(aPolygon.getB2DPolygon());
+ basegfx::B2DRectangle rRect(
+ nX + (nWidth * rRectDrawCommand.mfX1), nY + (nHeight * rRectDrawCommand.mfY1),
+ nX + (nWidth * rRectDrawCommand.mfX2), nY + (nHeight * rRectDrawCommand.mfY2));
+
+ basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect(
+ rRect, rRectDrawCommand.mnRx / rRect.getWidth() * 2.0,
+ rRectDrawCommand.mnRy / rRect.getHeight() * 2.0);
+
rGraphics.SetLineColor();
rGraphics.SetFillColor(rRectDrawCommand.maFillColor);
rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(),
@@ -124,14 +130,15 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
{
auto const& rCircleDrawCommand
= static_cast<CircleDrawCommand const&>(*pDrawCommand);
- 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,
- aRectangle.GetHeight() >> 1);
+ basegfx::B2DRectangle rRect(nX + (nWidth * rCircleDrawCommand.mfX1),
+ nY + (nHeight * rCircleDrawCommand.mfY1),
+ nX + (nWidth * rCircleDrawCommand.mfX2),
+ nY + (nHeight * rCircleDrawCommand.mfY2));
+
+ basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromEllipse(
+ rRect.getCenter(), rRect.getWidth() / 2.0, rRect.getHeight() / 2.0);
- basegfx::B2DPolygon aB2DPolygon(aPolygon.getB2DPolygon());
rGraphics.SetLineColor(rCircleDrawCommand.maStrokeColor);
rGraphics.SetFillColor(rCircleDrawCommand.maFillColor);
rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(),
@@ -177,10 +184,10 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
bool bOldAA = m_rGraphics.getAntiAliasB2DDraw();
m_rGraphics.setAntiAliasB2DDraw(true);
- long nWidth = rControlRegion.GetWidth();
- long nHeight = rControlRegion.GetHeight();
- long nX = rControlRegion.Left() + 1;
- long nY = rControlRegion.Top() + 1;
+ long nWidth = rControlRegion.GetWidth() - 1;
+ long nHeight = rControlRegion.GetHeight() - 1;
+ long nX = rControlRegion.Left();
+ long nY = rControlRegion.Top();
bool bOK = false;