Skip to content

DIWNE::Actions::DiwneAction ​

Base class for DIWNEActions. More...

#include "DIWNE/Core/diwne_actions.h"

Inherited by DIWNE::Actions::ConnectPinAction, DIWNE::Actions::EditorAction, DIWNE::Actions::SelectionRectAction

Public Functions ​

Name
DiwneAction(const std::string & name, const std::shared_ptr< DiwneObject > & source)
virtual~DiwneAction() =default
voidend()<br>Marks the action to end at the end of the next frame.
boolhasSameSource(const DiwneAction & action) const<br>Checks whether the source of this and another action are the same.
boolisSource(const DiwneObject * object) const<br>Checks whether passed object is the source of this action (eg. the object that started it.
virtual voidonEnd()<br>Called at the end of the frame after the frame in which the action has ended. Called after onFrameEnd().
virtual voidonFrameEnd()<br>Called at the end of each frame the action is active for, called before onEnd() on the last frame.

Public Attributes ​

Name
std::stringname
std::weak_ptr< DiwneObject >source

Friends ​

Name
classDIWNE::InteractionState

Detailed Description ​

cpp
struct DIWNE::Actions::DiwneAction;
struct DIWNE::Actions::DiwneAction;

Base class for DIWNEActions.

Actions are operations that span and carry state across multiple frames.

Public Functions Documentation ​

function DiwneAction ​

cpp
inline DiwneAction(
    const std::string & name,
    const std::shared_ptr< DiwneObject > & source
)
inline DiwneAction(
    const std::string & name,
    const std::shared_ptr< DiwneObject > & source
)

Parameters:

  • name String identifier of the action
  • source DiwneObject considered to be it's source, eg. the object that started it and is most likely also responsible for ending it.

function ~DiwneAction ​

cpp
virtual ~DiwneAction() =default
virtual ~DiwneAction() =default

function end ​

cpp
inline void end()
inline void end()

Marks the action to end at the end of the next frame.

Warning: Ending the action is usually the responsibility of the object that started it. If this object fails to end it, it will simply be active forever. There are mechanisms to prevent this, namely, an action will be ended if the source object gets destroyed or forcibly deallocated (action source is a weak pointer), and any action can be ended by the NodeEditor when ESC is pressed.

An issue can arise when action is started and then the source object is hidden (not rendered anymore due to allowDrawing() returning false). In this case, the drawing lifecycle methods and processing of interactions is NOT called, only the initialize() and finalize() methods are called. So it must be ensured that either the source object will not get hidden until the end of the action or the check for ending the action happens in one of those two methods.

An exception is ending an action in DiwneObject::onDrag(), this method will always get called when the dragging ends even when it is due to the object becomming hidden, so it is safe to start and end actions there.

At the same time onFrameEnd() and onEnd() callbacks will be called in that order.

function hasSameSource ​

cpp
inline bool hasSameSource(
    const DiwneAction & action
) const
inline bool hasSameSource(
    const DiwneAction & action
) const

Checks whether the source of this and another action are the same.

function isSource ​

cpp
inline bool isSource(
    const DiwneObject * object
) const
inline bool isSource(
    const DiwneObject * object
) const

Checks whether passed object is the source of this action (eg. the object that started it.

function onEnd ​

cpp
inline virtual void onEnd()
inline virtual void onEnd()

Called at the end of the frame after the frame in which the action has ended. Called after onFrameEnd().

Reimplemented by: DIWNE::Actions::ConnectPinAction::onEnd

function onFrameEnd ​

cpp
inline virtual void onFrameEnd()
inline virtual void onFrameEnd()

Called at the end of each frame the action is active for, called before onEnd() on the last frame.

Reimplemented by: DIWNE::Actions::DragNodeAction::onFrameEnd

Public Attributes Documentation ​

variable name ​

cpp
std::string name;
std::string name;

variable source ​

cpp
std::weak_ptr< DiwneObject > source;
std::weak_ptr< DiwneObject > source;

Friends ​

friend DIWNE::InteractionState ​

cpp
friend class DIWNE::InteractionState(
    DIWNE::InteractionState 
);
friend class DIWNE::InteractionState(
    DIWNE::InteractionState 
);

Updated on 2025-05-31 at 12:55:31 +0000