Krita Source Code Documentation
Loading...
Searching...
No Matches
KoInteractionStrategy Class Referenceabstract

#include <KoInteractionStrategy.h>

+ Inheritance diagram for KoInteractionStrategy:

Public Member Functions

virtual void cancelInteraction ()
 
virtual KUndo2CommandcreateCommand ()=0
 
virtual void finishInteraction (Qt::KeyboardModifiers modifiers)=0
 
virtual void handleMouseMove (const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers)=0
 
 KoInteractionStrategy (KoToolBase *parent)
 constructor
 
virtual void paint (QPainter &painter, const KoViewConverter &converter)
 
KoToolBasetool () const
 
virtual ~KoInteractionStrategy ()
 Destructor.
 

Protected Member Functions

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

KoInteractionStrategyPrivated_ptr
 

Detailed Description

Abstract interface to define what actions a KoInteractionTool can do based on the Strategy design pattern. e.g, move, select, transform.

KoInteractionStrategy is a Strategy baseclass for the KoInteractionTool and it defines the behavior in case the user clicks or drags the input device. The strategy is created in the createPolicy() function which defines the resulting behavior and initiates a move or a resize, for example. The mouseMove events are forwarded to the handleMouseMove() method and the interaction is either finished with finishInteraction() or cancelInteraction() (never both).

Definition at line 37 of file KoInteractionStrategy.h.

Constructor & Destructor Documentation

◆ KoInteractionStrategy() [1/2]

KoInteractionStrategy::KoInteractionStrategy ( KoToolBase * parent)
explicit

constructor

Definition at line 17 of file KoInteractionStrategy.cpp.

◆ ~KoInteractionStrategy()

KoInteractionStrategy::~KoInteractionStrategy ( )
virtual

Destructor.

Definition at line 37 of file KoInteractionStrategy.cpp.

38{
39 delete d_ptr;
40}

References d_ptr.

◆ KoInteractionStrategy() [2/2]

KoInteractionStrategy::KoInteractionStrategy ( KoInteractionStrategyPrivate & dd)
protected

constructor

Definition at line 32 of file KoInteractionStrategy.cpp.

33 : d_ptr(&dd)
34{
35}

Member Function Documentation

◆ cancelInteraction()

void KoInteractionStrategy::cancelInteraction ( )
virtual

This method will undo frames based interactions by calling createCommand() and unexecuting that.

Reimplemented in KoPathPointRubberSelectStrategy, KoZoomStrategy, SelectionInteractionStrategy, SvgCreateTextStrategy, SvgInlineSizeChangeStrategy, SvgMoveTextStrategy, and SvgSelectTextStrategy.

Definition at line 22 of file KoInteractionStrategy.cpp.

23{
25 if (cmd) {
26 cmd->redo(); //some applications rely an redo being called here
27 cmd->undo();
28 delete cmd;
29 }
30}
virtual void undo()
virtual void redo()
virtual KUndo2Command * createCommand()=0

References createCommand(), KUndo2Command::redo(), and KUndo2Command::undo().

◆ createCommand()

virtual KUndo2Command * KoInteractionStrategy::createCommand ( )
pure virtual

◆ decorationThickness()

uint KoInteractionStrategy::decorationThickness ( ) const
protected

Definition at line 57 of file KoInteractionStrategy.cpp.

58{
59 return tool()->canvas()->resourceManager()->decorationThickness();
60}
QPointer< KoCanvasResourceProvider > resourceManager
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.

References KoToolBase::canvas(), KoCanvasBase::resourceManager, and tool().

◆ finishInteraction()

◆ grabSensitivity()

uint KoInteractionStrategy::grabSensitivity ( ) const
protected

Convenience function to get the global grab sensitivity.

Definition at line 62 of file KoInteractionStrategy.cpp.

63{
64 return tool()->canvas()->shapeController()->resourceManager()->grabSensitivity();
65}
QPointer< KoShapeController > shapeController

References KoToolBase::canvas(), KoCanvasBase::shapeController, and tool().

◆ handleMouseMove()

virtual void KoInteractionStrategy::handleMouseMove ( const QPointF & mouseLocation,
Qt::KeyboardModifiers modifiers )
pure virtual

◆ handleRadius()

uint KoInteractionStrategy::handleRadius ( ) const
protected

Convenience function to get the global handle radius.

Definition at line 52 of file KoInteractionStrategy.cpp.

53{
54 return tool()->canvas()->resourceManager()->handleRadius();
55}

References KoToolBase::canvas(), KoCanvasBase::resourceManager, and tool().

◆ paint()

void KoInteractionStrategy::paint ( QPainter & painter,
const KoViewConverter & converter )
virtual

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

Reimplemented in KoShapeRubberSelectStrategy, NopInteractionStrategy, SelectionInteractionStrategy, ShapeGradientEditStrategy, ShapeMoveStrategy, ShapeResizeStrategy, ShapeRotateStrategy, ShapeShearStrategy, and SvgCreateTextStrategy.

Definition at line 42 of file KoInteractionStrategy.cpp.

43{
44}

◆ tool()

KoToolBase * KoInteractionStrategy::tool ( ) const

Definition at line 46 of file KoInteractionStrategy.cpp.

Member Data Documentation

◆ d_ptr

KoInteractionStrategyPrivate* KoInteractionStrategy::d_ptr
protected

Definition at line 80 of file KoInteractionStrategy.h.


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