Kaydet (Commit) 913b3a64 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

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
üst 33094a54
......@@ -227,6 +227,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/sdr/overlay/overlayobject \
svx/source/sdr/overlay/overlaymanager \
svx/source/sdr/overlay/overlayobjectlist \
svx/source/sdr/overlay/overlayhandle \
svx/source/sdr/primitive2d/sdrellipseprimitive2d \
svx/source/sdr/primitive2d/sdrprimitivetools \
svx/source/sdr/primitive2d/sdrtextprimitive2d \
......
/* -*- 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/.
*
*/
#ifndef INCLUDED_SVX_SDR_OVERLAY_OVERLAYHANDLE_HXX
#define INCLUDED_SVX_SDR_OVERLAY_OVERLAYHANDLE_HXX
#include <svx/sdr/overlay/overlayobject.hxx>
#include <basegfx/vector/b2dsize.hxx>
namespace sdr { namespace overlay {
class SVX_DLLPUBLIC OverlayHandle : public OverlayObjectWithBasePosition
{
protected:
basegfx::B2DSize maSize;
Color maStrokeColor;
// geometry creation for OverlayObject
virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence() SAL_OVERRIDE;
public:
OverlayHandle(const basegfx::B2DPoint& rBasePos,
const basegfx::B2DSize& rSize,
Color& rStrokeColor,
Color& rFillColor);
virtual ~OverlayHandle();
};
}} // end of namespace sdr::overlay
#endif // INCLUDED_SVX_SDR_OVERLAY_OVERLAYHANDLE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -22,7 +22,43 @@
#include <drawinglayer/primitive2d/primitivetools2d.hxx>
#include <vcl/bitmapex.hxx>
#include <basegfx/vector/b2dsize.hxx>
namespace drawinglayer { namespace primitive2d {
class OverlayStaticRectanglePrimitive : public DiscreteMetricDependentPrimitive2D
{
private:
basegfx::B2DPoint maPosition;
basegfx::B2DSize maSize;
// the graphic definition
basegfx::BColor maStrokeColor;
basegfx::BColor maFillColor;
double mfTransparence;
// the rotation of the primitive itself
double mfRotation;
protected:
virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
public:
OverlayStaticRectanglePrimitive(
const basegfx::B2DPoint& rPosition,
const basegfx::B2DSize& rSize,
const basegfx::BColor& rStrokeColor,
const basegfx::BColor& rFillColor,
double fTransparence,
double fRotation);
// compare operator
virtual bool operator==( const BasePrimitive2D& rPrimitive ) const SAL_OVERRIDE;
DeclPrimitive2DIDBlock()
};
}} // end of namespace drawinglayer::primitive2d
// Overlay helper class which holds a BotmapEx which is to be visualized
// at the given logic position with the Bitmap's pixel size, unscaled and
......
/* -*- 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: */
......@@ -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
{
......
......@@ -50,6 +50,7 @@
#include <svx/sdr/overlay/overlaybitmapex.hxx>
#include <sdr/overlay/overlayline.hxx>
#include <svx/sdr/overlay/overlaytriangle.hxx>
#include <sdr/overlay/overlayhandle.hxx>
#include <sdr/overlay/overlayrectangle.hxx>
#include <svx/sdrpagewindow.hxx>
#include <svx/sdrpaintwindow.hxx>
......@@ -577,13 +578,54 @@ void SdrHdl::CreateB2dIAObject()
if (xManager.is())
{
basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
aPosition,
eColIndex,
eKindOfMarker,
rOutDev,
aMoveOutsideOffset);
sdr::overlay::OverlayObject* pNewOverlayObject = NULL;
if (getenv ("SVX_DRAW_HANDLES") && (eKindOfMarker == Rect_7x7 || eKindOfMarker == Rect_9x9 || eKindOfMarker == Rect_11x11))
{
double fSize = 7.0;
switch (eKindOfMarker)
{
case Rect_9x9:
fSize = 9.0;
break;
case Rect_11x11:
fSize = 11.0;
break;
default:
break;
}
sal_Int32 nScaleFactor = rOutDev.GetDPIScaleFactor();
basegfx::B2DSize aB2DSize(fSize * nScaleFactor, fSize * nScaleFactor);
Color aHandleStrokeColor(COL_BLACK);
Color aHandleFillColor(COL_LIGHTGREEN);
switch (eColIndex)
{
case Cyan:
aHandleFillColor = Color(COL_CYAN);
break;
case LightCyan:
aHandleFillColor = Color(COL_LIGHTCYAN);
break;
case Red:
aHandleFillColor = Color(COL_RED);
break;
case LightRed:
aHandleFillColor = Color(COL_LIGHTRED);
break;
case Yellow:
aHandleFillColor = Color(COL_YELLOW);
break;
default:
break;
}
pNewOverlayObject = new sdr::overlay::OverlayHandle(aPosition, aB2DSize, aHandleStrokeColor, aHandleFillColor);
}
else
{
pNewOverlayObject = CreateOverlayObject(
aPosition, eColIndex, eKindOfMarker,
rOutDev, aMoveOutsideOffset);
}
// OVERLAYMANAGER
if (pNewOverlayObject)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment