DIWNE::NodeEditor
The DIWNE node editor object. More...
#include "DIWNE/Core/NodeEditor.h"
Inherits from DIWNE::DiwneObject, DIWNE::NodeContainer, std::enable_shared_from_this< DiwneObject >, DIWNE::INodeContainer
Inherited by Workspace::WorkspaceDiwne
Public Functions
Name | |
---|---|
NodeEditor(const char * label, SettingsDiwne * settingsDiwne)<br>Create a node editor instance. | |
~NodeEditor() override | |
void | addLink(std::shared_ptr< Link > link) |
void | addNode(const std::shared_ptr< Node > & node) |
void | addNode(const std::shared_ptr< Node > & node, const ImVec2 position, bool shiftToLeftByNodeWidth =false) |
virtual void | afterDraw(DrawInfo & context) override<br>Called last during drawing. |
virtual bool | allowZoom() |
virtual void | begin(DrawInfo & context) override<br>First method to be called during object drawing. |
void | bringLastActiveNodeToFront() |
void | bringMarkedNodesToFront() |
Canvas & | canvas() const<br>Get a reference to the canvas component of the node editor. |
virtual void | clear()<br>Clear all nodes from the node editor. |
virtual void | content(DrawInfo & context) override<br>Called after begin() during drawing. |
template <class T ,typename... Args> <br>auto | createLink(Args &&... args)<br>Create a new link of type T and add it to the node editor. |
template <class T ,typename... Args> <br>auto | createNode(const ImVec2 position =ImVec2(0, 0), Args &&... args)<br>Creates a new node in the node editor of the specified type. |
template <class T > <br>auto | createNode(const ImVec2 position =ImVec2(0, 0), bool shiftToLeftByNodeWidth =false) |
void | deleteSelectedNodes() |
virtual void | deselectAllNodes() |
virtual void | draw(DrawMode drawMode =DrawMode_Interactive) override<br>Generic draw method meant to be used by external code. |
virtual void | end(DrawInfo & context) override<br>Called after content(). |
virtual RecursiveNodeRange | getAllNodesInnerIncluded() const |
float | getDpiScale() const |
template <typename T =Node> <br>std::shared_ptr< T > | getLastActiveNode() |
virtual NodeList & | getNodeList() override<br>Get a reference to the underlying owning vector of all nodes in the node editor. |
virtual NodeRange | getNodes() const override<br>Get a view of all nodes in the node editor which can be iterated over. |
bool | getNodesSelectionChanged() const |
const ImVec2 & | getPopupPosition() const<br>Get position of the last popup in screen coordinates. |
virtual FilteredNodeRange | getSelectedNodes() const |
virtual FilteredRecursiveNodeRange | getSelectedNodesInnerIncluded() const |
StyleOverride * | getStyleOverride() const =delete |
float | getZoom() const |
virtual void | initializeDiwne(DrawInfo & context) override |
NodeEditorInputAdapter & | input() const<br>Get a reference to the node editors input adapter. |
void | invertSelection() |
virtual bool | isJustPressedDiwne() override<br>Determine whether a key/s of interest was/were just pressed. |
virtual bool | isPressedDiwne() override<br>Determine whether a key/s of interest is/are pressed down over the object. |
virtual bool | isZoomingDiwne() |
virtual void | onDestroy(bool logEvent) override<br>Gets called the moment the object is marked for deletion by destroy(). |
virtual void | onDrag(DrawInfo & context, bool dragStart, bool dragEnd) override<br>This method gets called when the object is being dragged. |
virtual void | onReleased(bool justReleased, DrawInfo & context) override<br>Called when the object is not pressed. |
virtual void | onZoom() |
virtual void | processInteractions(DrawInfo & context) override<br>Method for reacting to user input after the object is fully drawn and its dimensions are known. |
virtual bool | processPan()<br>Called by Canvas::setZoom() when the zoom level changes. |
virtual bool | processZoom() |
void | purgeAllNodes()<br>Erases objects marked for deletion or removal from the editor. |
void | selectAllNodes(bool deselectIfAllAreSelected =false)<br>Selects all nodes. |
void | setDpiScale(float dpiScale)<br>Set the node editor's dpi scale. Updates dpi scale of its style as well. |
template <class T ,typename... Args> <br>void | setInputAdapter(Args &&... args) |
void | setLastActiveNode(std::shared_ptr< Node > node) |
void | setNodesSelectionChanged(bool value) |
void | setPopupPosition(ImVec2 position)<br>Set position of the last popup in screen coordinates, used for placement of new nodes. |
void | setStyle(std::unique_ptr< StyleBase > && ptr) |
void | setStyleOverride(StyleOverride * styleOverride) =delete |
void | setZoom(float val) |
void | shiftNodesToBegin(const NodeList & nodesToShift) |
void | shiftNodesToEnd(const NodeList & nodesToShift) |
virtual Style & | style() const override<br>Get a reference to the editors style settings, which specify various colors and sizes much like ImStyle. |
StyleBase & | styleBase() const |
virtual void | updateLayout(DrawInfo & context) override<br>Updates object's m_rect, m_displayRect and any other object size variables. |
Protected Functions
Name | |
---|---|
virtual bool | isDraggedDiwne() override<br>Is the object being dragged? (usually by mouse or some key combo) |
void | purgeObjects()<br>Erases objects marked for deletion or removal from the editor. |
Public Attributes
Name | |
---|---|
InteractionState | interactionState <br>State of multi-frame user operations. |
std::vector< std::shared_ptr< Link > > | m_links <br>List of links, nodes are stored in NodeContainer superclass. |
bool | m_takeSnap <br>Indicates that a state change has occurred, can be used for undo/redo systems. |
SettingsDiwne * | mp_settingsDiwne |
Protected Attributes
Name | |
---|---|
std::unique_ptr< Canvas > | m_canvas |
ImDrawListSplitter | m_channelSplitter <br>Channel splitter used to call nodes draw methods in reverse order. |
std::unique_ptr< NodeEditorInputAdapter > | m_input |
bool | m_lastActiveNodeChanged |
bool | m_nodesSelectionChanged |
ImVec2 | m_popupPosition <br>Position of the last popup in screen coordinates. |
std::unique_ptr< StyleBase > | m_style |
std::weak_ptr< Node > | mp_lastActiveNode <br>Last node that requested focus (had a logical update) |
Additional inherited members
Public Functions inherited from DIWNE::DiwneObject
Name | |
---|---|
DiwneObject(DIWNE::NodeEditor & diwne, std::string labelDiwne) | |
virtual | ~DiwneObject() |
virtual bool | allowDragStart() const<br>Determines whether a drag operation can start from this object. |
virtual bool | allowDrawing()<br>Decide whether the object should be drawn (when outside the window for example) |
virtual bool | allowHover() const<br>Determines whether the object can be hovered. |
virtual bool | allowInteraction() const<br>Decide whether the object should react to user input in general. |
virtual bool | allowPopup() const<br>Determines whether a popup can be raised over the object. |
virtual bool | allowPress(const DrawInfo & context) const<br>Determines whether the object can be pressed. |
virtual bool | allowSelectOnClick(const DrawInfo & context) const<br>Determines whether the object can be selected by clicking it (eg. |
template <typename T =DiwneObject> <br>T * | as()<br>Returns a raw pointer to itself casted to a type. |
virtual void | destroy(bool logEvent =true)<br>Marks the object for lazy destruction/deallocation and removal from any containers (like the node editor). |
virtual void | drawDiwne(DrawInfo & context, DrawMode drawMode =DrawMode_Interactive)<br>Internal draw method. |
DrawInfo | drawDiwneEx(DrawInfo & context, DrawMode drawMode =DrawMode_Interactive) |
virtual void | finalize(DrawInfo & context)<br>The final method to be called, gets called every frame and doesn't do any drawing. |
ImRect | getDisplayRect() const<br>Object's bounds aligned to current viewport pixel boundaries. |
ID | getId() const |
DiwneObject * | getParentObject() const |
ImVec2 | getPosition() const<br>Returns the top left corner of the object's rect. |
virtual ImRect | getRect() const<br>Rectangle bounds of the object in DIWNE coordinates (editor canvas coordinates). |
bool | getSelectable() |
virtual bool | getSelected() const<br>Whether the object is selected or not. |
virtual void | initialize(DrawInfo & context)<br>First method to be called every frame. |
bool | isAnyParentSelected() |
bool | isChildObject() const |
bool | isChildOfObject(DiwneObject * parent) |
bool | isDestroyed() const |
bool | isDragging(DrawInfo & context)<br>Is this object the source of an active dragging operation? |
bool | isFixed() const<br>Fixed objects are ones rendered at a position determined by some other object. |
bool | isRendered() const |
bool | isToBeBroughtToFront() |
virtual void | onHover(DrawInfo & context)<br>This method gets called when the object is hovered. |
virtual void | onPopup() |
virtual void | onPressed(bool justPressed, DrawInfo & context)<br>Called when the object is pressed, meaning a key is pressed over it. |
virtual void | onSelection(bool selected) |
void | openPopup()<br>Request to open the object's popup if possible. |
bool | operator!=(const DiwneObject & rhs) const |
bool | operator==(const DiwneObject & rhs) const |
virtual void | popupContent(DrawInfo & context)<br>Content of popup menu raised on this objec. |
void | setBringToFront(bool val)<br>Marks the object to be brought to front (be drawn first). |
void | setFixed(bool val) |
void | setForceDraw(bool val)<br>When true, makes the object automatically add the ForceDraw DrawMode flag. |
void | setParentObject(DiwneObject * parent) |
void | setPopupEnabled(bool val) |
void | setPosition(const ImVec2 & position)<br>Move the object's rect and any other associated positional data to the specified position. |
void | setRendered(bool val) |
void | setSelectable(bool selectable)<br>Whether the object can be selected. |
virtual bool | setSelected(bool selected)<br>Set the selection state of the object. |
void | setTooltip(const std::string & text) |
void | setTooltipEnabled(bool val) |
template <typename T =DiwneObject> <br>std::shared_ptr< T > | sharedPtr()<br>Returns a shared pointer to this object. |
void | showTooltip(const std::string & label, const ImColor && color, DrawInfo & context)<br>Immediately show a tooltip next to the mouse cursor with the specified text. |
void | showTooltip(const std::string & label, const std::string & desc, const ImColor && color, DrawInfo & context, float wrapWidth =35.f)<br>Immediately show a tooltip next to the mouse cursor with the specified text. |
void | stopDrag(DrawInfo & context)<br>End an active drag operation this object is a source of. |
virtual void | tooltipContent(DrawInfo & context)<br>Content of the object's tooltip. |
virtual void | translate(const ImVec2 & vec)<br>Move the object's rect and any other associated positional data. |
Protected Functions inherited from DIWNE::DiwneObject
Name | |
---|---|
virtual void | afterDrawDiwne(DrawInfo & context)<br>Updates layout, processes interactions and then calls the user afterDraw() method. |
virtual void | beginDiwne(DrawInfo & context) |
virtual void | endDiwne(DrawInfo & context) |
virtual void | finalizeDiwne(DrawInfo & context) |
virtual bool | isHoveredDiwne()<br>Is the object being hovered? The default implementation mostly gets this information from ImGui::IsItemHovered() but the behavior can be changed or restricted. |
virtual bool | popupShouldBeOpenedDiwne() const<br>Determine whether a popup should be opened, that is, by default, that right mouse button was pressed and isn't dragging. |
virtual void | processDragDiwne(DrawInfo & context) |
virtual void | processHoverDiwne(DrawInfo & context)<br>Processes whether the object is currently hovered. |
virtual void | processInteractionsDiwne(DrawInfo & context) |
virtual void | processPopupAndTooltipDiwne(DrawInfo & context)<br>Processes whether a popup should be opened over this object. |
virtual void | processPressAndReleaseDiwne(DrawInfo & context)<br>Processes whether the object is currently pressed (held) and further if it was just pressed or released. |
virtual bool | processSelectDiwne(DrawInfo & context)<br>Processes any interactions related to whether the object should be selected. |
virtual void | setInitialPositionDiwne()<br>Internal helper for setting the object's initial position. |
void | setSize(const ImVec2 & size) |
void | updateRectFromImGuiItem() |
Public Attributes inherited from DIWNE::DiwneObject
Name | |
---|---|
NodeEditor & | diwne <br>Reference to the NodeEditor instance (also named 'editor' in some classes) |
bool | m_deletable <br>Whether the object can be destroyed by the user. |
bool | m_destroy <br>Indicates the object is to be deleted (and deallocated) |
ImRect | m_displayRect <br>Rectangle bounds aligned with the last viewport. |
bool | m_draggable <br>Whether dragging of the object is allowed by default. |
DrawMode | m_drawMode <br>Read-only flag thats updated on each drawDiwne(). |
bool | m_drawnThisFrame <br>Read only flag indicating whether the object has been drawn this frame. |
bool | m_fixed <br>Whether the object can be moved by user operations. |
bool | m_forceHoverDiwne <br>Special flag that can be used to enforce hover state, used by pin drag assist. |
bool | m_hoverable <br>Whether hovering is enabled by default. |
bool | m_hovered <br>Is the object hovered (usually by the mouse or whatever isHoveredDiwne() tracks) |
bool | m_hoverRoot <br>Whether hovering this object should prevent other objects from hovering. |
ID | m_idDiwne <br>Unique numeric identifier of the object. |
bool | m_isDragged <br>Is the object dragged? Returns false immediately on drag end (unlike isDragging()). |
bool | m_isPressed <br>Is the object pressed down (held)? Requirement for dragging. |
bool | m_justHidden <br>Read only flag indicating that this object was drawn last frame, but not this one. |
bool | m_justPressed <br>Read only flag indicating the object was pressed this frame (eg. |
bool | m_justReleased <br>Read only flag indicating the object was released this frame (eg. |
std::string | m_labelDiwne <br>Unique string identifier, consists of <some string>:<m_idDiwne>. |
ImRect | m_rect <br>Rectangle bounds of the object in diwne coordinates. |
StyleOverride * | m_styleOverride <br>Style override to allow uniquely styled object types. |
Protected Attributes inherited from DIWNE::DiwneObject
Name | |
---|---|
unsigned long long | g_diwneIDCounter <br>Static unique ID generator, unique only for current application run. |
bool | m_bringToFront <br>Request the object's rendering order to be moved to the front above other objects. |
bool | m_forceDraw <br>Request the next draw of the object to have the ForceDraw DrawMode flag. |
bool | m_internalHover <br>Temporary storage for an internal ImGui::IsItemHovered() check Can be set in the end() method to determine if object is hovered if applicable. |
bool | m_openPopup <br>Request to open popup. |
bool | m_openTooltip <br>Request to open tooltip. |
DiwneObject * | m_parentObject <br>Sets the parent object of object, relevant in node container and hover hierarchy. |
bool | m_popupEnabled <br>Whether this object has popup enabled. |
std::string | m_popupLabelDiwne <br>ImGui popup identifier. |
bool | m_rendered <br>Whether the object should be drawn, this is a general flag that overrides behavior of the allowDrawing() method. |
bool | m_selectable <br>Should not be accessed directly. |
bool | m_selected <br>Should not be accessed directly. |
bool | m_tooltipEnabled <br>Whether this object has tooltip enabled. |
std::string | m_tooltipText |
Public Functions inherited from DIWNE::NodeContainer
Name | |
---|---|
NodeContainer(DiwneObject * owner)<br>Constructs the node container for a specific DiwneObject that it represents. | |
virtual void | addNodeAt(const std::shared_ptr< Node > & node, int index)<br>Adds a node at a specified index. |
void | purgeNodes()<br>Erases objects marked for deletion or removal from the container. |
bool | removeNode(const std::shared_ptr< Node > & node)<br>Removes a node from the container. |
virtual void | removeNodeAt(int index)<br>Removes a node at a specified index from the container. |
bool | replaceNode(const std::shared_ptr< Node > & oldNode, const std::shared_ptr< Node > & newNode)<br>Replaces an existing node with a new one. |
virtual void | replaceNodeAt(const std::shared_ptr< Node > & node, int index)<br>Replaces node at a specified index with a different one. |
Protected Functions inherited from DIWNE::NodeContainer
Name | |
---|---|
virtual void | onNodeAdd(Node * node, int index)<br>Called after a node is inserted into the container. |
virtual void | onNodeRemove(std::shared_ptr< Node > node, int index)<br>Called after a node is removed from the container. |
Protected Attributes inherited from DIWNE::NodeContainer
Name | |
---|---|
NodeList | m_nodes |
DiwneObject * | m_owner <br>Diwne object associated with this node container. |
Public Functions inherited from DIWNE::INodeContainer
Name | |
---|---|
virtual | ~INodeContainer() =default |
Detailed Description
class DIWNE::NodeEditor;
class DIWNE::NodeEditor;
The DIWNE node editor object.
Every DiwneObject has a reference to this object.
Public Functions Documentation
function NodeEditor
NodeEditor(
const char * label,
SettingsDiwne * settingsDiwne
)
NodeEditor(
const char * label,
SettingsDiwne * settingsDiwne
)
Create a node editor instance.
Parameters:
- settingsDiwne
Return:
Note: NodeEditor must MUST be instantiated as a shared pointer using std::make_shared! It cannot be defined as a local stack variable or static value variable or even manually using the new operator.
function ~NodeEditor
~NodeEditor() override
~NodeEditor() override
function addLink
void addLink(
std::shared_ptr< Link > link
)
void addLink(
std::shared_ptr< Link > link
)
function addNode
void addNode(
const std::shared_ptr< Node > & node
)
void addNode(
const std::shared_ptr< Node > & node
)
function addNode
void addNode(
const std::shared_ptr< Node > & node,
const ImVec2 position,
bool shiftToLeftByNodeWidth =false
)
void addNode(
const std::shared_ptr< Node > & node,
const ImVec2 position,
bool shiftToLeftByNodeWidth =false
)
function afterDraw
virtual void afterDraw(
DrawInfo & context
) override
virtual void afterDraw(
DrawInfo & context
) override
Called last during drawing.
Reimplements: DIWNE::DiwneObject::afterDraw
At this point the m_rect of the object should be calculated in the updateLayout() method and this method should be able to work with it. Because of that the drawing code within shouldn't affect the objects size anymore. Interactions are processed before this method and thus interaction related member variables can be used within.
function allowZoom
virtual bool allowZoom()
virtual bool allowZoom()
function begin
virtual void begin(
DrawInfo & context
) override
virtual void begin(
DrawInfo & context
) override
First method to be called during object drawing.
Reimplements: DIWNE::DiwneObject::begin
Reimplemented by: Workspace::WorkspaceDiwne::begin
Can be used to initialize drawing code.
function bringLastActiveNodeToFront
void bringLastActiveNodeToFront()
void bringLastActiveNodeToFront()
function bringMarkedNodesToFront
void bringMarkedNodesToFront()
void bringMarkedNodesToFront()
function canvas
inline Canvas & canvas() const
inline Canvas & canvas() const
Get a reference to the canvas component of the node editor.
Canvas contains information about the position of the viewport displaying the editor's infinite 2D plane. It also holds utility methods used for drawing content within the plane (diwne coordinates).
function clear
virtual void clear()
virtual void clear()
Clear all nodes from the node editor.
function content
virtual void content(
DrawInfo & context
) override
virtual void content(
DrawInfo & context
) override
Called after begin() during drawing.
Reimplements: DIWNE::DiwneObject::content
Reimplemented by: Workspace::WorkspaceDiwne::content
Draws object content.
Todosee #111, wrongly computed m_takeSnap value.
function createLink
template <class T ,
typename... Args>
inline auto createLink(
Args &&... args
)
template <class T ,
typename... Args>
inline auto createLink(
Args &&... args
)
Create a new link of type T and add it to the node editor.
Template Parameters:
- T
Return: An owning shared ptr to the new link. Note that the link is already owned by the node editor at this point in time.
function createNode
template <class T ,
typename... Args>
inline auto createNode(
const ImVec2 position =ImVec2(0, 0),
Args &&... args
)
template <class T ,
typename... Args>
inline auto createNode(
const ImVec2 position =ImVec2(0, 0),
Args &&... args
)
Creates a new node in the node editor of the specified type.
Parameters:
- position Initial position of the node
- args Node constructor arguments (except the first NodeEditor reference)
Template Parameters:
- T Node type
Return: Shared pointer to the node.
It is assumed that the first argument of the node's constructor is a NodeEditor reference and can be ommited.
function createNode
template <class T >
inline auto createNode(
const ImVec2 position =ImVec2(0, 0),
bool shiftToLeftByNodeWidth =false
)
template <class T >
inline auto createNode(
const ImVec2 position =ImVec2(0, 0),
bool shiftToLeftByNodeWidth =false
)
function deleteSelectedNodes
void deleteSelectedNodes()
void deleteSelectedNodes()
function deselectAllNodes
virtual void deselectAllNodes()
virtual void deselectAllNodes()
function draw
virtual void draw(
DrawMode drawMode =DrawMode_Interactive
) override
virtual void draw(
DrawMode drawMode =DrawMode_Interactive
) override
Generic draw method meant to be used by external code.
Parameters:
- drawMode Drawing mode
See: drawDiwne()
Reimplements: DIWNE::DiwneObject::draw
Note that some objects are meant to only by drawn using the internal drawDiwne() method instead.
function end
virtual void end(
DrawInfo & context
) override
virtual void end(
DrawInfo & context
) override
Called after content().
Reimplements: DIWNE::DiwneObject::end
Reimplemented by: Workspace::WorkspaceDiwne::end
Used to end content drawing.
function getAllNodesInnerIncluded
virtual RecursiveNodeRange getAllNodesInnerIncluded() const
virtual RecursiveNodeRange getAllNodesInnerIncluded() const
function getDpiScale
inline float getDpiScale() const
inline float getDpiScale() const
function getLastActiveNode
template <typename T =Node>
inline std::shared_ptr< T > getLastActiveNode()
template <typename T =Node>
inline std::shared_ptr< T > getLastActiveNode()
function getNodeList
virtual NodeList & getNodeList() override
virtual NodeList & getNodeList() override
Get a reference to the underlying owning vector of all nodes in the node editor.
Reimplements: DIWNE::NodeContainer::getNodeList
function getNodes
virtual NodeRange getNodes() const override
virtual NodeRange getNodes() const override
Get a view of all nodes in the node editor which can be iterated over.
Reimplements: DIWNE::NodeContainer::getNodes
The object returned is a trivial container wrapper around a node iterator. TODO: Better docs with an example TODO: This can be const. TODO: There is an idea that iterators could filter out destroyed nodes by default. Consider.
function getNodesSelectionChanged
bool getNodesSelectionChanged() const
bool getNodesSelectionChanged() const
function getPopupPosition
const ImVec2 & getPopupPosition() const
const ImVec2 & getPopupPosition() const
Get position of the last popup in screen coordinates.
function getSelectedNodes
virtual FilteredNodeRange getSelectedNodes() const
virtual FilteredNodeRange getSelectedNodes() const
function getSelectedNodesInnerIncluded
virtual FilteredRecursiveNodeRange getSelectedNodesInnerIncluded() const
virtual FilteredRecursiveNodeRange getSelectedNodesInnerIncluded() const
function getStyleOverride
StyleOverride * getStyleOverride() const =delete
StyleOverride * getStyleOverride() const =delete
function getZoom
inline float getZoom() const
inline float getZoom() const
function initializeDiwne
virtual void initializeDiwne(
DrawInfo & context
) override
virtual void initializeDiwne(
DrawInfo & context
) override
Reimplements: DIWNE::DiwneObject::initializeDiwne
function input
inline NodeEditorInputAdapter & input() const
inline NodeEditorInputAdapter & input() const
Get a reference to the node editors input adapter.
This object contains input bindings and can be set on the fly externally to swap input schemes.
function invertSelection
void invertSelection()
void invertSelection()
function isJustPressedDiwne
virtual bool isJustPressedDiwne() override
virtual bool isJustPressedDiwne() override
Determine whether a key/s of interest was/were just pressed.
See: isPressedDiwne()
Reimplements: DIWNE::DiwneObject::isJustPressedDiwne
For the press action to be carried out this method must return true at least once during the key press and release cycle. This method is needed to avoid starting the press and release cycle when the key was not pressed initially over this object (Dragging pressed mouse over the object).
function isPressedDiwne
virtual bool isPressedDiwne() override
virtual bool isPressedDiwne() override
Determine whether a key/s of interest is/are pressed down over the object.
See: When overriding also modify isJustPressedDiwne()
Note: Overriding the pressed state behavior will modify the dragging and selection behavior.
Reimplements: DIWNE::DiwneObject::isPressedDiwne
While the key is down this method should return true until the key is released.
When this method returns true and other conditions are met (hovered, press allowed), the object pressed flag is set to true and onPress() method is called.
If multiple keys make this method return true it is necessary to distinguish between them later in the implementation if different functionality for each key is desired.
function isZoomingDiwne
virtual bool isZoomingDiwne()
virtual bool isZoomingDiwne()
function onDestroy
virtual void onDestroy(
bool logEvent
) override
virtual void onDestroy(
bool logEvent
) override
Gets called the moment the object is marked for deletion by destroy().
See: destroy()
Warning: It is possible that the onDestroy() callback is never called when destroy() wasn't properly called. DiwneObjects containing other DiwneObjects should always ensure to destroy their children in their onDestroy().
Reimplements: DIWNE::DiwneObject::onDestroy
It is called only once per object.
function onDrag
virtual void onDrag(
DrawInfo & context,
bool dragStart,
bool dragEnd
) override
virtual void onDrag(
DrawInfo & context,
bool dragStart,
bool dragEnd
) override
This method gets called when the object is being dragged.
Parameters:
- dragStart The drag has just started this frame.
- dragEnd The drag is ending this frame.
See: processDragDiwne(), processPressAndReleaseDiwne()
Reimplements: DIWNE::DiwneObject::onDrag
Reimplemented by: Workspace::WorkspaceDiwne::onDrag
Drag begins when the object is pressed and isDraggedDiwne() returns true.
A call with dragStart true, should always be followed by a call with dragEnd true.
function onReleased
virtual void onReleased(
bool justReleased,
DrawInfo & context
) override
virtual void onReleased(
bool justReleased,
DrawInfo & context
) override
Called when the object is not pressed.
Parameters:
- justPressed True on the frame the object is released (becomes no longer pressed)
See: onPressed()
Reimplements: DIWNE::DiwneObject::onReleased
Every frame either this or the onPressed() method is called.
function onZoom
inline virtual void onZoom()
inline virtual void onZoom()
Reimplemented by: Workspace::WorkspaceDiwne::onZoom
function processInteractions
virtual void processInteractions(
DrawInfo & context
) override
virtual void processInteractions(
DrawInfo & context
) override
Method for reacting to user input after the object is fully drawn and its dimensions are known.
Reimplements: DIWNE::DiwneObject::processInteractions
Reimplemented by: Workspace::WorkspaceDiwne::processInteractions
It is called after end() and updateLayout(), but before the afterDraw() lifecycle method. Internal interactions are processed right before.
function processPan
virtual bool processPan()
virtual bool processPan()
Called by Canvas::setZoom() when the zoom level changes.
function processZoom
virtual bool processZoom()
virtual bool processZoom()
function purgeAllNodes
void purgeAllNodes()
void purgeAllNodes()
Erases objects marked for deletion or removal from the editor.
Also iterates through all NodeContainers in the editor and purges their nodes.
function selectAllNodes
void selectAllNodes(
bool deselectIfAllAreSelected =false
)
void selectAllNodes(
bool deselectIfAllAreSelected =false
)
Selects all nodes.
Parameters:
- deselectIfAllAreSelected If true and all nodes were already selected, deselect them all.
function setDpiScale
inline void setDpiScale(
float dpiScale
)
inline void setDpiScale(
float dpiScale
)
Set the node editor's dpi scale. Updates dpi scale of its style as well.
function setInputAdapter
template <class T ,
typename... Args>
void setInputAdapter(
Args &&... args
)
template <class T ,
typename... Args>
void setInputAdapter(
Args &&... args
)
function setLastActiveNode
inline void setLastActiveNode(
std::shared_ptr< Node > node
)
inline void setLastActiveNode(
std::shared_ptr< Node > node
)
function setNodesSelectionChanged
void setNodesSelectionChanged(
bool value
)
void setNodesSelectionChanged(
bool value
)
function setPopupPosition
void setPopupPosition(
ImVec2 position
)
void setPopupPosition(
ImVec2 position
)
Set position of the last popup in screen coordinates, used for placement of new nodes.
function setStyle
inline void setStyle(
std::unique_ptr< StyleBase > && ptr
)
inline void setStyle(
std::unique_ptr< StyleBase > && ptr
)
function setStyleOverride
void setStyleOverride(
StyleOverride * styleOverride
) =delete
void setStyleOverride(
StyleOverride * styleOverride
) =delete
function setZoom
inline void setZoom(
float val
)
inline void setZoom(
float val
)
function shiftNodesToBegin
void shiftNodesToBegin(
const NodeList & nodesToShift
)
void shiftNodesToBegin(
const NodeList & nodesToShift
)
function shiftNodesToEnd
void shiftNodesToEnd(
const NodeList & nodesToShift
)
void shiftNodesToEnd(
const NodeList & nodesToShift
)
function style
inline virtual Style & style() const override
inline virtual Style & style() const override
Get a reference to the editors style settings, which specify various colors and sizes much like ImStyle.
Reimplements: DIWNE::DiwneObject::style
function styleBase
inline StyleBase & styleBase() const
inline StyleBase & styleBase() const
function updateLayout
virtual void updateLayout(
DrawInfo & context
) override
virtual void updateLayout(
DrawInfo & context
) override
Updates object's m_rect, m_displayRect and any other object size variables.
See: m_rect, m_displayRect
Reimplements: DIWNE::DiwneObject::updateLayout
In other words this method is responsible for keeping track of the objects size.
IMPORTANT: This method should only update the m_rect's size, NOT it's position.
The object's rectangle is often set directly from ImGui's last item rectangle. But ImGui coordinates are aligned to pixel boundries via truncation of the coordinates, if the object's rect was updated directly using the screen space ImGui rectangle, there might be a slight discrepancy in the new position converted back to DIWNE coordinates which would cause the object to drift in a feedback loop.
m_displayRect should be updated together with m_rect to preserve correct pixel-aligned rendering in afterDraw(). TODO: Figure out if m_displayRect.Max should be aligned as well or not
This method is called after end() and before the afterDraw() method which can use the calculated size values for final drawing.
Protected Functions Documentation
function isDraggedDiwne
virtual bool isDraggedDiwne() override
virtual bool isDraggedDiwne() override
Is the object being dragged? (usually by mouse or some key combo)
Reimplements: DIWNE::DiwneObject::isDraggedDiwne
function purgeObjects
void purgeObjects()
void purgeObjects()
Erases objects marked for deletion or removal from the editor.
Public Attributes Documentation
variable interactionState
InteractionState interactionState;
InteractionState interactionState;
State of multi-frame user operations.
variable m_links
std::vector< std::shared_ptr< Link > > m_links;
std::vector< std::shared_ptr< Link > > m_links;
List of links, nodes are stored in NodeContainer superclass.
variable m_takeSnap
bool m_takeSnap {false};
bool m_takeSnap {false};
Indicates that a state change has occurred, can be used for undo/redo systems.
variable mp_settingsDiwne
SettingsDiwne * mp_settingsDiwne;
SettingsDiwne * mp_settingsDiwne;
Protected Attributes Documentation
variable m_canvas
std::unique_ptr< Canvas > m_canvas = std::make_unique<Canvas>(*this);
std::unique_ptr< Canvas > m_canvas = std::make_unique<Canvas>(*this);
variable m_channelSplitter
ImDrawListSplitter m_channelSplitter;
ImDrawListSplitter m_channelSplitter;
Channel splitter used to call nodes draw methods in reverse order.
variable m_input
std::unique_ptr< NodeEditorInputAdapter > m_input = std::make_unique<NodeEditorInputAdapter>(*this);
std::unique_ptr< NodeEditorInputAdapter > m_input = std::make_unique<NodeEditorInputAdapter>(*this);
variable m_lastActiveNodeChanged
bool m_lastActiveNodeChanged {false};
bool m_lastActiveNodeChanged {false};
variable m_nodesSelectionChanged
bool m_nodesSelectionChanged {false};
bool m_nodesSelectionChanged {false};
variable m_popupPosition
ImVec2 m_popupPosition;
ImVec2 m_popupPosition;
Position of the last popup in screen coordinates.
variable m_style
std::unique_ptr< StyleBase > m_style = std::make_unique<StyleBase>();
std::unique_ptr< StyleBase > m_style = std::make_unique<StyleBase>();
variable mp_lastActiveNode
std::weak_ptr< Node > mp_lastActiveNode;
std::weak_ptr< Node > mp_lastActiveNode;
Last node that requested focus (had a logical update)
Updated on 2025-05-31 at 12:55:31 +0000