16#include <QApplication>
82 if (areas.size() <= 1)
return lines;
83 for (
int i = 1; i < areas.size(); i++) {
84 const QPainterPath previous = areas.at(i-1);
85 const QPainterPath next = areas.at(i);
86 const bool overlap = previous.intersects(next);
87 QLineF arrow(previous.boundingRect().center(), next.boundingRect().center());
90 Q_FOREACH (QPolygonF
p, previous.toSubpathPolygons()) {
91 if (
p.size() == 1)
continue;
92 for (
int j = 1; j <
p.size(); j++) {
93 QLineF l2(
p.at(j-1),
p.at(j));
95 if (l2.intersects(arrow, &intersect) == QLineF::BoundedIntersection) {
96 arrow.setP1(intersect);
101 Q_FOREACH (QPolygonF
p, next.toSubpathPolygons()) {
102 if (
p.size() == 1)
continue;
103 for (
int j = 1; j <
p.size(); j++) {
104 QLineF l2(
p.at(j-1),
p.at(j));
106 if (l2.intersects(arrow, &intersect) == QLineF::BoundedIntersection) {
107 arrow.setP2(intersect);
121 bool contourModeActive) {
126 if (contourModeActive) {
127 if (
d->drawOutline) {
141 if (
d->drawBoundingRect) {
147 if (
d->drawTextWrappingArea) {
148 if (
d->textWrappingAreasHovered) {
155 Q_FOREACH(
const QPainterPath path, areas) {
164 painter->setBrush(contourModeActive? pal.highlight(): pal.button());
166 pen.setColor(contourModeActive? pal.highlightedText().color(): pal.buttonText().color());
167 pen.setCosmetic(
true);
168 pen.setWidthF(
d->decorationThickness);
169 painter->setPen(pen);
178 const QPalette pal = qApp->palette();
183 Q_FOREACH(
KoShape* shape,
d->canvas->shapeManager()->selection()->selectedEditableShapes()) {
185 if (
d->drawButton(text)) {
198 base |=
d->getButtonRectCorrected(base);
201 Q_FOREACH(
KoShape* shape,
d->canvas->shapeManager()->selection()->selectedEditableShapes()) {
203 if (
d->drawButton(text)) {
205 base |=
d->getButtonRectCorrected(base);
215 d->drawBoundingRect = enable;
220 return d->drawBoundingRect;
225 d->drawTextWrappingArea = enable;
230 d->drawOutline = enable;
235 return d->drawOutline;
240 d->handleRadius = radius;
245 d->decorationThickness = thickness;
252 if (
d->getButtonRect(text->
boundingRect()).contains(point)) {
256 return d->getPotentialTextShape(point);
262 if (text && !
d->drawButton(text)) {
272 if (shape ==
d->canvas->currentShapeManagerOwnerShape()) {
273 d->canvas->setCurrentShapeManagerOwnerShape(
nullptr);
275 d->canvas->setCurrentShapeManagerOwnerShape(shape);
282 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()
static KisHandleStyle & secondarySelection()
virtual KoShape * currentShapeManagerOwnerShape() const
the shape that owns the currently active shape manager
virtual KoShapeManager * shapeManager() const =0
virtual const KoViewConverter * viewConverter() const =0
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 paintTextShape(QPainter *painter, const KoViewConverter &converter, const QPalette &pal, KoSvgTextShape *text, bool contourModeActive=false)
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
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()
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)