DIWNE::InteractionState
A persistent state storage holding information about multi-frame interactions. More...
#include "DIWNE/Core/Elements/DiwneObject.h"
Public Functions
Name | |
---|---|
bool | anyActionActive() |
void | endAction(bool immediately =false)<br>Clears the current action, either right away or at the end of the frame. |
template <typename T > <br>T * | getAction()<br>Returns the current action casted to a specific type. |
template <typename T > <br>T * | getActiveAction(const std::string & name ="", const DiwneObject * source =nullptr)<br>Can be used to check if an action is active and return it if so. |
bool | isActionActive(const std::string & name) |
bool | isActionActive(const std::string & name, const DiwneObject * source)<br>Checks whether an action is active and its source is the passed source diwne label. |
bool | isDragSource(const DiwneObject * object) const<br>Whether passed object is a drag source of an active drag operation. |
void | nextFrame()<br>Some operations in the context are queued to be performed at the end of the frame / beginning of the next one. |
template <typename T ,typename... Args> <br>T * | startAction(Args &&... args) |
Actions::DiwneAction * | startAction(std::unique_ptr< Actions::DiwneAction > action) |
Public Attributes
Name | |
---|---|
std::unique_ptr< Actions::DiwneAction > | action <br>The current active action. |
bool | dragEnd <br>Indicates that an object has stopped being dragged this frame. |
bool | dragEndedLastFrame <br>Indicates that the dragEnd flag has been true the PREVIOUS frame. |
bool | dragging <br>Indicates that an object is being dragged this frame. |
std::weak_ptr< DiwneObject > | dragSource <br>Weak pointer to the object that initiated the drag. |
ID | dragSourceID <br>ID of the last drag source, quick way to check if an object is the drag source. |
bool | dragStart <br>Indicates that an object has started being dragged this frame. |
std::string | hoverTarget <br>Used to specify which object can be handed hover when a hovered child object isn't a hover root. |
Detailed Description
class DIWNE::InteractionState;
class DIWNE::InteractionState;
A persistent state storage holding information about multi-frame interactions.
Each NodeEditor holds an instance of this state and sets a reference to it in the non-persistent DrawInfo context. By persistence we mean persistence across multiple frames.
Public Functions Documentation
function anyActionActive
bool anyActionActive()
bool anyActionActive()
function endAction
void endAction(
bool immediately =false
)
void endAction(
bool immediately =false
)
Clears the current action, either right away or at the end of the frame.
function getAction
template <typename T >
inline T * getAction()
template <typename T >
inline T * getAction()
Returns the current action casted to a specific type.
This method ASSUMES that we already know the action type ahead by calling isActionActive()!
function getActiveAction
template <typename T >
inline T * getActiveAction(
const std::string & name ="",
const DiwneObject * source =nullptr
)
template <typename T >
inline T * getActiveAction(
const std::string & name ="",
const DiwneObject * source =nullptr
)
Can be used to check if an action is active and return it if so.
Return: Returns the specified action IF if it currently active. Otherwise null.
function isActionActive
bool isActionActive(
const std::string & name
)
bool isActionActive(
const std::string & name
)
function isActionActive
bool isActionActive(
const std::string & name,
const DiwneObject * source
)
bool isActionActive(
const std::string & name,
const DiwneObject * source
)
Checks whether an action is active and its source is the passed source diwne label.
function isDragSource
inline bool isDragSource(
const DiwneObject * object
) const
inline bool isDragSource(
const DiwneObject * object
) const
Whether passed object is a drag source of an active drag operation.
See: dragging
Unlike DiwneObject::isDragging() or m_isDragged flag, this remains true for one frame after the end of drag.
function nextFrame
void nextFrame()
void nextFrame()
Some operations in the context are queued to be performed at the end of the frame / beginning of the next one.
This method performs those actions as well as some general checks ensuring the state will be valid in the next frame.
function startAction
template <typename T ,
typename... Args>
inline T * startAction(
Args &&... args
)
template <typename T ,
typename... Args>
inline T * startAction(
Args &&... args
)
function startAction
Actions::DiwneAction * startAction(
std::unique_ptr< Actions::DiwneAction > action
)
Actions::DiwneAction * startAction(
std::unique_ptr< Actions::DiwneAction > action
)
Public Attributes Documentation
variable action
std::unique_ptr< Actions::DiwneAction > action;
std::unique_ptr< Actions::DiwneAction > action;
The current active action.
Only one action can be started at a time. When action is ended, it remains "active" until the end of the NEXT frame to allow all objects to react to it.
variable dragEnd
bool dragEnd {false};
bool dragEnd {false};
Indicates that an object has stopped being dragged this frame.
See: dragging
This flag flips to true mid-frame during the drawing of the object that stopped being dragged. It is true for only a single frame (a portion of it after drawing of the previously dragged object). The dragging flag is always true when this one is true.
variable dragEndedLastFrame
bool dragEndedLastFrame {false};
bool dragEndedLastFrame {false};
Indicates that the dragEnd flag has been true the PREVIOUS frame.
See: dragging
When true, dragging, dragStart and dragEnd are all false. Another object cannot start being dragged when this flag is true. Is is true for the entirety of a single frame following the frame in which dragging ended.
variable dragging
bool dragging {false};
bool dragging {false};
Indicates that an object is being dragged this frame.
This flag flips to true mid-frame during the drawing of the dragged object. The flag flips to false at the end of the frame in which the dragging stopped. It is true for many frames, including the frame dragging has stopped.
Below is a table visualizing state of all the drag flags and drag source during dragging of an object spanning 3 frames. Dragging of object '3' begins on frame 0 and ends on frame 2. No object can be dragged on frame 3 to allow objects '1' and '2' to react to dragging in special cases.
* Frame: ... -1 | *0 | 1 | *2 | 3 | 4 ...
* Object ID drawn: 3 4 5 | 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2
* dragging value: - - - | - - T T T T | T T T T T T | T T T T T T | - - - - - - | - -
* dragStart value: - - - | - - T T T T | - - - - - - | - - - - - - | - - - - - - | - -
* dragEnd value: - - - | - - - - - - | - - - - - - | - - T T T T | - - - - - - | - -
* dragEndLF value: - - - | - - - - - - | - - - - - - | - - - - - - | T T T T T T | - -
* dragSource ptr: - - - | - - O O O O | O O O O O O | O O O O O O | O O O O O O | - -
* m_isDragged: - - - | - - T T T T | T T T T T T | T T T - - - | - - - - - - | - -
* isDragging(): - - - | - - T T T T | T T T T T T | T T T T T T | - - - - - - | - -
* isDragSource(): - - - | - - T T T T | T T T T T T | T T T T T T | T T T T T T | - -
* | ^ | | ^ | | - -
* dragging started ended
* Legend: 'T' = true, '-' = false or null, 'O' = valid pointer
* dragEndLF = dragEndedLastFrame
* ```
### variable dragSource
```cpp
std::weak_ptr< DiwneObject > dragSource;
* Frame: ... -1 | *0 | 1 | *2 | 3 | 4 ...
* Object ID drawn: 3 4 5 | 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2
* dragging value: - - - | - - T T T T | T T T T T T | T T T T T T | - - - - - - | - -
* dragStart value: - - - | - - T T T T | - - - - - - | - - - - - - | - - - - - - | - -
* dragEnd value: - - - | - - - - - - | - - - - - - | - - T T T T | - - - - - - | - -
* dragEndLF value: - - - | - - - - - - | - - - - - - | - - - - - - | T T T T T T | - -
* dragSource ptr: - - - | - - O O O O | O O O O O O | O O O O O O | O O O O O O | - -
* m_isDragged: - - - | - - T T T T | T T T T T T | T T T - - - | - - - - - - | - -
* isDragging(): - - - | - - T T T T | T T T T T T | T T T T T T | - - - - - - | - -
* isDragSource(): - - - | - - T T T T | T T T T T T | T T T T T T | T T T T T T | - -
* | ^ | | ^ | | - -
* dragging started ended
* Legend: 'T' = true, '-' = false or null, 'O' = valid pointer
* dragEndLF = dragEndedLastFrame
* ```
### variable dragSource
```cpp
std::weak_ptr< DiwneObject > dragSource;
Weak pointer to the object that initiated the drag.
See: dragging
variable dragSourceID
ID dragSourceID;
ID dragSourceID;
ID of the last drag source, quick way to check if an object is the drag source.
variable dragStart
bool dragStart {false};
bool dragStart {false};
Indicates that an object has started being dragged this frame.
See: dragging
This flag flips to true mid-frame during the drawing of the newly dragged object. The flag flips to false at the end of the frame in which the dragging started. It is true for only a single frame (a portion of it after drawing of the dragged object). The dragging flag is always true when this one is true.
variable hoverTarget
std::string hoverTarget;
std::string hoverTarget;
Used to specify which object can be handed hover when a hovered child object isn't a hover root.
Is usually set to the object's parent object.
Updated on 2025-05-31 at 12:55:31 +0000