Krita Source Code Documentation
Loading...
Searching...
No Matches
ShapeGradientEditStrategy Class Reference

#include <ShapeGradientEditStrategy.h>

+ Inheritance diagram for ShapeGradientEditStrategy:

Classes

struct  Private
 

Public Member Functions

KUndo2CommandcreateCommand () override
 
void finishInteraction (Qt::KeyboardModifiers modifiers) override
 
void handleMouseMove (const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
 ShapeGradientEditStrategy (KoToolBase *tool, KoFlake::FillVariant fillVariant, KoShape *shape, KoShapeGradientHandles::Handle::Type startHandleType, const QPointF &clicked)
 
 ~ShapeGradientEditStrategy () override
 
- Public Member Functions inherited from KoInteractionStrategy
virtual void cancelInteraction ()
 
 KoInteractionStrategy (KoToolBase *parent)
 constructor
 
KoToolBasetool () const
 
virtual ~KoInteractionStrategy ()
 Destructor.
 

Private Attributes

QScopedPointer< Privatem_d
 

Additional Inherited Members

- Protected Member Functions inherited from KoInteractionStrategy
uint decorationThickness () const
 
uint grabSensitivity () const
 Convenience function to get the global grab sensitivity.
 
uint handleRadius () const
 Convenience function to get the global handle radius.
 
 KoInteractionStrategy (KoInteractionStrategyPrivate &)
 constructor
 
- Protected Attributes inherited from KoInteractionStrategy
KoInteractionStrategyPrivated_ptr
 

Detailed Description

Definition at line 14 of file ShapeGradientEditStrategy.h.

Constructor & Destructor Documentation

◆ ShapeGradientEditStrategy()

ShapeGradientEditStrategy::ShapeGradientEditStrategy ( KoToolBase * tool,
KoFlake::FillVariant fillVariant,
KoShape * shape,
KoShapeGradientHandles::Handle::Type startHandleType,
const QPointF & clicked )

Definition at line 42 of file ShapeGradientEditStrategy.cpp.

48 , m_d(new Private(clicked, shape, fillVariant))
49{
51
52 m_d->handleType = startHandleType;
53
54 KoShapeGradientHandles::Handle handle = m_d->gradientHandles.getHandle(m_d->handleType);
55 m_d->initialOffset = handle.pos - clicked;
56
58 Q_FOREACH (const KoShapeGradientHandles::Handle &h, m_d->gradientHandles.handles()) {
59 strategy->addPoint(h.pos);
60 }
62}
void addPoint(const QPointF &pt)
KoSnapGuide * snapGuide
KoInteractionStrategy(KoToolBase *parent)
constructor
bool addCustomSnapStrategy(KoSnapStrategy *customStrategy)
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
QScopedPointer< Private > m_d
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KoSnapGuide::addCustomSnapStrategy(), KisSnapPointStrategy::addPoint(), KoToolBase::canvas(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, KoShapeGradientHandles::Handle::pos, KoCanvasBase::snapGuide, and KoInteractionStrategy::tool().

◆ ~ShapeGradientEditStrategy()

ShapeGradientEditStrategy::~ShapeGradientEditStrategy ( )
override

Definition at line 64 of file ShapeGradientEditStrategy.cpp.

65{
66}

Member Function Documentation

◆ createCommand()

KUndo2Command * ShapeGradientEditStrategy::createCommand ( )
overridevirtual

For interactions that are undo-able this method should be implemented to return such a command. Implementations should return 0 otherwise.

Returns
a command, or 0.

Implements KoInteractionStrategy.

Definition at line 79 of file ShapeGradientEditStrategy.cpp.

80{
81 return m_d->intermediateCommand ?
82 new KisCommandUtils::SkipFirstRedoWrapper(m_d->intermediateCommand.take()) :
83 nullptr;
84}

References m_d.

◆ finishInteraction()

void ShapeGradientEditStrategy::finishInteraction ( Qt::KeyboardModifiers modifiers)
overridevirtual

Override to make final changes to the data on the end of an interaction.

Implements KoInteractionStrategy.

Definition at line 86 of file ShapeGradientEditStrategy.cpp.

87{
88 Q_UNUSED(modifiers);
89 tool()->canvas()->snapGuide()->reset();
90}
void reset()
Resets the snap guide.

References KoToolBase::canvas(), KoSnapGuide::reset(), KoCanvasBase::snapGuide, and KoInteractionStrategy::tool().

◆ handleMouseMove()

void ShapeGradientEditStrategy::handleMouseMove ( const QPointF & mouseLocation,
Qt::KeyboardModifiers modifiers )
overridevirtual

Extending classes should implement this method to update the selectedShapes based on the new mouse position.

Parameters
mouseLocationthe new location in pt
modifiersOR-ed set of keys pressed.

Implements KoInteractionStrategy.

Definition at line 68 of file ShapeGradientEditStrategy.cpp.

69{
70 const QPointF snappedPosition = tool()->canvas()->snapGuide()->snap(mouseLocation, m_d->initialOffset, modifiers);
71 const QPointF diff = snappedPosition - m_d->previous;
72 m_d->previous = snappedPosition;
73
75 m_d->gradientHandles.moveGradientHandle(m_d->handleType, diff),
76 m_d->intermediateCommand);
77}
QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers)
snaps the mouse position, returns if mouse was snapped
void redoAndMergeIntoAccumulatingCommand(KUndo2Command *cmd, QScopedPointer< KUndo2Command > &accumulatingCommand)

References KoToolBase::canvas(), m_d, KisCommandUtils::redoAndMergeIntoAccumulatingCommand(), KoSnapGuide::snap(), KoCanvasBase::snapGuide, and KoInteractionStrategy::tool().

◆ paint()

void ShapeGradientEditStrategy::paint ( QPainter & painter,
const KoViewConverter & converter )
overridevirtual

Reimplement this if the action needs to draw a "blob" on the canvas; that is, a transient decoration like a rubber band.

Reimplemented from KoInteractionStrategy.

Definition at line 92 of file ShapeGradientEditStrategy.cpp.

93{
94 Q_UNUSED(painter);
95 Q_UNUSED(converter);
96}

Member Data Documentation

◆ m_d

QScopedPointer<Private> ShapeGradientEditStrategy::m_d
private

Definition at line 31 of file ShapeGradientEditStrategy.h.


The documentation for this class was generated from the following files: