Krita Source Code Documentation
Loading...
Searching...
No Matches
KoParameterChangeStrategy.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2006 Thorsten Zachmann <zachmann@kde.org>
3 SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
9#include "KoParameterShape.h"
11
12#include <KoCanvasBase.h>
13#include "KoSnapGuide.h"
14
15
17 : KoInteractionStrategy(*(new KoParameterChangeStrategyPrivate(tool, parameterShape, handleId)))
18{
20 d->tool->canvas()->snapGuide()->setIgnoredShapes({parameterShape});
21}
22
28
32
33void KoParameterChangeStrategy::handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers)
34{
36
37 const QPointF snappedPosition = d->tool->canvas()->snapGuide()->snap(mouseLocation, modifiers);
38
39 d->parameterShape->moveHandle(d->handleId, snappedPosition, modifiers);
40 d->lastModifierUsed = modifiers;
41 d->releasePoint = snappedPosition;
42}
43
45{
47
48 d->tool->canvas()->snapGuide()->reset();
49
51 // check if handle position changed
52 if (d->startPoint != QPointF(0, 0) && d->startPoint != d->releasePoint) {
53 cmd = new KoParameterHandleMoveCommand(d->parameterShape, d->handleId, d->startPoint, d->releasePoint, d->lastModifierUsed);
54 }
55 return cmd;
56}
57
58void KoParameterChangeStrategy::finishInteraction(Qt::KeyboardModifiers /*modifiers*/)
59{
60}
61
62
Strategy for changing control points of parametric shapes.
KUndo2Command * createCommand() override
void finishInteraction(Qt::KeyboardModifiers modifiers) override
KoParameterChangeStrategy(KoToolBase *tool, KoParameterShape *parameterShape, int handleId)
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
The undo / redo command for changing a parameter.