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 |
| void | end()<br>Marks the action to end at the end of the next frame. |
| bool | hasSameSource(const DiwneAction & action) const<br>Checks whether the source of this and another action are the same. |
| bool | isSource(const DiwneObject * object) const<br>Checks whether passed object is the source of this action (eg. the object that started it. |
| virtual void | onEnd()<br>Called at the end of the frame after the frame in which the action has ended. Called after onFrameEnd(). |
| virtual void | onFrameEnd()<br>Called at the end of each frame the action is active for, called before onEnd() on the last frame. |
Public Attributes
| Name | |
|---|---|
| std::string | name |
| std::weak_ptr< DiwneObject > | source |
Friends
| Name | |
|---|---|
| class | DIWNE::InteractionState |
Detailed Description
struct DIWNE::Actions::DiwneAction;struct DIWNE::Actions::DiwneAction;Actions are operations that span and carry state across multiple frames.
Public Functions Documentation
function DiwneAction
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
virtual ~DiwneAction() =defaultvirtual ~DiwneAction() =defaultfunction end
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
inline bool hasSameSource(
const DiwneAction & action
) constinline bool hasSameSource(
const DiwneAction & action
) constChecks whether the source of this and another action are the same.
function isSource
inline bool isSource(
const DiwneObject * object
) constinline bool isSource(
const DiwneObject * object
) constChecks whether passed object is the source of this action (eg. the object that started it.
function onEnd
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
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
std::string name;std::string name;variable source
std::weak_ptr< DiwneObject > source;std::weak_ptr< DiwneObject > source;Friends
friend DIWNE::InteractionState
friend class DIWNE::InteractionState(
DIWNE::InteractionState
);friend class DIWNE::InteractionState(
DIWNE::InteractionState
);Updated on 2026-05-21 at 15:39:36 +0000