11#include <QPainterPath>
33#define HANDLE_DISTANCE 10
37 , m_rendererInterface(displayInterface)
39 , m_decorationThickness(1)
40 , m_showFillGradientHandles(false)
41 , m_showStrokeFillGradientHandles(false)
42 , m_forceShapeOutlines(false)
89 if (selectedShapes.isEmpty())
return;
93 const bool haveOnlyOneEditableShape =
95 selectedShapes.size() == 1;
97 bool editable =
false;
98 bool forceBoundingRubberLine =
false;
112 if (polys.size() == 1) {
113 const QPolygonF poly1 = polys[0];
114 const QPolygonF poly2 = QPolygonF(polys[0].boundingRect());
115 const QPolygonF nonoverlap = poly2.subtracted(poly1);
117 forceBoundingRubberLine |= !nonoverlap.isEmpty();
120 Q_FOREACH (
const QPolygonF &poly, polys) {
134 if (selectedShapes.size() > 1 || forceBoundingRubberLine) {
149 QPolygonF outline = handleArea;
156 helper.
drawHandleRect(0.5 * (outline.value(0) + outline.value(1)));
157 helper.
drawHandleRect(0.5 * (outline.value(1) + outline.value(2)));
158 helper.
drawHandleRect(0.5 * (outline.value(2) + outline.value(3)));
159 helper.
drawHandleRect(0.5 * (outline.value(3) + outline.value(0)));
167 if (haveOnlyOneEditableShape) {
168 KoShape *shape = selectedShapes.first();
195 if (gradientHandles.
type() == QGradient::LinearGradient) {
198 if (handles.size() == 2) {
232 for (
const auto& corner: cornerHandles) {
233 const QPointF point = t.map(corner.pos);
252 for (
const auto &path: paths) {
float value(const T *src, size_t ch)
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void drawHandleSmallCircle(const QPointF ¢er)
void drawPath(const QPainterPath &path)
void drawGradientCrossHandle(const QPointF ¢er, qreal radius)
void drawHandleRect(const QPointF ¢er, qreal radius)
void drawConnectionLine(const QLineF &line)
void setHandleStyle(const KisHandleStyle &style)
void drawGradientHandle(const QPointF ¢er, qreal radius)
void drawGradientArrow(const QPointF &start, const QPointF &end, qreal radius)
void drawRubberLine(const QPolygonF &poly)
void drawHandleCircle(const QPointF ¢er, qreal radius)
static KisHandleStyle & gradientArrows(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & highlightedPrimaryHandlesWithSolidOutline(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & gradientHandles(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & secondarySelection(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & primarySelection(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & highlightedPrimaryHandles(KisHandlePalette palette=KisHandlePalette())
QVariant resource(int key) const
virtual KisHandlePalette handlePaletteForDisplayColorSpace() const =0
handlePaletteForDisplayColorSpace
const QList< KoShape * > selectedVisibleShapes() const
QRectF outlineRect() const override
const QList< KoShape * > selectedEditableShapes() const
QGradient::Type type() const
QVector< Handle > handles() const
QPainterPath path() const
QVector< QPainterPath > getConnectedPath(const Handle &handle) const
Handle getHandle(SvgMeshPosition position) const
convenience method to get a handle by its position in the mesharray
QPointF getAttachedCorner(const Handle &bezierHandle) const
get the attached corner node of the bezierHandle
QVector< Handle > handles() const
get all nodes in the mesh, don't use this for drawing the path but use path()
virtual QRectF outlineRect() const
virtual QPainterPath outline() const
virtual bool isShapeEditable(bool recursive=true) const
checks recursively if the shape or one of its parents is not visible or locked
QTransform absoluteTransformation() const
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
static QList< KoShape * > linearizeSubtree(const QList< KoShape * > &shapes)
void setDecorationThickness(int thickness)
bool m_showFillGradientHandles
void paintGradientHandles(KoShape *shape, KoFlake::FillVariant fillVariant, QPainter &painter, const KoViewConverter &converter)
void setCurrentMeshGradientHandles(const KoShapeMeshGradientHandles::Handle &selectedHandle, const KoShapeMeshGradientHandles::Handle &hoveredHandle)
int m_decorationThickness
KoColorDisplayRendererInterface * m_rendererInterface
void paint(QPainter &painter, const KoViewConverter &converter)
void setSelection(KoSelection *selection)
KoFlake::AnchorPosition m_hotPosition
void paintMeshGradientHandles(KoShape *shape, KoFlake::FillVariant fillVariant, QPainter &painter, const KoViewConverter &converter)
void setShowFillMeshGradientHandles(bool value)
bool m_showStrokeFillGradientHandles
bool m_showFillMeshGradientHandles
void setForceShapeOutlines(bool value)
KoSelection * m_selection
void setShowStrokeFillGradientHandles(bool value)
bool m_forceShapeOutlines
void setHandleRadius(int radius)
SelectionDecorator(KoCanvasResourceProvider *resourceManager, KoColorDisplayRendererInterface *displayInterface)
KoShapeMeshGradientHandles::Handle m_selectedMeshHandle
KoShapeMeshGradientHandles::Handle m_currentHoveredMeshHandle
void setShowFillGradientHandles(bool value)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
KRITAFLAKE_EXPORT QPointF anchorToPoint(AnchorPosition anchor, const QRectF rect, bool *valid=0)
rgba palette[MAX_PALETTE]
SvgMeshPosition getPosition() const