Commit 0e71f2e7 authored by Tusooa Zhu's avatar Tusooa Zhu 🅱

Recover point selection when undo/redo

(1) The corresponding points in the original and cloned shapes
can be connected through KoPathPointIndex. Use
`cloned->pointByIndex(origIndex)` to obtain the corresponding point
in the cloned shape. Since we will also need to record the shape the
point belongs to, we can use KoPathPointData which combines these two.

(2) KoPathToolSelection has its own shape selection, and it is vital
to map it as well, since KoPathToolSelection::update() will remove any
point that is not a part of its selectedShapes().
parent 16f0a2ae
......@@ -36,31 +36,12 @@ struct KisNodeReplaceBasedStrokeStrategy::Private
Private(const Private &rhs) = default;
~Private() = default;
static QList<KoShape *> findMappedShapes(KisNodeSP oldNode, KisNodeSP newNode, QList<KoShape *> shapesToMap);
KisNodeSP affectedNode;
KisNodeSP originalState;
KisPostExecutionUndoAdapter *postExecUndoAdapter;
KoShapeManager *shapeManager;
QList<KoShape *> oldSelection;
bool nodeChanged = false;
class NodeReplaceCommand : public KUndo2Command
{
public:
NodeReplaceCommand(KisNodeSP affectedNode, KisNodeSP originalState, QList<KoShape *> oldSelection, KoShapeManager *shapeManager, const KUndo2MagicString &name);
~NodeReplaceCommand() override = default;
void undo() override;
void redo() override;
KisNodeSP m_affectedNode;
KisNodeSP m_originalState;
KisNodeSP m_editedState;
KoShapeManager *m_shapeManager;
QList<KoShape *> m_oldSelection;
QList<KoShape *> m_newSelection;
};
};
KisNodeReplaceBasedStrokeStrategy::Private::Private(KisCanvas2 *canvas)
......@@ -72,7 +53,7 @@ KisNodeReplaceBasedStrokeStrategy::Private::Private(KisCanvas2 *canvas)
shapeManager = canvas->shapeManager();
}
QList<KoShape *> KisNodeReplaceBasedStrokeStrategy::Private::findMappedShapes(KisNodeSP oldNode, KisNodeSP newNode, QList<KoShape *> shapesToMap)
QList<KoShape *> KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::findMappedShapes(KisNodeSP oldNode, KisNodeSP newNode, QList<KoShape *> shapesToMap)
{
KisShapeLayerSP oldLayer(dynamic_cast<KisShapeLayer *>(oldNode.data()));
KisShapeLayerSP newLayer(dynamic_cast<KisShapeLayer *>(newNode.data()));
......@@ -103,7 +84,7 @@ QList<KoShape *> KisNodeReplaceBasedStrokeStrategy::Private::findMappedShapes(Ki
return newShapes;
}
KisNodeReplaceBasedStrokeStrategy::Private::NodeReplaceCommand::NodeReplaceCommand(KisNodeSP affectedNode, KisNodeSP originalState, QList<KoShape *> oldSelection, KoShapeManager *shapeManager, const KUndo2MagicString &name)
KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::NodeReplaceCommand(KisNodeSP affectedNode, KisNodeSP originalState, QList<KoShape *> oldSelection, KoShapeManager *shapeManager, const KUndo2MagicString &name)
: KUndo2Command(name)
, m_affectedNode(affectedNode)
, m_originalState(originalState)
......@@ -118,7 +99,7 @@ KisNodeReplaceBasedStrokeStrategy::Private::NodeReplaceCommand::NodeReplaceComma
}
}
void KisNodeReplaceBasedStrokeStrategy::Private::NodeReplaceCommand::undo()
void KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::undo()
{
QScopedPointer<KisLockableCanvas::Locker> lock(m_shapeManager->obtainLock());
KoSelection *selection = m_shapeManager->selection();
......@@ -128,9 +109,10 @@ void KisNodeReplaceBasedStrokeStrategy::Private::NodeReplaceCommand::undo()
Q_FOREACH (KoShape *shape, shapesToSelect) {
selection->select(shape);
}
KUndo2Command::undo();
}
void KisNodeReplaceBasedStrokeStrategy::Private::NodeReplaceCommand::redo()
void KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::redo()
{
QScopedPointer<KisLockableCanvas::Locker> lock(m_shapeManager->obtainLock());
KoSelection *selection = m_shapeManager->selection();
......@@ -140,6 +122,7 @@ void KisNodeReplaceBasedStrokeStrategy::Private::NodeReplaceCommand::redo()
Q_FOREACH (KoShape *shape, shapesToSelect) {
selection->select(shape);
}
KUndo2Command::redo();
}
KisNodeReplaceBasedStrokeStrategy::KisNodeReplaceBasedStrokeStrategy(QString id, KisCanvas2 *canvas,
......@@ -155,7 +138,7 @@ KisNodeReplaceBasedStrokeStrategy::KisNodeReplaceBasedStrokeStrategy(QString id,
KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::EXCLUSIVE);
QScopedPointer<KisLockableCanvas::Locker> lock(m_d->shapeManager->obtainLock());
if (lock) { // then the current layer is a shape layer
m_d->oldSelection = m_d->findMappedShapes(m_d->affectedNode, m_d->originalState, m_d->shapeManager->selection()->selectedShapes());
m_d->oldSelection = NodeReplaceCommand::findMappedShapes(m_d->affectedNode, m_d->originalState, m_d->shapeManager->selection()->selectedShapes());
}
}
......@@ -187,14 +170,29 @@ void KisNodeReplaceBasedStrokeStrategy::cancelStrokeCallback()
void KisNodeReplaceBasedStrokeStrategy::finishStrokeCallback()
{
if (m_d->nodeChanged) {
KUndo2CommandSP cmd(new Private::NodeReplaceCommand(m_d->affectedNode, m_d->originalState, m_d->oldSelection, m_d->shapeManager, name()));
KUndo2CommandSP cmd(createCommand());
m_d->postExecUndoAdapter->addCommand(cmd);
}
}
KUndo2Command *KisNodeReplaceBasedStrokeStrategy::createCommand()
{
return new NodeReplaceCommand(m_d->affectedNode, m_d->originalState, m_d->oldSelection, m_d->shapeManager, name());
}
void KisNodeReplaceBasedStrokeStrategy::setChanged(bool changed)
{
m_d->nodeChanged = changed;
}
KisNodeSP KisNodeReplaceBasedStrokeStrategy::affectedNode()
{
return m_d->affectedNode;
}
KisNodeSP KisNodeReplaceBasedStrokeStrategy::originalState()
{
return m_d->originalState;
}
......@@ -23,11 +23,16 @@
#include <kis_resources_snapshot.h>
#include <QScopedPointer>
#include <kundo2command.h>
#include <kritaui_export.h>
#include <kis_node.h>
class KisCanvas2;
class KisStrokesFacade;
class KoShape;
class KoShapeManager;
class KRITAUI_EXPORT KisNodeReplaceBasedStrokeStrategy : public KisRunnableBasedStrokeStrategy
{
......@@ -49,6 +54,38 @@ public:
*/
void setChanged(bool changed);
public:
KisNodeSP affectedNode();
KisNodeSP originalState();
protected:
virtual KUndo2Command *createCommand();
class KRITAUI_EXPORT NodeReplaceCommand : public KUndo2Command
{
public:
NodeReplaceCommand(KisNodeSP affectedNode, KisNodeSP originalState, QList<KoShape *> oldSelection, KoShapeManager *shapeManager, const KUndo2MagicString &name);
~NodeReplaceCommand() override = default;
void undo() override;
void redo() override;
KisNodeSP affectedNode() { return m_affectedNode; }
KisNodeSP originalState() { return m_originalState; }
KisNodeSP editedState() { return m_editedState; }
KoShapeManager *shapeManager() { return m_shapeManager; }
static QList<KoShape *> findMappedShapes(KisNodeSP oldNode, KisNodeSP newNode, QList<KoShape *> shapesToMap);
private:
KisNodeSP m_affectedNode;
KisNodeSP m_originalState;
KisNodeSP m_editedState;
KoShapeManager *m_shapeManager;
QList<KoShape *> m_oldSelection;
QList<KoShape *> m_newSelection;
};
private:
struct Private;
QScopedPointer<Private> m_d;
......
......@@ -15,6 +15,8 @@ set(pathtool_SRCS
KoPathSegmentChangeStrategy.cpp
KoParameterChangeStrategy.cpp
KoPathToolInteractionStrategy.cpp
PathToolPlugin.cpp
)
......
......@@ -32,7 +32,7 @@
KoParameterChangeStrategy::KoParameterChangeStrategy(KoToolBase *tool, KoParameterShape *parameterShape, int handleId)
: KisStrokeBasedInteractionStrategy(tool)
: KoPathToolInteractionStrategy(tool)
{
startStroke(new StrokeStrategy(tool, parameterShape, handleId));
}
......@@ -58,7 +58,7 @@ struct KoParameterChangeStrategy::StrokeStrategy::Private
};
KoParameterChangeStrategy::StrokeStrategy::StrokeStrategy(KoToolBase* tool, KoParameterShape* parameterShape, int handleId)
: KisStrokeBasedInteractionStrategy::StrokeStrategy("CHANGE_PARAMETER", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Change parameter"))
: KoPathToolInteractionStrategy::StrokeStrategy("CHANGE_PARAMETER", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Change parameter"), dynamic_cast<KoPathTool *>(tool))
, d(new Private(tool, parameterShape, handleId))
{
d->tool->canvas()->snapGuide()->setIgnoredShapes({parameterShape});
......
......@@ -21,13 +21,13 @@
#define KOPARAMETERCHANGESTRATEGY_H
#include "kritaflake_export.h"
#include <KisStrokeBasedInteractionStrategy.h>
#include <KoPathToolInteractionStrategy.h>
#include <QPointF>
class KoParameterShape;
/// Strategy for changing control points of parametric shapes
class KRITAFLAKE_EXPORT KoParameterChangeStrategy : public KisStrokeBasedInteractionStrategy
class KRITAFLAKE_EXPORT KoParameterChangeStrategy : public KoPathToolInteractionStrategy
{
public:
/**
......@@ -39,7 +39,7 @@ public:
KoParameterChangeStrategy(KoToolBase *tool, KoParameterShape *parameterShape, int handleId);
~KoParameterChangeStrategy() override;
class StrokeStrategy : public KisStrokeBasedInteractionStrategy::StrokeStrategy
class StrokeStrategy : public KoPathToolInteractionStrategy::StrokeStrategy
{
public:
StrokeStrategy(KoToolBase *tool, KoParameterShape *parameterShape, int handleId);
......
......@@ -25,7 +25,7 @@
#include "KoPathTool.h"
KoPathControlPointMoveStrategy::KoPathControlPointMoveStrategy(KoPathTool *tool, const KoPathPointData &pointData, KoPathPoint::PointType type, const QPointF &pos)
: KisStrokeBasedInteractionStrategy(tool)
: KoPathToolInteractionStrategy(tool)
{
startStroke(new StrokeStrategy(tool, pointData, type, pos));
}
......@@ -35,7 +35,7 @@ KoPathControlPointMoveStrategy::~KoPathControlPointMoveStrategy()
}
KoPathControlPointMoveStrategy::StrokeStrategy::StrokeStrategy(KoPathTool* tool, const KoPathPointData& pointData, KoPathPoint::PointType type, const QPointF& pos)
: KisStrokeBasedInteractionStrategy::StrokeStrategy("MOVE_CONTROL_POINT", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Move control point"))
: KoPathToolInteractionStrategy::StrokeStrategy("MOVE_CONTROL_POINT", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Move control point"), tool)
, m_lastPosition(pos)
, m_move(0, 0)
, m_tool(tool)
......
......@@ -22,7 +22,7 @@
#define KOPATHCONTROLPOINTMOVESTRATEGY_H
#include <QPointF>
#include <KisStrokeBasedInteractionStrategy.h>
#include <KoPathToolInteractionStrategy.h>
#include "KoPathPoint.h"
#include "KoPathPointData.h"
......@@ -32,14 +32,14 @@ class KoPathTool;
* /internal
* @brief Strategy for moving points of a path shape.
*/
class KoPathControlPointMoveStrategy : public KisStrokeBasedInteractionStrategy
class KoPathControlPointMoveStrategy : public KoPathToolInteractionStrategy
{
public:
KoPathControlPointMoveStrategy(KoPathTool* tool, const KoPathPointData& pointData,
KoPathPoint::PointType type, const QPointF& pos);
~KoPathControlPointMoveStrategy() override;
class StrokeStrategy : public KisStrokeBasedInteractionStrategy::StrokeStrategy
class StrokeStrategy : public KoPathToolInteractionStrategy::StrokeStrategy
{
public:
StrokeStrategy(KoPathTool* tool, const KoPathPointData& pointData,
......
......@@ -31,7 +31,7 @@
KoPathPointMoveStrategy::KoPathPointMoveStrategy(KoPathTool *tool, const QPointF &pos)
: KisStrokeBasedInteractionStrategy(tool)
: KoPathToolInteractionStrategy(tool)
{
startStroke(new StrokeStrategy(tool, pos));
}
......@@ -41,7 +41,7 @@ KoPathPointMoveStrategy::~KoPathPointMoveStrategy()
}
KoPathPointMoveStrategy::StrokeStrategy::StrokeStrategy(KoPathTool* tool, const QPointF& pos)
: KisStrokeBasedInteractionStrategy::StrokeStrategy("MOVE_PATH_POINT", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Move points"))
: KoPathToolInteractionStrategy::StrokeStrategy("MOVE_PATH_POINT", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Move points"), tool)
, m_originalPosition(pos)
, m_tool(tool)
{
......
......@@ -22,7 +22,7 @@
#define KOPATHPOINTMOVESTRATEGY_H
#include <QPointF>
#include <KisStrokeBasedInteractionStrategy.h>
#include <KoPathToolInteractionStrategy.h>
class KoPathTool;
......@@ -31,13 +31,13 @@ class KoPathPointData;
/**
* @brief Strategy for moving points of a path shape.
*/
class KoPathPointMoveStrategy : public KisStrokeBasedInteractionStrategy
class KoPathPointMoveStrategy : public KoPathToolInteractionStrategy
{
public:
KoPathPointMoveStrategy(KoPathTool *tool, const QPointF &pos);
~KoPathPointMoveStrategy() override;
class StrokeStrategy : public KisStrokeBasedInteractionStrategy::StrokeStrategy
class StrokeStrategy : public KoPathToolInteractionStrategy::StrokeStrategy
{
public:
StrokeStrategy(KoPathTool *tool, const QPointF &pos);
......
......@@ -29,7 +29,7 @@
#include <math.h>
KoPathSegmentChangeStrategy::KoPathSegmentChangeStrategy(KoPathTool *tool, const QPointF &pos, const KoPathPointData &segment, qreal segmentParam)
: KisStrokeBasedInteractionStrategy(tool)
: KoPathToolInteractionStrategy(tool)
{
startStroke(new StrokeStrategy(tool, pos, segment, segmentParam));
}
......@@ -39,7 +39,7 @@ KoPathSegmentChangeStrategy::~KoPathSegmentChangeStrategy()
}
KoPathSegmentChangeStrategy::StrokeStrategy::StrokeStrategy(KoPathTool* tool, const QPointF& pos, const KoPathPointData& segment, qreal segmentParam)
: KisStrokeBasedInteractionStrategy::StrokeStrategy("CHANGE_SEGMENT", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Change Segment"))
: KoPathToolInteractionStrategy::StrokeStrategy("CHANGE_SEGMENT", dynamic_cast<KisCanvas2 *>(tool->canvas()), kundo2_i18n("Change Segment"), tool)
, m_originalPosition(pos)
, m_lastPosition(pos)
, m_tool(tool)
......
......@@ -20,7 +20,7 @@
#ifndef KOPATHSEGMENTCHANGESTRATEGY_H
#define KOPATHSEGMENTCHANGESTRATEGY_H
#include <KisStrokeBasedInteractionStrategy.h>
#include <KoPathToolInteractionStrategy.h>
#include "KoPathSegment.h"
#include "KoPathPointData.h"
#include <QPointF>
......@@ -31,13 +31,13 @@ class KoPathShape;
/**
* @brief Strategy for deforming a segment of a path shape.
*/
class KoPathSegmentChangeStrategy : public KisStrokeBasedInteractionStrategy
class KoPathSegmentChangeStrategy : public KoPathToolInteractionStrategy
{
public:
KoPathSegmentChangeStrategy(KoPathTool* tool, const QPointF& pos, const KoPathPointData& segment, qreal segmentParam);
~KoPathSegmentChangeStrategy() override;
class StrokeStrategy : public KisStrokeBasedInteractionStrategy::StrokeStrategy
class StrokeStrategy : public KoPathToolInteractionStrategy::StrokeStrategy
{
public:
StrokeStrategy(KoPathTool* tool, const QPointF& pos, const KoPathPointData& segment, qreal segmentParam);
......
/* This file is part of the KDE project
* Copyright (C) 2019 Tusooa Zhu <tusooa@vista.aero>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoPathToolInteractionStrategy.h"
#include "KoPathTool.h"
#include "KoShapeManager.h"
#include "KoPathToolSelection.h"
#include <KoPathPointData.h>
#include <kis_pointer_utils.h>
#include <QDebug>
struct KoPathToolInteractionStrategy::StrokeStrategy::Private
{
Private(KoPathTool *tool, StrokeStrategy *q)
: q(q)
, tool(tool)
{
shapeManager = tool->canvas()->shapeManager();
KoPathToolSelection *selection = dynamic_cast<KoPathToolSelection *>(tool->selection());
oldSelectedPoints = PointSelectionCommand::mapPointData(q->affectedNode(), q->originalState(), selection->selectedPointsData());
QList<KoShape *> shapes(KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::findMappedShapes(q->affectedNode(), q->originalState(), implicitCastList<KoShape *>(selection->selectedShapes())));
Q_FOREACH (KoShape *shape, shapes) {
oldSelectedShapes << dynamic_cast<KoPathShape *>(shape);
}
}
StrokeStrategy *q;
KoPathTool *tool;
KoShapeManager *shapeManager;
QList<KoPathPointData> oldSelectedPoints;
QList<KoPathShape *> oldSelectedShapes;
class PointSelectionCommand : public KUndo2Command
{
public:
PointSelectionCommand(KoToolSelection *selection, QList<KoPathPointData> oldSelectedPoints, QList<KoPathShape *> oldSelectedShapes, KUndo2Command *parent)
: KUndo2Command(parent)
, m_selection(dynamic_cast<KoPathToolSelection *>(selection))
, m_parent(dynamic_cast<KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand *>(parent))
, m_oldSelectedPoints(oldSelectedPoints)
, m_oldSelectedShapes(oldSelectedShapes)
{
KIS_ASSERT_RECOVER_NOOP(m_selection);
KIS_ASSERT_RECOVER_NOOP(m_parent);
m_newSelectedPoints = mapPointData(m_parent->affectedNode(), m_parent->editedState(), m_selection->selectedPointsData());
Q_FOREACH (KoShape *shape, KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::findMappedShapes(m_parent->affectedNode(), m_parent->editedState(), implicitCastList<KoShape *>(m_selection->selectedShapes()))) {
m_newSelectedShapes << dynamic_cast<KoPathShape *>(shape);
}
}
~PointSelectionCommand() = default;
static QList<KoPathPointData> mapPointData(KisNodeSP oldLayer, KisNodeSP newLayer, QList<KoPathPointData> oldPointData)
{
QList<KoPathShape *> oldShapes;
Q_FOREACH (const KoPathPointData &data, oldPointData) {
if (! oldShapes.contains(data.pathShape)) {
oldShapes << data.pathShape;
}
}
QList<KoPathShape *> newShapes;
Q_FOREACH (KoShape *shape, KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::findMappedShapes(oldLayer, newLayer, implicitCastList<KoShape *>(oldShapes))) {
newShapes << dynamic_cast<KoPathShape *>(shape);
}
QList<KoPathPointData> result;
Q_FOREACH (const KoPathPointData &data, oldPointData) {
int index = oldShapes.indexOf(data.pathShape);
result << KoPathPointData(newShapes[index], data.pointIndex);
}
return result;
}
void undo() override
{
m_selection->clear();
QList<KoPathShape *> shapesToSelect;
Q_FOREACH (KoShape *shape, KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::findMappedShapes(m_parent->originalState(), m_parent->affectedNode(), implicitCastList<KoShape *>(m_oldSelectedShapes))) {
shapesToSelect << dynamic_cast<KoPathShape *>(shape);
}
m_selection->setSelectedShapes(shapesToSelect);
Q_FOREACH (KoPathPointData data, mapPointData(m_parent->originalState(), m_parent->affectedNode(), m_oldSelectedPoints)) {
m_selection->add(data.pathShape->pointByIndex(data.pointIndex), /* clear = */ false);
}
}
void redo() override
{
m_selection->clear();
QList<KoPathShape *> shapesToSelect;
Q_FOREACH (KoShape *shape, KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand::findMappedShapes(m_parent->editedState(), m_parent->affectedNode(), implicitCastList<KoShape *>(m_newSelectedShapes))) {
shapesToSelect << dynamic_cast<KoPathShape *>(shape);
}
m_selection->setSelectedShapes(shapesToSelect);
Q_FOREACH (KoPathPointData data, mapPointData(m_parent->editedState(), m_parent->affectedNode(), m_newSelectedPoints)) {
m_selection->add(data.pathShape->pointByIndex(data.pointIndex), /* clear = */ false);
}
}
private:
KoPathToolSelection *m_selection;
KisNodeReplaceBasedStrokeStrategy::NodeReplaceCommand *m_parent;
QList<KoPathPointData> m_oldSelectedPoints;
QList<KoPathPointData> m_newSelectedPoints;
QList<KoPathShape *> m_oldSelectedShapes;
QList<KoPathShape *> m_newSelectedShapes;
};
};
KoPathToolInteractionStrategy::StrokeStrategy::StrokeStrategy(QString id, KisCanvas2 *canvas, const KUndo2MagicString &name, KoPathTool *tool)
: KisStrokeBasedInteractionStrategy::StrokeStrategy(id, canvas, name)
, m_d(new Private(tool, this))
{
}
KoPathToolInteractionStrategy::StrokeStrategy::~StrokeStrategy() = default;
KUndo2Command *KoPathToolInteractionStrategy::StrokeStrategy::createCommand()
{
KUndo2Command *cmd = KisStrokeBasedInteractionStrategy::StrokeStrategy::createCommand();
new Private::PointSelectionCommand(m_d->tool->selection(), m_d->oldSelectedPoints, m_d->oldSelectedShapes, cmd);
return cmd;
}
struct KoPathToolInteractionStrategy::Private
{
Private(KoPathTool *tool) : tool(tool) {}
KoPathTool *tool;
};
KoPathToolInteractionStrategy::KoPathToolInteractionStrategy(KoToolBase *tool)
: KisStrokeBasedInteractionStrategy(tool)
, m_d(new Private(dynamic_cast<KoPathTool *>(tool)))
{
}
KoPathToolInteractionStrategy::~KoPathToolInteractionStrategy() = default;
/* This file is part of the KDE project
* Copyright (C) 2019 Tusooa Zhu <tusooa@vista.aero>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KO_PATH_TOOL_INTERACTION_STRATEGY_H_
#define KO_PATH_TOOL_INTERACTION_STRATEGY_H_
#include <KisStrokeBasedInteractionStrategy.h>
class KoPathTool;
class KoPathToolInteractionStrategy : public KisStrokeBasedInteractionStrategy
{
public:
class StrokeStrategy : public KisStrokeBasedInteractionStrategy::StrokeStrategy
{
public:
StrokeStrategy(QString id, KisCanvas2 *canvas, const KUndo2MagicString &name, KoPathTool *tool);
~StrokeStrategy() override;
KUndo2Command *createCommand() override;
private:
struct Private;
QScopedPointer<Private> m_d;
};
KoPathToolInteractionStrategy(KoToolBase *tool);
~KoPathToolInteractionStrategy() override;
private:
struct Private;
QScopedPointer<Private> m_d;
};
#endif
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