16#include <QApplication>
87 if (areas.size() <= 1)
return lines;
88 for (
int i = 1; i < areas.size(); i++) {
89 const QPainterPath previous = areas.at(i-1);
90 const QPainterPath next = areas.at(i);
91 const bool overlap = previous.intersects(next);
92 QLineF arrow(previous.boundingRect().center(), next.boundingRect().center());
95 Q_FOREACH (QPolygonF
p, previous.toSubpathPolygons()) {
96 if (
p.size() == 1)
continue;
97 for (
int j = 1; j <
p.size(); j++) {
98 QLineF l2(
p.at(j-1),
p.at(j));
100 if (l2.intersects(arrow, &intersect) == QLineF::BoundedIntersection) {
101 arrow.setP1(intersect);
106 Q_FOREACH (QPolygonF
p, next.toSubpathPolygons()) {
107 if (
p.size() == 1)
continue;
108 for (
int j = 1; j <
p.size(); j++) {
109 QLineF l2(
p.at(j-1),
p.at(j));
111 if (l2.intersects(arrow, &intersect) == QLineF::BoundedIntersection) {
112 arrow.setP2(intersect);
127 KisHandlePalette handlePalette =
d->renderInterface()->handlePaletteForDisplayColorSpace();
131 if (contourModeActive) {
132 if (
d->drawOutline) {
146 if (
d->drawBoundingRect) {
152 if (
d->drawTextWrappingArea) {
153 if (
d->textWrappingAreasHovered) {
160 Q_FOREACH(
const QPainterPath path, areas) {
167 QPalette systemPalette =
d->renderInterface()->systemPaletteForDisplayColorSpace();
170 painter->setBrush(contourModeActive? systemPalette.highlight(): systemPalette.button());
172 pen.setColor(contourModeActive? systemPalette.highlightedText().color(): systemPalette.buttonText().color());
173 pen.setCosmetic(
true);
174 pen.setWidthF(
d->decorationThickness);
175 painter->setPen(pen);
188 Q_FOREACH(
KoShape* shape,
d->canvas->shapeManager()->selection()->selectedEditableShapes()) {
190 if (
d->drawButton(text)) {
203 base |=
d->getButtonRectCorrected(base);
206 Q_FOREACH(
KoShape* shape,
d->canvas->shapeManager()->selection()->selectedEditableShapes()) {
208 if (
d->drawButton(text)) {
210 base |=
d->getButtonRectCorrected(base);
220 d->drawBoundingRect = enable;
225 return d->drawBoundingRect;
230 d->drawTextWrappingArea = enable;
235 d->drawOutline = enable;
240 return d->drawOutline;
245 d->handleRadius = radius;
250 d->decorationThickness = thickness;
257 if (
d->getButtonRect(text->
boundingRect()).contains(point)) {
261 return d->getPotentialTextShape(point);
267 if (text && !
d->drawButton(text)) {
277 if (shape ==
d->canvas->currentShapeManagerOwnerShape()) {
278 d->canvas->setCurrentShapeManagerOwnerShape(
nullptr);
280 d->canvas->setCurrentShapeManagerOwnerShape(shape);
287 d->textWrappingAreasHovered = enabled;
const int BUTTON_CORNER_ROUND
QList< QLineF > getTextAreaOrderArrows(QList< QPainterPath > areas)
const int BUTTON_ICON_SIZE
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void drawPath(const QPainterPath &path)
void setHandleStyle(const KisHandleStyle &style)
void drawGradientArrow(const QPointF &start, const QPointF &end, qreal radius)
static KisHandleStyle & partiallyHighlightedPrimaryHandles(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & secondarySelection(KisHandlePalette palette=KisHandlePalette())
virtual KoShape * currentShapeManagerOwnerShape() const
the shape that owns the currently active shape manager
virtual KoShapeManager * shapeManager() const =0
virtual const KoViewConverter * viewConverter() const =0
virtual KoColorDisplayRendererInterface * displayRendererInterface() const
displayRendererInterface The display renderer interface has a number of color conversion functions wh...
const QList< KoShape * > selectedEditableShapes() const
QList< KoShape * > shapes
virtual QPainterPath outline() const
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
QTransform transformation() const
Returns the shapes local transformation matrix.
void setDrawShapeOutlines(bool enable)
setDrawShapeOutlines Draw the shape outlines instead of only the rect.
KoSvgTextShape * contourModeButtonHovered(const QPointF &point)
KoSvgTextShapeOutlineHelper(KoCanvasBase *canvas)
~KoSvgTextShapeOutlineHelper()
bool drawShapeOutlines() const
void setDecorationThickness(int thickness)
void setDrawBoundingRect(bool enable)
setDrawBoundingRect Whether to draw the bounding rect of the shapes.
void toggleTextContourMode(KoSvgTextShape *shape)
bool updateTextContourMode()
updateTextContourMode This checks if the text contour mode still has shapes, and otherwise switches o...
bool drawBoundingRect() const
void setTextAreasHovered(bool enabled)
void setDrawTextWrappingArea(bool enable)
setDrawTextWrappingArea draw the wrapping area. The wrapping area is computed from the shapes as well...
void setHandleRadius(int radius)
void paint(QPainter *painter, const KoViewConverter &converter)
QRectF decorationRect()
decorationRect
void paintTextShape(QPainter *painter, const KoViewConverter &converter, KoSvgTextShape *text, bool contourModeActive=false)
QScopedPointer< Private > d
QRectF boundingRect() const override
Get the bounding box of the shape.
QList< QPainterPath > textWrappingAreas() const
textWrappingAreas The text wrapping areas are computed from shapesInside() and shapesSubtract(),...
QList< KoShape * > shapesInside
KoShapeManager * internalShapeManager() const
internalShapeManager
QRectF outlineRect() const override
virtual QPointF viewToDocument(const QPointF &viewPoint) const
virtual QPointF documentToView(const QPointF &documentPoint) const
QIcon loadIcon(const QString &name)
KoSvgTextShape * getTextModeShape()
KoColorDisplayRendererInterface * renderInterface()
bool textWrappingAreasHovered
Private(KoCanvasBase *canvasBase)
KoViewConverter * converter() const
QRectF getButtonRectCorrected(QRectF base)
bool drawTextWrappingArea
KoSvgTextShape * getPotentialTextShape(const QPointF &point)
QRectF getButtonRect(QRectF base)
bool drawButton(KoSvgTextShape *text)