summaryrefslogtreecommitdiff
path: root/svx/source/sdr
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-03-25 15:42:41 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-03-27 10:45:15 +0900
commit913b3a648117206d21821b0cea40ff15a0e8e5cf (patch)
tree83c28ebde2e2d9dda7227c26e05d0a0d89f652d8 /svx/source/sdr
parent33094a542fbcdcdaf14d5d7304e79f2e5b8cd4de (diff)
Experimental: draw handles instead of getting them from bitmap
Currently object handles are defined in the bitmap which is a pain when using in HiDPI as they have to be scaled and don't look pretty. They are also hard to change and non theme-able (change of color needs a change the bitmap). This commit experimentaly enables the drawn handles (enable with environment variable SVX_DRAW_HANDLES) which currently exchanges the default some basic handles. Change-Id: If80aa7fe756a6d8d6991e9515f2951ee21b31b72
Diffstat (limited to 'svx/source/sdr')
-rw-r--r--svx/source/sdr/overlay/overlayhandle.cxx63
-rw-r--r--svx/source/sdr/overlay/overlaytools.cxx89
2 files changed, 152 insertions, 0 deletions
diff --git a/svx/source/sdr/overlay/overlayhandle.cxx b/svx/source/sdr/overlay/overlayhandle.cxx
new file mode 100644
index 000000000000..8cd47ff837d6
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayhandle.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sdr/overlay/overlayhandle.hxx>
+#include <sdr/overlay/overlaytools.hxx>
+#include <tools/poly.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+
+namespace sdr { namespace overlay {
+
+using namespace drawinglayer::primitive2d;
+using namespace basegfx;
+
+Primitive2DSequence OverlayHandle::createOverlayObjectPrimitive2DSequence()
+{
+ basegfx::BColor aStrokeColor = maStrokeColor.getBColor();
+ basegfx::BColor aFillColor = getBaseColor().getBColor();
+
+ const Primitive2DReference aReference(
+ new OverlayStaticRectanglePrimitive(maBasePosition, maSize, aStrokeColor, aFillColor, 0.3f, 0.0f));
+
+ return Primitive2DSequence(&aReference, 1);
+}
+
+OverlayHandle::OverlayHandle(const B2DPoint& rBasePos,
+ const B2DSize& rSize,
+ Color& rStrokeColor,
+ Color& rFillColor)
+ : OverlayObjectWithBasePosition(rBasePos, rFillColor)
+ , maSize(rSize)
+ , maStrokeColor(rStrokeColor)
+{
+}
+
+OverlayHandle::~OverlayHandle()
+{
+}
+
+}} // end of namespace sdr::overlay
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaytools.cxx b/svx/source/sdr/overlay/overlaytools.cxx
index ea0cab69899c..b333ce212179 100644
--- a/svx/source/sdr/overlay/overlaytools.cxx
+++ b/svx/source/sdr/overlay/overlaytools.cxx
@@ -33,6 +33,95 @@
#include <vcl/settings.hxx>
+namespace drawinglayer
+{
+namespace primitive2d
+{
+
+OverlayStaticRectanglePrimitive::OverlayStaticRectanglePrimitive(
+ const basegfx::B2DPoint& rPosition,
+ const basegfx::B2DSize& rSize,
+ const basegfx::BColor& rStrokeColor,
+ const basegfx::BColor& rFillColor,
+ double fTransparence,
+ double fRotation)
+ : DiscreteMetricDependentPrimitive2D()
+ , maPosition(rPosition)
+ , maSize(rSize)
+ , maStrokeColor(rStrokeColor)
+ , maFillColor(rFillColor)
+ , mfTransparence(fTransparence)
+ , mfRotation(fRotation)
+{}
+
+Primitive2DSequence OverlayStaticRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ Primitive2DSequence aPrimitive2DSequence;
+ const double fHalfWidth = maSize.getX() * getDiscreteUnit() / 2.0;
+ const double fHalfHeight = maSize.getY() * getDiscreteUnit() / 2.0;
+
+ basegfx::B2DRange aRange(
+ maPosition.getX() - fHalfWidth, maPosition.getY() - fHalfHeight,
+ maPosition.getX() + fHalfWidth, maPosition.getY() + fHalfHeight);
+
+ if (basegfx::fTools::more(getDiscreteUnit(), 0.0) && mfTransparence <= 1.0)
+ {
+ basegfx::B2DPolygon aPolygon(
+ basegfx::tools::createPolygonFromRect(aRange));
+
+ // create filled primitive
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ aPolyPolygon.append(aPolygon);
+
+ const attribute::LineAttribute aLineAttribute(maStrokeColor, 1.0);
+
+ // create data
+ const Primitive2DReference aStroke(
+ new PolyPolygonStrokePrimitive2D(aPolyPolygon, aLineAttribute));
+
+ // create fill primitive
+ const Primitive2DReference aFill(
+ new PolyPolygonColorPrimitive2D(aPolyPolygon, maFillColor));
+
+ aPrimitive2DSequence = Primitive2DSequence(2);
+ aPrimitive2DSequence[0] = aFill;
+ aPrimitive2DSequence[1] = aStroke;
+
+ // embed filled to transparency (if used)
+ if (mfTransparence > 0.0)
+ {
+ const Primitive2DReference aFillTransparent(
+ new UnifiedTransparencePrimitive2D(
+ aPrimitive2DSequence,
+ mfTransparence));
+
+ aPrimitive2DSequence = Primitive2DSequence(&aFillTransparent, 1);
+ }
+ }
+
+ return aPrimitive2DSequence;
+}
+
+bool OverlayStaticRectanglePrimitive::operator==(const BasePrimitive2D& rPrimitive) const
+{
+ if (DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const OverlayStaticRectanglePrimitive& rCompare = static_cast<const OverlayStaticRectanglePrimitive&>(rPrimitive);
+
+ return (maPosition == rCompare.maPosition
+ && maSize == rCompare.maSize
+ && maStrokeColor == rCompare.maStrokeColor
+ && maFillColor == rCompare.maFillColor
+ && mfTransparence == rCompare.mfTransparence
+ && mfRotation == rCompare.mfRotation);
+ }
+
+ return false;
+}
+
+ImplPrimitive2DIDBlock(OverlayStaticRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYRECTANGLEPRIMITIVE)
+
+}} // end of namespace drawinglayer::primitive2d
namespace drawinglayer
{