Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Initial implementation of text-on-path position adjustment.
Wolthera van Hövell tot Westerflierf1bc39f69f9c
diff --git a/libs/command/kis_command_ids.h b/libs/command/kis_command_ids.hindex 33bbe407eb..b1ae06d390 100644--- a/libs/command/kis_command_ids.h+++ b/libs/command/kis_command_ids.h@@ -44,6 +44,7 @@ enum CommandId {KoShapeMergeTextPropertiesCommandId,ImageAnimSettingCommandId,SvgTextChangeTransformsOnRangeCommandId,+ SvgTextPathInfoChangeCommandId};}diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cppindex 7a559075c4..1e02440581 100644--- a/libs/flake/text/KoSvgTextShape.cpp+++ b/libs/flake/text/KoSvgTextShape.cpp@@ -114,7 +114,7 @@ KoSvgTextNodeIndex KoSvgTextShape::Private::createTextNodeIndex(KisForest<KoSvgTKoSvgTextNodeIndex::KoSvgTextNodeIndex(const KoSvgTextNodeIndex &rhs){- d->textElement = rhs.d->textElement;+ d.reset(new KoSvgTextNodeIndex::Private(rhs.d->textElement, rhs.d->textPath));}KoSvgTextNodeIndex::~KoSvgTextNodeIndex() {@@ -122,18 +122,23 @@ KoSvgTextNodeIndex::~KoSvgTextNodeIndex() {}KoSvgTextProperties *KoSvgTextNodeIndex::properties(){+ if (!d) { return nullptr;}return &d->textElement->properties;}KoSvgText::TextOnPathInfo *KoSvgTextNodeIndex::textPathInfo() {+ if (!d) {+ qDebug() << "d not initialized...";+ return nullptr;+ }return &d->textElement->textPathInfo;}KoShape *KoSvgTextNodeIndex::textPath() {+ if (!d) { qDebug() << "d not initialized...";return nullptr;}return d->textPath;}-KoSvgTextShape::KoSvgTextShape(): KoShape(), d(new Private)@@ -1458,12 +1463,25 @@ QPair<int, int> KoSvgTextShape::findRangeForNodeIndex(const KoSvgTextNodeIndex &KoSvgTextNodeIndex KoSvgTextShape::topLevelNodeForPos(int pos) const{+ auto candidate = d->textData.childBegin();+ if (d->isLoading || d->cursorPos.isEmpty()) return d->createTextNodeIndex(candidate);+ if (childBegin(d->textData.childBegin()) != childEnd(d->textData.childBegin())) {+ candidate = childBegin(d->textData.childBegin());+ }const int finalPos = d->cursorPos.size() - 1;const int index = d->cursorPos.at(qBound(0, pos, finalPos)).index;int currentIndex = 0;- auto element = KisForestDetail::siblingCurrent(Private::findTextContentElementForIndex(d->textData, currentIndex, index, true));- if (element == d->textData.childBegin()) return d->createTextNodeIndex(d->textData.childBegin());- return d->createTextNodeIndex(Private::findTopLevelParent(d->textData.childBegin(), element));++ auto e = Private::findTextContentElementForIndex(d->textData, currentIndex, index, true);+ if (e == d->textData.depthFirstTailEnd()) {+ return d->createTextNodeIndex(candidate);+ }++ auto element = KisForestDetail::siblingCurrent(e);+ auto parent = Private::findTopLevelParent(d->textData.childBegin(), element);+ if (parent == childEnd(d->textData.childBegin())) return d->createTextNodeIndex(candidate);++ return d->createTextNodeIndex(parent);}KoSvgTextProperties KoSvgTextShape::textProperties() constdiff --git a/libs/flake/text/KoSvgTextShapeOutlineHelper.h b/libs/flake/text/KoSvgTextShapeOutlineHelper.hindex 76fc26610b..be0b3dbdf2 100644--- a/libs/flake/text/KoSvgTextShapeOutlineHelper.h+++ b/libs/flake/text/KoSvgTextShapeOutlineHelper.h@@ -73,6 +73,7 @@ public:bool updateTextContourMode();void toggleTextContourMode(KoSvgTextShape *shape);+private:void paintTextShape(QPainter *painter, const KoViewConverter &converter,const QPalette &pal, KoSvgTextShape *text,diff --git a/plugins/tools/svgtexttool/CMakeLists.txt b/plugins/tools/svgtexttool/CMakeLists.txtindex 6650debdce..dd5801f4a8 100644--- a/plugins/tools/svgtexttool/CMakeLists.txt+++ b/plugins/tools/svgtexttool/CMakeLists.txt@@ -29,6 +29,9 @@ set (SvgTextTool_SRCSSvgTextChangeTransformsOnRange.cppSvgTextTypeSettingStrategy.cppSvgTextRemoveTransformsFromRange.cpp+ SvgTextPathInfoChangeCommand.cpp+ SvgChangeTextPathInfoStrategy.cpp+ SvgTextOnPathDecorationHelper.cppglyphpalette/GlyphPaletteDialog.cppglyphpalette/GlyphPaletteProxyModel.cppdiff --git a/plugins/tools/svgtexttool/SvgChangeTextPathInfoStrategy.cpp b/plugins/tools/svgtexttool/SvgChangeTextPathInfoStrategy.cppnew file mode 100644index 0000000000..b3d660e22e--- /dev/null+++ b/plugins/tools/svgtexttool/SvgChangeTextPathInfoStrategy.cpp@@ -0,0 +1,101 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */+#include "SvgChangeTextPathInfoStrategy.h"++#include "SvgTextPathInfoChangeCommand.h"+#include <KoPathSegment.h>+#include <KoPathShape.h>+#include <KoToolBase.h>+#include "SvgTextTool.h"+#include <qmath.h>+#include <QDebug>++SvgChangeTextPathInfoStrategy::SvgChangeTextPathInfoStrategy(SvgTextTool *tool, KoSvgTextShape *shape, const QPointF &clicked, int textCursorPos)+ :KoInteractionStrategy(tool)+ , m_shape(shape)+ , m_currentMousePos(clicked)+ , m_textCursorPos(textCursorPos)+{+ KoSvgTextNodeIndex index = m_shape->topLevelNodeForPos(m_textCursorPos);+ m_oldInfo = *(index.textPathInfo());++}++void SvgChangeTextPathInfoStrategy::handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers)+{+ Q_UNUSED(modifiers)++ m_currentMousePos = mouseLocation;++ KUndo2Command *cmd = createCommand();+ if (cmd) {+ cmd->redo();+ }+ tool()->repaintDecorations();+}++KUndo2Command *SvgChangeTextPathInfoStrategy::createCommand()+{+ SvgTextTool *const tool = qobject_cast<SvgTextTool *>(this->tool());+ KoSvgTextNodeIndex index = m_shape->topLevelNodeForPos(m_textCursorPos);+ KoShape *shape = index.textPath();+ if (!shape) {+ return nullptr;+ }++ KoPathShape *path = dynamic_cast<KoPathShape*>(shape);+ KoSvgText::TextOnPathInfo info;++ const qreal grab = tool->grabSensitivityInPt();+ /*QRectF roi = path->boundingRect();+ roi.adjust(-grab, -grab, grab, grab);*/+ KoPathSegment segment = path->segmentAtPoint(m_currentMousePos, tool->handleGrabRect(m_currentMousePos));++ if (!segment.isValid()) {+ return nullptr;+ }++ QList<KoPathSegment> segments = path->segmentsAt(path->outlineRect().adjusted(-grab, -grab, grab, grab));++ Q_FOREACH(KoPathSegment s, segments) {+ if (s == segment) {+ const qreal t = segment.nearestPoint(path->documentToShape(m_currentMousePos));+ info.startOffset += (t * segment.length());++ QPainterPath p = path->transformation().map(path->outline());+ qDebug() << info.startOffset/p.length();+ const qreal angle = p.angleAtPercent(fmod(info.startOffset/p.length(), 1.0))+90;+ if (fabs(QLineF(segment.pointAt(t), m_currentMousePos).angle() - angle) < 90) {+ info.side = KoSvgText::TextPathSideRight;+ } else {+ info.side = KoSvgText::TextPathSideLeft;+ }+ if (info.side == KoSvgText::TextPathSideRight) {+ info.startOffset = p.length() - info.startOffset;+ }+ break;+ }+ info.startOffset += s.length();+ }++ KUndo2Command *cmd = new SvgTextPathInfoChangeCommand(m_shape, m_textCursorPos, info);+ cmd->setText(kundo2_i18n("Change Text On Path Position"));+ return cmd;+}++void SvgChangeTextPathInfoStrategy::cancelInteraction()+{+ KUndo2Command *cmd = new SvgTextPathInfoChangeCommand(m_shape, m_textCursorPos, m_oldInfo);+ if (cmd) {+ cmd->undo();+ }+ tool()->repaintDecorations();+}++void SvgChangeTextPathInfoStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)+{++}diff --git a/plugins/tools/svgtexttool/SvgChangeTextPathInfoStrategy.h b/plugins/tools/svgtexttool/SvgChangeTextPathInfoStrategy.hnew file mode 100644index 0000000000..75362410c9--- /dev/null+++ b/plugins/tools/svgtexttool/SvgChangeTextPathInfoStrategy.h@@ -0,0 +1,34 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */+#ifndef SVGCHANGETEXTPATHINFOSTRATEGY_H+#define SVGCHANGETEXTPATHINFOSTRATEGY_H++#include <KoInteractionStrategy.h>++#include <KoSvgTextShape.h>+#include <KoSvgText.h>+++class SvgTextTool;++class SvgChangeTextPathInfoStrategy : public KoInteractionStrategy+{+public:+ SvgChangeTextPathInfoStrategy(SvgTextTool *tool, KoSvgTextShape *shape, const QPointF &clicked, int textCursorPos);+ ~SvgChangeTextPathInfoStrategy() override = default;++ void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;+ KUndo2Command *createCommand() override;+ void cancelInteraction() override;+ void finishInteraction(Qt::KeyboardModifiers modifiers) override;+private:+ KoSvgTextShape *m_shape;+ QPointF m_currentMousePos;+ int m_textCursorPos;+ KoSvgText::TextOnPathInfo m_oldInfo;+};++#endif // SVGCHANGETEXTPATHINFOSTRATEGY_Hdiff --git a/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp b/plugins/tools/svgtexttool/SvgCreateTextStrategy.cppindex 4a6ee5c471..6460150bf0 100644--- a/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp+++ b/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp@@ -22,6 +22,7 @@#include "commands/KoKeepShapesSelectedCommand.h"#include "commands/KoShapeMoveCommand.h"#include "commands/KoSvgTextAddRemoveShapeCommands.h"+#include "SvgTextPathInfoChangeCommand.h"#include "kis_global.h"#include "kundo2command.h"@@ -150,9 +151,27 @@ KUndo2Command *SvgCreateTextStrategy::createCommand()textShape->setPosition(m_flowShape->absolutePosition(KoFlake::TopLeft));KoPathShape *path = dynamic_cast<KoPathShape*>(m_flowShape);- if (path && path->segmentAtPoint(m_dragStart, tool->handleGrabRect(m_dragStart)).isValid()) {+ KoPathSegment segment;+ if(path) {+ segment = path->segmentAtPoint(m_dragStart, tool->handleGrabRect(m_dragStart));+ }+ if (segment.isValid()) {int pos = textShape->posForIndex(textShape->plainText().size());new KoSvgTextSetTextPathOnRangeCommand(textShape, m_flowShape, 0, pos, parentCommand);++ KoSvgText::TextOnPathInfo info;+ const qreal grab = tool->grabSensitivityInPt();+ QList<KoPathSegment> segments = path->segmentsAt(path->outlineRect().adjusted(-grab, -grab, grab, grab));+ Q_FOREACH(KoPathSegment s, segments) {+ if (s == segment) {+ info.startOffset += (segment.nearestPoint(path->documentToShape(m_dragStart))*segment.length());+ break;+ }+ info.startOffset += s.length();+ qDebug() << info.startOffset << s.length();+ }+ qDebug() << "setting path at..." << info.startOffset << segments.size();+ new SvgTextPathInfoChangeCommand(textShape, 2, info, parentCommand);} else {new KoSvgTextAddShapeCommand(textShape, m_flowShape, true, parentCommand);}diff --git a/plugins/tools/svgtexttool/SvgTextOnPathDecorationHelper.cpp b/plugins/tools/svgtexttool/SvgTextOnPathDecorationHelper.cppnew file mode 100644index 0000000000..46d3756cf2--- /dev/null+++ b/plugins/tools/svgtexttool/SvgTextOnPathDecorationHelper.cpp@@ -0,0 +1,126 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */+#include "SvgTextOnPathDecorationHelper.h"++#include <KoSvgTextShape.h>+#include <KisHandlePainterHelper.h>+#include <KoViewConverter.h>+#include <QDebug>+#include <KoPathShape.h>+struct SvgTextOnPathDecorationHelper::Private {+ KoSvgTextShape *shape = nullptr;+ int pos = 0;++ qreal handleRadius = 7;+ qreal decorationThickness = 1;+ QPointF lastMousePos;++ QLineF getLineAnchorTextNode(KoSvgTextNodeIndex &index, qreal lineLength) {+ KoPathShape *s = dynamic_cast<KoPathShape*>(index.textPath());+ QPainterPath outline = s->transformation().map(s->outline());+ QLineF line;+ qreal percent = index.textPathInfo()->startOffsetIsPercentage?+ index.textPathInfo()->startOffset * 0.01:+ index.textPathInfo()->startOffset / outline.length();+ if (s->isClosedSubpath(s->subpathCount()-1)) {+ percent = fmod(percent, 1.0);+ } else {+ percent = qBound(0.0, percent, 1.0);+ }+ if (index.textPathInfo()->side == KoSvgText::TextPathSideRight) {+ percent = 1.0 - percent;+ }+ line.setP1(outline.pointAtPercent(percent));+ line.setAngle(outline.angleAtPercent(percent)-90.0);+ line.setLength(lineLength);+ return line;+ }+};++SvgTextOnPathDecorationHelper::SvgTextOnPathDecorationHelper(): d(new Private)+{++}++SvgTextOnPathDecorationHelper::~SvgTextOnPathDecorationHelper()+{++}++void SvgTextOnPathDecorationHelper::setPos(int pos)+{+ d->pos = pos;+}++void SvgTextOnPathDecorationHelper::setShape(KoSvgTextShape *shape)+{+ d->shape = shape;+}++void SvgTextOnPathDecorationHelper::setHandleRadius(qreal radius)+{+ d->handleRadius = radius;+}++void SvgTextOnPathDecorationHelper::setDecorationThickness(qreal thickness)+{+ d->decorationThickness = thickness;+}++bool SvgTextOnPathDecorationHelper::hitTest(QPointF mouseInPts)+{+ if (d->lastMousePos != mouseInPts) {+ d->lastMousePos = mouseInPts;+ }+ if (!d->shape) return false;+ KoSvgTextNodeIndex index = d->shape->topLevelNodeForPos(d->pos);+ if (!(index.textPath() && index.textPathInfo())) return false;++ QLineF line = d->getLineAnchorTextNode(index, 0);+ line = d->shape->absoluteTransformation().map(line);+ return (QLineF(line.p2(), mouseInPts).length() <= d->handleRadius);+}++void SvgTextOnPathDecorationHelper::paint(QPainter *p, const KoViewConverter &converter)+{+ if (!d->shape) return;+ KoSvgTextNodeIndex index = d->shape->topLevelNodeForPos(d->pos);+ if (!(index.textPath() && index.textPathInfo())) return;++ QLineF line = d->getLineAnchorTextNode(index, 0);+ p->save();+ KisHandlePainterHelper helper =+ KoShape::createHandlePainterHelperView(p, d->shape, converter, d->handleRadius, d->decorationThickness);+ // TODO: fix handle.+ if (QLineF(converter.documentToView().map(line.p2()), d->lastMousePos).length() <= converter.viewToDocumentX(d->handleRadius)) {+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());+ } else {+ helper.setHandleStyle(KisHandleStyle::secondarySelection());+ }++ helper.drawConnectionLine(line);+ helper.drawHandleCircle(line.p2());+ //qDebug() << line.p2();+ p->restore();+}++QRectF SvgTextOnPathDecorationHelper::decorationRect(const QTransform documentToView) const+{+ QRectF r;+ if (!d->shape) return r;+ KoSvgTextNodeIndex index = d->shape->topLevelNodeForPos(d->pos);+ if (!(index.textPath() && index.textPathInfo())) return r;++ QLineF line = d->getLineAnchorTextNode(index, 0);+ line = documentToView.map(line);+ r |= QRectF(line.p1()-QPointF(d->decorationThickness, d->decorationThickness), line.p2()+QPointF(d->decorationThickness, d->decorationThickness));++ QPointF handle(d->handleRadius, d->handleRadius);+ r |= QRectF(line.p2() - handle, line.p2() + handle);++ //qDebug() << "decor rect" << r << line.p2();+ return r;+}diff --git a/plugins/tools/svgtexttool/SvgTextOnPathDecorationHelper.h b/plugins/tools/svgtexttool/SvgTextOnPathDecorationHelper.hnew file mode 100644index 0000000000..9a9c590770--- /dev/null+++ b/plugins/tools/svgtexttool/SvgTextOnPathDecorationHelper.h@@ -0,0 +1,68 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */+#ifndef SVGTEXTONPATHDECORATIONHELPER_H+#define SVGTEXTONPATHDECORATIONHELPER_H++#include <QPointF>+#include <QPainter>+++class KoSvgTextShape;+class KoViewConverter;+/**+ * @brief The SvgTextOnPathDecorationHelper class+ */+class SvgTextOnPathDecorationHelper+{+public:+ SvgTextOnPathDecorationHelper();+ ~SvgTextOnPathDecorationHelper();++ /**+ * @brief setPos+ * the the position of the cursor, where+ * the text path is sought. A single text shape+ * can have multiple paths, and this is how they+ * are distinguished.+ * @param pos -- a text cursor position.+ */+ void setPos(int pos);++ /**+ * @brief setShape+ * Set the shape for which to draw the text path.+ * @param shape -- text shape.+ */+ void setShape(KoSvgTextShape *shape);++ void setHandleRadius(qreal radius);+ void setDecorationThickness(qreal thickness);++ /**+ * @brief hitTest+ * @return whether the current position is over a handle.+ */+ bool hitTest(QPointF mouseInPts);++ /**+ * @brief paint+ * Paint the handles for the text path.+ */+ void paint(QPainter *painter, const KoViewConverter &converter);++ /**+ * @brief decorationRect+ * @param documentToView -- document to view transform.+ * @return the decoration rect.+ */+ QRectF decorationRect(const QTransform documentToView) const;++private:+ struct Private;+ QScopedPointer<Private> d;+};++#endif // SVGTEXTONPATHDECORATIONHELPER_Hdiff --git a/plugins/tools/svgtexttool/SvgTextPathInfoChangeCommand.cpp b/plugins/tools/svgtexttool/SvgTextPathInfoChangeCommand.cppnew file mode 100644index 0000000000..295315e12b--- /dev/null+++ b/plugins/tools/svgtexttool/SvgTextPathInfoChangeCommand.cpp@@ -0,0 +1,71 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */+#include "SvgTextPathInfoChangeCommand.h"+#include "kis_command_ids.h"++SvgTextPathInfoChangeCommand::SvgTextPathInfoChangeCommand(KoSvgTextShape *shape, int pos, KoSvgText::TextOnPathInfo textPathInfo, KUndo2Command *parent)+ : KUndo2Command(parent)+ , m_shape(shape)+ , m_textData(shape->getMemento())+ , m_pos(pos)+ , m_newInfo(textPathInfo)+{+ qWarning() << m_shape->topLevelNodeForPos(m_pos).textPath();+ setText(kundo2_i18n("Change Text On Path Properties"));+}++void SvgTextPathInfoChangeCommand::redo()+{+ QRectF updateRect = m_shape->boundingRect();+ KoSvgTextNodeIndex index = m_shape->topLevelNodeForPos(m_pos);+++ if (m_newInfo.side != index.textPathInfo()->side) {+ KoSvgText::TextAnchor anchor = KoSvgText::TextAnchor(index.properties()->propertyOrDefault(KoSvgTextProperties::TextAnchorId).toInt());+ anchor = anchor == KoSvgText::AnchorStart? KoSvgText::AnchorEnd:+ anchor == KoSvgText::AnchorEnd? KoSvgText::AnchorStart: KoSvgText::AnchorMiddle;+ index.properties()->setProperty(KoSvgTextProperties::TextAnchorId, anchor);+ }++ index.textPathInfo()->startOffset = m_newInfo.startOffset;+ index.textPathInfo()->side = m_newInfo.side;+ index.textPathInfo()->method = m_newInfo.method;+ index.textPathInfo()->startOffsetIsPercentage = m_newInfo.startOffsetIsPercentage;+ index.textPathInfo()->spacing = m_newInfo.spacing;+ qDebug() << "old txtpath info" << index.textPathInfo()->side << index.textPathInfo()->startOffset;++ m_shape->relayout();+ m_shape->notifyChanged();+ updateRect |= m_shape->boundingRect();+ m_shape->notifyCursorPosChanged(m_pos, m_pos);+ m_shape->updateAbsolute(updateRect);+}++void SvgTextPathInfoChangeCommand::undo()+{+ QRectF updateRect = m_shape->boundingRect();+ m_shape->setMemento(m_textData, m_pos, m_pos);+ updateRect |= m_shape->boundingRect();+ m_shape->updateAbsolute(updateRect);+}++int SvgTextPathInfoChangeCommand::id() const+{+ return KisCommandUtils::SvgTextPathInfoChangeCommandId;+}++bool SvgTextPathInfoChangeCommand::mergeWith(const KUndo2Command *other)+{+ const SvgTextPathInfoChangeCommand *command = dynamic_cast<const SvgTextPathInfoChangeCommand*>(other);++ if (!command || command->m_shape != m_shape || m_pos != command->m_pos) {+ return false;+ }++ m_newInfo = command->m_newInfo;+ return true;++}diff --git a/plugins/tools/svgtexttool/SvgTextPathInfoChangeCommand.h b/plugins/tools/svgtexttool/SvgTextPathInfoChangeCommand.hnew file mode 100644index 0000000000..f7aba3cf9d--- /dev/null+++ b/plugins/tools/svgtexttool/SvgTextPathInfoChangeCommand.h@@ -0,0 +1,33 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */+#ifndef SVGTEXTPATHINFOCHANGECOMMAND_H+#define SVGTEXTPATHINFOCHANGECOMMAND_H++#include <kundo2command.h>+#include "kritatoolsvgtext_export.h"++#include <KoSvgTextShape.h>+#include <KoSvgText.h>++class KRITATOOLSVGTEXT_EXPORT SvgTextPathInfoChangeCommand : public KUndo2Command+{+public:+ SvgTextPathInfoChangeCommand(KoSvgTextShape *shape, int pos, KoSvgText::TextOnPathInfo textPathInfo, KUndo2Command *parent = nullptr);++ void redo() override;+ void undo() override;++ int id() const override;+ bool mergeWith(const KUndo2Command *other) override;++private:+ KoSvgTextShape *m_shape;+ KoSvgTextShapeMementoSP m_textData;+ int m_pos;+ KoSvgText::TextOnPathInfo m_newInfo;+};++#endif // SVGTEXTPATHINFOCHANGECOMMAND_Hdiff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp b/plugins/tools/svgtexttool/SvgTextTool.cppindex 556ed47a09..516c99b825 100644--- a/plugins/tools/svgtexttool/SvgTextTool.cpp+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp@@ -24,6 +24,7 @@#include "SvgTextToolOptionsModel.h"#include "SvgTextTypeSettingStrategy.h"#include "SvgTextChangeTransformsOnRange.h"+#include "SvgChangeTextPathInfoStrategy.h"#include <QPainterPath>#include <QDesktopServices>@@ -146,6 +147,8 @@ SvgTextTool::SvgTextTool(KoCanvasBase *canvas)m_textOutlineHelper->setDrawBoundingRect(false);m_textOutlineHelper->setDrawTextWrappingArea(true);+ connect(&m_textCursor, SIGNAL(selectionChanged()), this, SLOT(updateTextPathHelper()));+m_base_cursor = QCursor(QPixmap(":/tool_text_basic.xpm"), 7, 7);m_text_inline_horizontal = QCursor(QPixmap(":/tool_text_inline_horizontal.xpm"), 7, 7);m_text_inline_vertical = QCursor(QPixmap(":/tool_text_inline_vertical.xpm"), 7, 7);@@ -359,6 +362,11 @@ void SvgTextTool::updateGlyphPalette()}}+void SvgTextTool::updateTextPathHelper()+{+ m_textOnPathHelper.setPos(m_textCursor.getPos());+}+void SvgTextTool::insertRichText(KoSvgTextShape *richText, bool replaceLastGlyph){if (replaceLastGlyph) {@@ -454,6 +462,7 @@ void SvgTextTool::slotShapeSelectionChanged()KoSvgTextShape *const shape = selectedShape();if (shape != m_textCursor.shape()) {m_textCursor.setShape(shape);+ m_textOnPathHelper.setShape(shape);if (shape) {setTextMode(true);} else {@@ -649,6 +658,7 @@ QRectF SvgTextTool::decorationsRect() constrect |= m_hoveredShapeHighlightRect.boundingRect();rect |= m_textOutlineHelper->decorationRect();+ rect |= m_textOnPathHelper.decorationRect(canvas()->viewConverter()->documentToView());return rect;}@@ -708,6 +718,9 @@ void SvgTextTool::paint(QPainter &gc, const KoViewConverter &converter)m_textOutlineHelper->setDecorationThickness(decorationThickness());m_textOutlineHelper->setHandleRadius(handleRadius());m_textOutlineHelper->paint(&gc, converter);+ m_textOnPathHelper.setDecorationThickness(decorationThickness());+ m_textOnPathHelper.setHandleRadius(handleRadius());+ m_textOnPathHelper.paint(&gc, converter);gc.setTransform(converter.documentToView(), true);{KisHandlePainterHelper handlePainter(&gc, handleRadius(), decorationThickness());@@ -766,6 +779,11 @@ void SvgTextTool::mousePressEvent(KoPointerEvent *event)event->accept();return;}+ } else if (m_textOnPathHelper.hitTest(event->point)) {+ m_interactionStrategy.reset(new SvgChangeTextPathInfoStrategy(this, selectedShape, event->point, m_textCursor.getPos()));+ m_dragging = DragMode::TextPathHandle;+ event->accept();+ return;} else if (m_highlightItem == HighlightItem::MoveBorder) {m_interactionStrategy.reset(new SvgMoveTextStrategy(this, selectedShape, event->point));m_dragging = DragMode::Move;@@ -876,6 +894,8 @@ void SvgTextTool::mouseMoveEvent(KoPointerEvent *event)} else {useCursor(m_ibeam_vertical);}+ } else {+ useCursor(Qt::ArrowCursor);}event->accept();} else {diff --git a/plugins/tools/svgtexttool/SvgTextTool.h b/plugins/tools/svgtexttool/SvgTextTool.hindex 61877aad97..8779393821 100644--- a/plugins/tools/svgtexttool/SvgTextTool.h+++ b/plugins/tools/svgtexttool/SvgTextTool.h@@ -20,6 +20,7 @@#include "SvgTextCursor.h"#include "SvgTextToolOptionsManager.h"+#include "SvgTextOnPathDecorationHelper.h"#include "glyphpalette/GlyphPaletteDialog.h"#include <memory>@@ -27,7 +28,6 @@class KoSelection;class SvgTextEditor;class KoSvgTextShape;-class SvgTextCursor;class KoInteractionStrategy;class KUndo2Command;@@ -36,6 +36,7 @@ class SvgTextTool : public KoToolBaseQ_OBJECTfriend class SvgCreateTextStrategy;+ friend class SvgChangeTextPathInfoStrategy;public:explicit SvgTextTool(KoCanvasBase *canvas);@@ -119,6 +120,8 @@ private Q_SLOTS:* update the glyph palette dialog from the current selection.*/void updateGlyphPalette();++ void updateTextPathHelper();/*** @brief insertRichText* Insert a rich text shape, used by the glyph palette..@@ -197,6 +200,7 @@ private:Select,InlineSizeHandle,Move,+ TextPathHandle,};enum class HighlightItem {None = 0,@@ -220,6 +224,7 @@ private:SvgTextCursor m_textCursor;+ SvgTextOnPathDecorationHelper m_textOnPathHelper;QScopedPointer<KoSvgTextShapeOutlineHelper> m_textOutlineHelper;KisSignalAutoConnectionsStore m_canvasConnections;