Skip to content

DIWNE::DiwneObject

The base class for all DIWNE elements containing common functionality.

#include "DIWNE/Core/Elements/DiwneObject.h"

Inherits from std::enable_shared_from_this< DiwneObject >

Inherited by DIWNE::Link, DIWNE::Node, DIWNE::NodeDropZone, DIWNE::NodeEditor, DIWNE::Pin

Public Functions

Name
DiwneObject(DIWNE::NodeEditor & diwne, std::string labelDiwne)
virtual~DiwneObject()
virtual voidafterDraw(DrawInfo & context)<br>Called last during drawing.
virtual boolallowDragStart() const<br>Determines whether a drag operation can start from this object.
virtual boolallowDrawing()<br>Decide whether the object should be drawn (when outside the window for example)
virtual boolallowHover() const<br>Determines whether the object can be hovered.
virtual boolallowInteraction() const<br>Decide whether the object should react to user input in general.
virtual boolallowPopup() const<br>Determines whether a popup can be raised over the object.
virtual boolallowPress(const DrawInfo & context) const<br>Determines whether the object can be pressed.
virtual boolallowSelectOnClick(const DrawInfo & context) const<br>Determines whether the object can be selected by clicking it (eg.
template <typename T =DiwneObject&gt; <br>T *as()<br>Returns a raw pointer to itself casted to a type.
virtual voidbegin(DrawInfo & context) =0<br>First method to be called during object drawing.
virtual voidcontent(DrawInfo & context) =0<br>Called after begin() during drawing.
virtual voiddestroy(bool logEvent =true)<br>Marks the object for lazy destruction/deallocation and removal from any containers (like the node editor).
virtual voiddraw(DrawMode drawMode =DrawMode_Interactive)<br>Generic draw method meant to be used by external code.
virtual voiddrawDiwne(DrawInfo & context, DrawMode drawMode =DrawMode_Interactive)<br>Internal draw method.
DrawInfodrawDiwneEx(DrawInfo & context, DrawMode drawMode =DrawMode_Interactive)
virtual voidend(DrawInfo & context) =0<br>Called after content().
virtual voidfinalize(DrawInfo & context)<br>The final method to be called, gets called every frame and doesn't do any drawing.
ImRectgetDisplayRect() const<br>Object's bounds aligned to current viewport pixel boundaries.
IDgetId() const
DiwneObject *getParentObject() const
ImVec2getPosition() const<br>Returns the top left corner of the object's rect.
virtual ImRectgetRect() const<br>Rectangle bounds of the object in DIWNE coordinates (editor canvas coordinates).
boolgetSelectable()
virtual boolgetSelected() const<br>Whether the object is selected or not.
StyleOverride *getStyleOverride() const
virtual voidinitialize(DrawInfo & context)<br>First method to be called every frame.
boolisAnyParentSelected()
boolisChildObject() const
boolisChildOfObject(DiwneObject * parent)
boolisDestroyed() const
boolisDragging(DrawInfo & context)<br>Is this object the source of an active dragging operation?
boolisFixed() const<br>Fixed objects are ones rendered at a position determined by some other object.
boolisRendered() const
boolisToBeBroughtToFront()
virtual voidonDestroy(bool logEvent)<br>Gets called the moment the object is marked for deletion by destroy().
virtual voidonDrag(DrawInfo & context, bool dragStart, bool dragEnd)<br>This method gets called when the object is being dragged.
virtual voidonHover(DrawInfo & context)<br>This method gets called when the object is hovered.
virtual voidonPopup()
virtual voidonPressed(bool justPressed, DrawInfo & context)<br>Called when the object is pressed, meaning a key is pressed over it.
virtual voidonReleased(bool justReleased, DrawInfo & context)<br>Called when the object is not pressed.
virtual voidonSelection(bool selected)
voidopenPopup()<br>Request to open the object's popup if possible.
booloperator!=(const DiwneObject & rhs) const
booloperator==(const DiwneObject & rhs) const
virtual voidpopupContent(DrawInfo & context)<br>Content of popup menu raised on this objec.
virtual voidprocessInteractions(DrawInfo & context)<br>Method for reacting to user input after the object is fully drawn and its dimensions are known.
voidsetBringToFront(bool val)<br>Marks the object to be brought to front (be drawn first).
voidsetFixed(bool val)
voidsetForceDraw(bool val)<br>When true, makes the object automatically add the ForceDraw DrawMode flag.
voidsetParentObject(DiwneObject * parent)
voidsetPopupEnabled(bool val)
voidsetPosition(const ImVec2 & position)<br>Move the object's rect and any other associated positional data to the specified position.
voidsetRendered(bool val)
voidsetSelectable(bool selectable)<br>Whether the object can be selected.
virtual boolsetSelected(bool selected)<br>Set the selection state of the object.
voidsetStyleOverride(StyleOverride * styleOverride)<br>Assign a StyleOverride object to this DiwneObject.
voidsetTooltip(const std::string & text)
voidsetTooltipEnabled(bool val)
template <typename T =DiwneObject&gt; <br>std::shared_ptr< T >sharedPtr()<br>Returns a shared pointer to this object.
voidshowTooltip(const std::string & label, const ImColor && color, DrawInfo & context)<br>Immediately show a tooltip next to the mouse cursor with the specified text.
voidshowTooltip(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.
voidstopDrag(DrawInfo & context)<br>End an active drag operation this object is a source of.
virtual Style &style() const<br>Get the style for this object.
virtual voidtooltipContent(DrawInfo & context)<br>Content of the object's tooltip.
virtual voidtranslate(const ImVec2 & vec)<br>Move the object's rect and any other associated positional data.
virtual voidupdateLayout(DrawInfo & context) =0<br>Updates object's m_rect, m_displayRect and any other object size variables.

Protected Functions

Name
virtual voidafterDrawDiwne(DrawInfo & context)<br>Updates layout, processes interactions and then calls the user afterDraw() method.
virtual voidbeginDiwne(DrawInfo & context)
virtual voidendDiwne(DrawInfo & context)
virtual voidfinalizeDiwne(DrawInfo & context)
virtual voidinitializeDiwne(DrawInfo & context)
virtual boolisDraggedDiwne()<br>Is the object being dragged? (usually by mouse or some key combo)
virtual boolisHoveredDiwne()<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 boolisJustPressedDiwne()<br>Determine whether a key/s of interest was/were just pressed.
virtual boolisPressedDiwne()<br>Determine whether a key/s of interest is/are pressed down over the object.
virtual boolpopupShouldBeOpenedDiwne() const<br>Determine whether a popup should be opened, that is, by default, that right mouse button was pressed and isn't dragging.
virtual voidprocessDragDiwne(DrawInfo & context)
virtual voidprocessHoverDiwne(DrawInfo & context)<br>Processes whether the object is currently hovered.
virtual voidprocessInteractionsDiwne(DrawInfo & context)
virtual voidprocessPopupAndTooltipDiwne(DrawInfo & context)<br>Processes whether a popup should be opened over this object.
virtual voidprocessPressAndReleaseDiwne(DrawInfo & context)<br>Processes whether the object is currently pressed (held) and further if it was just pressed or released.
virtual boolprocessSelectDiwne(DrawInfo & context)<br>Processes any interactions related to whether the object should be selected.
virtual voidsetInitialPositionDiwne()<br>Internal helper for setting the object's initial position.
voidsetSize(const ImVec2 & size)
voidupdateRectFromImGuiItem()

Public Attributes

Name
NodeEditor &diwne <br>Reference to the NodeEditor instance (also named 'editor' in some classes)
boolm_deletable <br>Whether the object can be destroyed by the user.
boolm_destroy <br>Indicates the object is to be deleted (and deallocated)
ImRectm_displayRect <br>Rectangle bounds aligned with the last viewport.
boolm_draggable <br>Whether dragging of the object is allowed by default.
DrawModem_drawMode <br>Read-only flag thats updated on each drawDiwne().
boolm_drawnThisFrame <br>Read only flag indicating whether the object has been drawn this frame.
boolm_fixed <br>Whether the object can be moved by user operations.
boolm_forceHoverDiwne <br>Special flag that can be used to enforce hover state, used by pin drag assist.
boolm_hoverable <br>Whether hovering is enabled by default.
boolm_hovered <br>Is the object hovered (usually by the mouse or whatever isHoveredDiwne() tracks)
boolm_hoverRoot <br>Whether hovering this object should prevent other objects from hovering.
IDm_idDiwne <br>Unique numeric identifier of the object.
boolm_isDragged <br>Is the object dragged? Returns false immediately on drag end (unlike isDragging()).
boolm_isPressed <br>Is the object pressed down (held)? Requirement for dragging.
boolm_justHidden <br>Read only flag indicating that this object was drawn last frame, but not this one.
boolm_justPressed <br>Read only flag indicating the object was pressed this frame (eg.
boolm_justReleased <br>Read only flag indicating the object was released this frame (eg.
std::stringm_labelDiwne <br>Unique string identifier, consists of <some string>:<m_idDiwne>.
ImRectm_rect <br>Rectangle bounds of the object in diwne coordinates.
StyleOverride *m_styleOverride <br>Style override to allow uniquely styled object types.

Protected Attributes

Name
unsigned long longg_diwneIDCounter <br>Static unique ID generator, unique only for current application run.
boolm_bringToFront <br>Request the object's rendering order to be moved to the front above other objects.
boolm_forceDraw <br>Request the next draw of the object to have the ForceDraw DrawMode flag.
boolm_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.
boolm_openPopup <br>Request to open popup.
boolm_openTooltip <br>Request to open tooltip.
DiwneObject *m_parentObject <br>Sets the parent object of object, relevant in node container and hover hierarchy.
boolm_popupEnabled <br>Whether this object has popup enabled.
std::stringm_popupLabelDiwne <br>ImGui popup identifier.
boolm_rendered <br>Whether the object should be drawn, this is a general flag that overrides behavior of the allowDrawing() method.
boolm_selectable <br>Should not be accessed directly.
boolm_selected <br>Should not be accessed directly.
boolm_tooltipEnabled <br>Whether this object has tooltip enabled.
std::stringm_tooltipText

Public Functions Documentation

function DiwneObject

cpp
DiwneObject(
    DIWNE::NodeEditor & diwne,
    std::string labelDiwne
)
DiwneObject(
    DIWNE::NodeEditor & diwne,
    std::string labelDiwne
)

Parameters:

  • diwne is node editor object that this object belongs to
  • id used to identification
  • labelDiwne used to identification

function ~DiwneObject

cpp
virtual ~DiwneObject()
virtual ~DiwneObject()

function afterDraw

cpp
virtual void afterDraw(
    DrawInfo & context
)
virtual void afterDraw(
    DrawInfo & context
)

Called last during drawing.

Reimplemented by: Workspace::CoreNodeWithPins::afterDraw, Workspace::Camera::afterDraw, Workspace::Model::afterDraw, Workspace::Sequence::afterDraw, DIWNE::BasicNodeWithPins::afterDraw, DIWNE::NodeDropZone::afterDraw, DIWNE::Node::afterDraw, DIWNE::Pin::afterDraw, DIWNE::NodeEditor::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 allowDragStart

cpp
virtual bool allowDragStart() const
virtual bool allowDragStart() const

Determines whether a drag operation can start from this object.

See: isDraggedDiwne(), allowPress()

Reimplemented by: DIWNE::NodeDropZone::allowDragStart, DIWNE::Pin::allowDragStart, Workspace::Node::allowDragStart

By default the only requirement is the object to be pressed.

function allowDrawing

cpp
virtual bool allowDrawing()
virtual bool allowDrawing()

Decide whether the object should be drawn (when outside the window for example)

Reimplemented by: DIWNE::Link::allowDrawing, DIWNE::Node::allowDrawing, Workspace::CoreNode::allowDrawing, Workspace::CorePin::allowDrawing, Workspace::Sequence::allowDrawing, Workspace::TransformationBase::allowDrawing

function allowHover

cpp
virtual bool allowHover() const
virtual bool allowHover() const

Determines whether the object can be hovered.

See: isHoveredDiwne()

Reimplemented by: DIWNE::NodeDropZone::allowHover

Is always allowed by default.

function allowInteraction

cpp
virtual bool allowInteraction() const
virtual bool allowInteraction() const

Decide whether the object should react to user input in general.

Dear ImGui components might require special handling.

function allowPopup

cpp
virtual bool allowPopup() const
virtual bool allowPopup() const

Determines whether a popup can be raised over the object.

See: processPopupDiwne()

Reimplemented by: DIWNE::Pin::allowPopup

Allowed by default.

function allowPress

cpp
virtual bool allowPress(
    const DrawInfo & context
) const
virtual bool allowPress(
    const DrawInfo & context
) const

Determines whether the object can be pressed.

See: isPressedDiwne(), allowHover(), DrawInfo::inputConsumed, InteractionState::dragging

Reimplemented by: Workspace::CoreNodeWithPins::allowPress, DIWNE::BasicNodeWithPins::allowPress

By default this requires the object to be hovered, input not being consumed and nothing else being dragged.

function allowSelectOnClick

cpp
virtual bool allowSelectOnClick(
    const DrawInfo & context
) const
virtual bool allowSelectOnClick(
    const DrawInfo & context
) const

Determines whether the object can be selected by clicking it (eg.

See: processSelectDiwne()

Reimplemented by: Workspace::CoreLink::allowSelectOnClick

pressing and then releasing it). This is a type of interaction and not related to whether the object is "selectable" or not. Programmatical selection using DiwneObject::setSelected() is not affected.

function as

cpp
template <typename T  =DiwneObject>
inline T * as()
template <typename T  =DiwneObject>
inline T * as()

Returns a raw pointer to itself casted to a type.

Template Parameters:

  • T The pointer will be statically cast to this type. Ensure the cast won't fail. There are runtime checks in debug mode.

Useful as a shorthand for casting to derived object type.

function begin

cpp
virtual void begin(
    DrawInfo & context
) =0
virtual void begin(
    DrawInfo & context
) =0

First method to be called during object drawing.

Reimplemented by: Workspace::CoreNode::begin, Workspace::CoreNodeWithPins::begin, Workspace::Cycle::begin, Workspace::Sequence::begin, Workspace::WorkspaceDiwne::begin, DIWNE::BasicNode::begin, DIWNE::BasicNodeWithPins::begin, DIWNE::NodeDropZone::begin, DIWNE::Link::begin, DIWNE::Node::begin, DIWNE::Pin::begin, DIWNE::NodeEditor::begin

Can be used to initialize drawing code.

function content

cpp
virtual void content(
    DrawInfo & context
) =0
virtual void content(
    DrawInfo & context
) =0

Called after begin() during drawing.

Reimplemented by: Workspace::CoreLink::content, Workspace::CorePin::content, Workspace::WorkspaceDiwne::content, DIWNE::BasicNode::content, DIWNE::NodeDropZone::content, DIWNE::Link::content, DIWNE::Node::content, DIWNE::Pin::content, DIWNE::NodeEditor::content

Draws object content.

function destroy

cpp
virtual void destroy(
    bool logEvent =true
)
virtual void destroy(
    bool logEvent =true
)

Marks the object for lazy destruction/deallocation and removal from any containers (like the node editor).

Parameters:

  • logEvent The boolean flag passed to onDestroy(), can be used to determine where was destroy() called from.

See: onDestroy(), isDestroyed(), ~DiwneObject()

An object can be destroyed only once, which will invoke the onDestroy() callback. Repeated calls have no effect. When the actual deallocation and destruction occurs depends on the specific object. For example deletion of nodes and links is handled by the NodeEditor in the next frame. This methods needs to be called before the objects destructor. Internally DIWNE does not use RAII. The node editor object is an exception in that it calls destroy on itself automatically in a RAII manner. When an object gets destructed without being marked for destruction a warning message is printed.

function draw

cpp
virtual void draw(
    DrawMode drawMode =DrawMode_Interactive
)
virtual void draw(
    DrawMode drawMode =DrawMode_Interactive
)

Generic draw method meant to be used by external code.

Parameters:

  • drawMode Drawing mode

See: drawDiwne()

Reimplemented by: DIWNE::NodeEditor::draw

Note that some objects are meant to only by drawn using the internal drawDiwne() method instead.

function drawDiwne

cpp
virtual void drawDiwne(
    DrawInfo & context,
    DrawMode drawMode =DrawMode_Interactive
)
virtual void drawDiwne(
    DrawInfo & context,
    DrawMode drawMode =DrawMode_Interactive
)

Internal draw method.

Parameters:

  • context The drawing context of the current frame.
  • drawMode The drawing mode of this draw.

See: DIWNE Object Lifecycle

function drawDiwneEx

cpp
DrawInfo drawDiwneEx(
    DrawInfo & context,
    DrawMode drawMode =DrawMode_Interactive
)
DrawInfo drawDiwneEx(
    DrawInfo & context,
    DrawMode drawMode =DrawMode_Interactive
)

function end

cpp
virtual void end(
    DrawInfo & context
) =0
virtual void end(
    DrawInfo & context
) =0

Called after content().

Reimplemented by: Workspace::TransformationBase::end, Workspace::WorkspaceDiwne::end, DIWNE::BasicNode::end, DIWNE::NodeDropZone::end, DIWNE::Link::end, DIWNE::Node::end, DIWNE::Pin::end, DIWNE::NodeEditor::end

Used to end content drawing.

function finalize

cpp
virtual void finalize(
    DrawInfo & context
)
virtual void finalize(
    DrawInfo & context
)

The final method to be called, gets called every frame and doesn't do any drawing.

Reimplemented by: Workspace::Screen::finalize, Workspace::WorkspaceDiwne::finalize

function getDisplayRect

cpp
inline ImRect getDisplayRect() const
inline ImRect getDisplayRect() const

Object's bounds aligned to current viewport pixel boundaries.

See: getRect(), m_displayRect

Should be within ~1.0 margin of m_rect (but might be more). This rectangle should be used instead of m_rect when drawing backgrounds/borders etc, as it better aligns with ImGui content. The reason is that ImGui content is aligned on screen pixel boundaries, but m_rect isn't as it would then shift around, depending on the viewport position / zoom levels.

This rectangle is updated in DiwneObject::begin() can can be considered valid for the duration of the draw.

function getId

cpp
inline ID getId() const
inline ID getId() const

function getParentObject

cpp
DiwneObject * getParentObject() const
DiwneObject * getParentObject() const

function getPosition

cpp
inline ImVec2 getPosition() const
inline ImVec2 getPosition() const

Returns the top left corner of the object's rect.

function getRect

cpp
inline virtual ImRect getRect() const
inline virtual ImRect getRect() const

Rectangle bounds of the object in DIWNE coordinates (editor canvas coordinates).

See: getDisplayRect(), updateLayout(), m_rect

The top left corner of the rectangle (.Min) represents the objects position. Dimensions are the differences between the .Min and .Max (bottom right corner) coordinates.

The objects rectangle gets updated every frame by the updateLayout() method.

DiwneObjects are mostly drawn at the position of the ImGui cursor and this rect is updated accordingly. Some objects (like nodes) instead set the cursor position based on this rect.

Converting the objects position to screen coordinates will inevitably yield fractional pixel positions, since Dear ImGui does not handle fractional coordinates well, these initial screen coordinates get truncated to a pixel boundary, this new position, when converted back to diwne coordinates is slightly different. The m_rect position cannot be rounded as it would then change depending on the viewport position / zoom. Hence the slightly offset position is captured in m_displayRect and can be used for more precise, pixel aligned drawing.

function getSelectable

cpp
bool getSelectable()
bool getSelectable()

function getSelected

cpp
virtual bool getSelected() const
virtual bool getSelected() const

Whether the object is selected or not.

function getStyleOverride

cpp
StyleOverride * getStyleOverride() const
StyleOverride * getStyleOverride() const

See: setStyleOverride()

function initialize

cpp
virtual void initialize(
    DrawInfo & context
)
virtual void initialize(
    DrawInfo & context
)

First method to be called every frame.

Reimplemented by: Workspace::CoreLink::initialize, Workspace::Camera::initialize, Workspace::Model::initialize, DIWNE::NodeDropZone::initialize, DIWNE::Link::initialize, DIWNE::Pin::initialize

Does not handle drawing.

function isAnyParentSelected

cpp
inline bool isAnyParentSelected()
inline bool isAnyParentSelected()

function isChildObject

cpp
bool isChildObject() const
bool isChildObject() const

function isChildOfObject

cpp
inline bool isChildOfObject(
    DiwneObject * parent
)
inline bool isChildOfObject(
    DiwneObject * parent
)

function isDestroyed

cpp
inline bool isDestroyed() const
inline bool isDestroyed() const

See: destroy()

function isDragging

cpp
bool isDragging(
    DrawInfo & context
)
bool isDragging(
    DrawInfo & context
)

Is this object the source of an active dragging operation?

See:

function isFixed

cpp
bool isFixed() const
bool isFixed() const

Fixed objects are ones rendered at a position determined by some other object.

In such a case their position is "read only" as it will get overwritten. Top level nodes aren't fixed, as the editor adjust the ImGui cursor to their position before drawing. Objects drawn inside other objects will usually be fixed.

function isRendered

cpp
bool isRendered() const
bool isRendered() const

function isToBeBroughtToFront

cpp
bool isToBeBroughtToFront()
bool isToBeBroughtToFront()

function onDestroy

cpp
virtual void onDestroy(
    bool logEvent
)
virtual void onDestroy(
    bool logEvent
)

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().

Reimplemented by: Workspace::Node::onDestroy, DIWNE::BasicNodeWithPins::onDestroy, DIWNE::SequenceNodeContainer::onDestroy, DIWNE::NodeDropZone::onDestroy, DIWNE::Link::onDestroy, DIWNE::Node::onDestroy, DIWNE::Pin::onDestroy, DIWNE::NodeEditor::onDestroy, Workspace::CoreNode::onDestroy, Workspace::CoreNodeWithPins::onDestroy, Workspace::Camera::onDestroy, Workspace::Sequence::onDestroy, Workspace::TransformationBase::onDestroy

It is called only once per object.

function onDrag

cpp
virtual void onDrag(
    DrawInfo & context,
    bool dragStart,
    bool dragEnd
)
virtual void onDrag(
    DrawInfo & context,
    bool dragStart,
    bool dragEnd
)

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()

Reimplemented by: Workspace::WorkspaceDiwne::onDrag, DIWNE::Node::onDrag, DIWNE::Pin::onDrag, DIWNE::NodeEditor::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 onHover

cpp
virtual void onHover(
    DrawInfo & context
)
virtual void onHover(
    DrawInfo & context
)

This method gets called when the object is hovered.

Parameters:

  • context

See: processHoverDiwne()

Reimplemented by: DIWNE::Link::onHover, DIWNE::Node::onHover

This generally indicates mouse hover, but the behavior can be changed via isHoveredDiwne().

function onPopup

cpp
inline virtual void onPopup()
inline virtual void onPopup()

Reimplemented by: Workspace::CoreNode::onPopup, Workspace::WorkspaceDiwne::onPopup

function onPressed

cpp
virtual void onPressed(
    bool justPressed,
    DrawInfo & context
)
virtual void onPressed(
    bool justPressed,
    DrawInfo & context
)

Called when the object is pressed, meaning a key is pressed over it.

Parameters:

  • justPressed True on the frame of the actual press, false otherwise when the key is held down.

See: isPressedDiwne(), processPressAndReleaseDiwne()

Note: This isn't a general method for reacting to any input. This method signals a specific "pressed" or "held" state of the object which is only triggered for certain keys specified by isPressedDiwne(). By default this means being "pressed by the left mouse button", but this behavior can vary in subclasses.

Which key or keys trigger this state is determined by is isPressedDiwne() and isJustPressedDiwne(). An object is allowed to be pressed only when allowPress() returns true.

function onReleased

cpp
virtual void onReleased(
    bool justReleased,
    DrawInfo & context
)
virtual void onReleased(
    bool justReleased,
    DrawInfo & context
)

Called when the object is not pressed.

Parameters:

  • justPressed True on the frame the object is released (becomes no longer pressed)

See: onPressed()

Reimplemented by: Workspace::CoreNode::onReleased, Workspace::CorePin::onReleased, DIWNE::NodeEditor::onReleased

Every frame either this or the onPressed() method is called.

function onSelection

cpp
virtual void onSelection(
    bool selected
)
virtual void onSelection(
    bool selected
)

Reimplemented by: DIWNE::Node::onSelection, Workspace::CoreNode::onSelection, Workspace::Camera::onSelection, Workspace::Model::onSelection, Workspace::Screen::onSelection

function openPopup

cpp
void openPopup()
void openPopup()

Request to open the object's popup if possible.

function operator!=

cpp
inline bool operator!=(
    const DiwneObject & rhs
) const
inline bool operator!=(
    const DiwneObject & rhs
) const

function operator==

cpp
inline bool operator==(
    const DiwneObject & rhs
) const
inline bool operator==(
    const DiwneObject & rhs
) const

function popupContent

cpp
virtual void popupContent(
    DrawInfo & context
)
virtual void popupContent(
    DrawInfo & context
)

Content of popup menu raised on this objec.

Reimplemented by: Workspace::CoreLink::popupContent, Workspace::CoreNode::popupContent, Workspace::Node::popupContent, Workspace::Camera::popupContent, Workspace::Model::popupContent, Workspace::Screen::popupContent, Workspace::ScriptingNode::popupContent, Workspace::Sequence::popupContent, Workspace::TransformationBase::popupContent, Workspace::WorkspaceDiwne::popupContent

function processInteractions

cpp
inline virtual void processInteractions(
    DrawInfo & context
)
inline virtual void processInteractions(
    DrawInfo & context
)

Method for reacting to user input after the object is fully drawn and its dimensions are known.

Reimplemented by: Workspace::WorkspaceDiwne::processInteractions, DIWNE::NodeDropZone::processInteractions, DIWNE::Pin::processInteractions, DIWNE::NodeEditor::processInteractions

It is called after end() and updateLayout(), but before the afterDraw() lifecycle method. Internal interactions are processed right before.

function setBringToFront

cpp
void setBringToFront(
    bool val
)
void setBringToFront(
    bool val
)

Marks the object to be brought to front (be drawn first).

Is handled by the object's parent / container. For nodes, they are brought forward in rendering order next frame by the NodeEditor / NodeContainer.

function setFixed

cpp
void setFixed(
    bool val
)
void setFixed(
    bool val
)

function setForceDraw

cpp
void setForceDraw(
    bool val
)
void setForceDraw(
    bool val
)

When true, makes the object automatically add the ForceDraw DrawMode flag.

This flag is true by default and is reset after drawing. Can be used to ensure that size information is obtained no matter the drawing criteria for the first frame.

function setParentObject

cpp
void setParentObject(
    DiwneObject * parent
)
void setParentObject(
    DiwneObject * parent
)

function setPopupEnabled

cpp
void setPopupEnabled(
    bool val
)
void setPopupEnabled(
    bool val
)

function setPosition

cpp
void setPosition(
    const ImVec2 & position
)
void setPosition(
    const ImVec2 & position
)

Move the object's rect and any other associated positional data to the specified position.

See: translate()

function setRendered

cpp
void setRendered(
    bool val
)
void setRendered(
    bool val
)

function setSelectable

cpp
void setSelectable(
    bool selectable
)
void setSelectable(
    bool selectable
)

Whether the object can be selected.

When this is set to true the object cannot be selected anymore. Although it may remain selected if it was selected beforehand.

function setSelected

cpp
virtual bool setSelected(
    bool selected
)
virtual bool setSelected(
    bool selected
)

Set the selection state of the object.

See: setSelectable()

Return:

  • The new state of selection
  • New state of selection

This method can be used to select the object. If the selection state is changed by the call the onSelection() method is invoked.

function setStyleOverride

cpp
void setStyleOverride(
    StyleOverride * styleOverride
)
void setStyleOverride(
    StyleOverride * styleOverride
)

Assign a StyleOverride object to this DiwneObject.

Warning: StyleOverride objects ARE NOT managed by DIWNE, meaning this pointer is assumed to be always valid. Handle lifetime of StyleOverride objects in your own code.

This object acts as a proxy of the overarching NodeEditor's style. It can replace certain style variables with different ones to change style of a particular set of DiwneObject's it has been assigned to. A single StyleOverride object can be shared among many objects (to style a particular Node type for example).

function setTooltip

cpp
void setTooltip(
    const std::string & text
)
void setTooltip(
    const std::string & text
)

function setTooltipEnabled

cpp
void setTooltipEnabled(
    bool val
)
void setTooltipEnabled(
    bool val
)

function sharedPtr

cpp
template <typename T  =DiwneObject>
inline std::shared_ptr< T > sharedPtr()
template <typename T  =DiwneObject>
inline std::shared_ptr< T > sharedPtr()

Returns a shared pointer to this object.

Template Parameters:

  • T The pointer will be statically cast to this type. Ensure the cast won't fail. There are runtime checks in debug mode.

All DiwneObjects are assumed to be stored somewhere as a shared pointer. This can be used to retrieve an owning shared pointer from a "weak" raw pointer to a DiwneObject.

function showTooltip

cpp
void showTooltip(
    const std::string & label,
    const ImColor && color,
    DrawInfo & context
)
void showTooltip(
    const std::string & label,
    const ImColor && color,
    DrawInfo & context
)

Immediately show a tooltip next to the mouse cursor with the specified text.

Parameters:

  • label Text to show
  • color is the color of the tooltip

Prevents other tooltips from showing this frame.

function showTooltip

cpp
void showTooltip(
    const std::string & label,
    const std::string & desc,
    const ImColor && color,
    DrawInfo & context,
    float wrapWidth =35.f
)
void showTooltip(
    const std::string & label,
    const std::string & desc,
    const ImColor && color,
    DrawInfo & context,
    float wrapWidth =35.f
)

Immediately show a tooltip next to the mouse cursor with the specified text.

Parameters:

  • label Text to show
  • desc Smaller text description
  • color Color of the tooltip
  • wrapWidth Max number of characters before text wrap.

Prevents other tooltips from showing this frame.

function stopDrag

cpp
void stopDrag(
    DrawInfo & context
)
void stopDrag(
    DrawInfo & context
)

End an active drag operation this object is a source of.

See: onDrag()

function style

cpp
virtual Style & style() const
virtual Style & style() const

Get the style for this object.

See: setStyleOverride(), StyleBase

Reimplemented by: DIWNE::NodeEditor::style

NodeEditor subclass is where the base style is stored. Other objects however can override the base style.

function tooltipContent

cpp
virtual void tooltipContent(
    DrawInfo & context
)
virtual void tooltipContent(
    DrawInfo & context
)

Content of the object's tooltip.

Reimplemented by: Workspace::CorePin::tooltipContent

function translate

cpp
virtual void translate(
    const ImVec2 & vec
)
virtual void translate(
    const ImVec2 & vec
)

Move the object's rect and any other associated positional data.

Reimplemented by: DIWNE::BasicNode::translate, DIWNE::BasicNodeWithPins::translate, DIWNE::Pin::translate, Workspace::CoreNodeWithPins::translate

function updateLayout

cpp
virtual void updateLayout(
    DrawInfo & context
) =0
virtual void updateLayout(
    DrawInfo & context
) =0

Updates object's m_rect, m_displayRect and any other object size variables.

See: m_rect, m_displayRect

Reimplemented by: DIWNE::BasicNode::updateLayout, DIWNE::NodeDropZone::updateLayout, DIWNE::Link::updateLayout, DIWNE::Node::updateLayout, DIWNE::Pin::updateLayout, DIWNE::NodeEditor::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 afterDrawDiwne

cpp
virtual void afterDrawDiwne(
    DrawInfo & context
)
virtual void afterDrawDiwne(
    DrawInfo & context
)

Updates layout, processes interactions and then calls the user afterDraw() method.

Reimplemented by: DIWNE::Node::afterDrawDiwne

function beginDiwne

cpp
virtual void beginDiwne(
    DrawInfo & context
)
virtual void beginDiwne(
    DrawInfo & context
)

function endDiwne

cpp
virtual void endDiwne(
    DrawInfo & context
)
virtual void endDiwne(
    DrawInfo & context
)

Reimplemented by: Workspace::CoreNode::endDiwne

function finalizeDiwne

cpp
virtual void finalizeDiwne(
    DrawInfo & context
)
virtual void finalizeDiwne(
    DrawInfo & context
)

function initializeDiwne

cpp
virtual void initializeDiwne(
    DrawInfo & context
)
virtual void initializeDiwne(
    DrawInfo & context
)

Reimplemented by: DIWNE::Link::initializeDiwne, DIWNE::NodeEditor::initializeDiwne

function isDraggedDiwne

cpp
virtual bool isDraggedDiwne()
virtual bool isDraggedDiwne()

Is the object being dragged? (usually by mouse or some key combo)

Reimplemented by: DIWNE::NodeEditor::isDraggedDiwne

function isHoveredDiwne

cpp
virtual bool isHoveredDiwne()
virtual bool isHoveredDiwne()

Is the object being hovered? The default implementation mostly gets this information from ImGui::IsItemHovered() but the behavior can be changed or restricted.

Reimplemented by: DIWNE::Link::isHoveredDiwne

This implementation assumes that the last ImGui item represents the entirety of the object.

It is possible the object is hovered but some other object inside of it captured the hover beforehand and didn't propagate it towards this one. Being hovered is used as a prerequisite for most interactions.

This method is indirectly called from processInteractionsDiwne() which is called right after end() method.

If the DiwneObject isn't represented by an ImGui item, this method has to be overridden and modified accordingly. This default implementation uses ImGui::IsItemHovered() call as it handles all various cases of other UI elements or windows overlapping this object.

function isJustPressedDiwne

cpp
virtual bool isJustPressedDiwne()
virtual bool isJustPressedDiwne()

Determine whether a key/s of interest was/were just pressed.

See: isPressedDiwne()

Reimplemented by: DIWNE::NodeEditor::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

cpp
virtual bool isPressedDiwne()
virtual bool isPressedDiwne()

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.

Reimplemented by: DIWNE::NodeEditor::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 popupShouldBeOpenedDiwne

cpp
virtual bool popupShouldBeOpenedDiwne() const
virtual bool popupShouldBeOpenedDiwne() const

Determine whether a popup should be opened, that is, by default, that right mouse button was pressed and isn't dragging.

function processDragDiwne

cpp
virtual void processDragDiwne(
    DrawInfo & context
)
virtual void processDragDiwne(
    DrawInfo & context
)

function processHoverDiwne

cpp
virtual void processHoverDiwne(
    DrawInfo & context
)
virtual void processHoverDiwne(
    DrawInfo & context
)

Processes whether the object is currently hovered.

See: isHoveredDiwne(), allowHover()

Hover is a prerequisite for most other interactions. Hover processing is often delegated to ImGui items forming the objects using the m_internalHover flag. Otherwise a manual mouse intersection test is needed. Hover state can also be forced using the m_forceHoverDiwne flag, which gets reset every frame.

function processInteractionsDiwne

cpp
virtual void processInteractionsDiwne(
    DrawInfo & context
)
virtual void processInteractionsDiwne(
    DrawInfo & context
)

function processPopupAndTooltipDiwne

cpp
virtual void processPopupAndTooltipDiwne(
    DrawInfo & context
)
virtual void processPopupAndTooltipDiwne(
    DrawInfo & context
)

Processes whether a popup should be opened over this object.

Parameters:

  • context

If it is, the popupContent() method is called.

function processPressAndReleaseDiwne

cpp
virtual void processPressAndReleaseDiwne(
    DrawInfo & context
)
virtual void processPressAndReleaseDiwne(
    DrawInfo & context
)

Processes whether the object is currently pressed (held) and further if it was just pressed or released.

By default, being pressed means that the mouse is pressed down when hovering over it. The first frame of the press is considered just pressed, same for the last with just released.

What key or keys trigger the pressed state depends on the implementation of isPressedDiwne() and isJustPressedDiwne().

Regarding clicks or key presses: The concept of a "click" is often ambiguous. In ImGui it generally means the moment the mouse is just pressed. However clicks are more traditionally considered to be a rapid sequence of press and release. In DIWNE the click terminology isn't really used, an equivalent would be just released whilist not dragging. Meaning if you want to react to a click put an if (!context.state.dragging) in the onReleased() callback.

function processSelectDiwne

cpp
virtual bool processSelectDiwne(
    DrawInfo & context
)
virtual bool processSelectDiwne(
    DrawInfo & context
)

Processes any interactions related to whether the object should be selected.

Parameters:

  • context

See: processPressAndReleaseDiwne()

Return: Whether selection processing should end. Can be used to exit early from derived methods.

Note: This is not the only method which can select the object.

Reimplemented by: DIWNE::Node::processSelectDiwne

The default behavior is selection when the object is pressed and then released (clicked).

function setInitialPositionDiwne

cpp
virtual void setInitialPositionDiwne()
virtual void setInitialPositionDiwne()

Internal helper for setting the object's initial position.

Reimplemented by: DIWNE::Link::setInitialPositionDiwne, DIWNE::Node::setInitialPositionDiwne

function setSize

cpp
void setSize(
    const ImVec2 & size
)
void setSize(
    const ImVec2 & size
)

function updateRectFromImGuiItem

cpp
void updateRectFromImGuiItem()
void updateRectFromImGuiItem()

Public Attributes Documentation

variable diwne

cpp
NodeEditor & diwne;
NodeEditor & diwne;

Reference to the NodeEditor instance (also named 'editor' in some classes)

variable m_deletable

cpp
bool m_deletable {true};
bool m_deletable {true};

Whether the object can be destroyed by the user.

variable m_destroy

cpp
bool m_destroy {false};
bool m_destroy {false};

Indicates the object is to be deleted (and deallocated)

variable m_displayRect

cpp
ImRect m_displayRect;
ImRect m_displayRect;

Rectangle bounds aligned with the last viewport.

See: getDisplayRect()

variable m_draggable

cpp
bool m_draggable {true};
bool m_draggable {true};

Whether dragging of the object is allowed by default.

variable m_drawMode

cpp
DrawMode m_drawMode {DrawMode_Interactive};
DrawMode m_drawMode {DrawMode_Interactive};

Read-only flag thats updated on each drawDiwne().

Essentially just a way to avoid passing this along everywhere as it should stay constant for each object.

variable m_drawnThisFrame

cpp
bool m_drawnThisFrame {false};
bool m_drawnThisFrame {false};

Read only flag indicating whether the object has been drawn this frame.

variable m_fixed

cpp
bool m_fixed {false};
bool m_fixed {false};

Whether the object can be moved by user operations.

See: isFixed()

variable m_forceHoverDiwne

cpp
bool m_forceHoverDiwne {false};
bool m_forceHoverDiwne {false};

Special flag that can be used to enforce hover state, used by pin drag assist.

variable m_hoverable

cpp
bool m_hoverable {true};
bool m_hoverable {true};

Whether hovering is enabled by default.

variable m_hovered

cpp
bool m_hovered {false};
bool m_hovered {false};

Is the object hovered (usually by the mouse or whatever isHoveredDiwne() tracks)

variable m_hoverRoot

cpp
bool m_hoverRoot {false};
bool m_hoverRoot {false};

Whether hovering this object should prevent other objects from hovering.

variable m_idDiwne

cpp
ID m_idDiwne;
ID m_idDiwne;

Unique numeric identifier of the object.

variable m_isDragged

cpp
bool m_isDragged {false};
bool m_isDragged {false};

Is the object dragged? Returns false immediately on drag end (unlike isDragging()).

variable m_isPressed

cpp
bool m_isPressed {false};
bool m_isPressed {false};

Is the object pressed down (held)? Requirement for dragging.

See: onPressed()

When dragged it is still pressed. This flag becomes valid since the processInteractions() lifecycle step.

variable m_justHidden

cpp
bool m_justHidden {false};
bool m_justHidden {false};

Read only flag indicating that this object was drawn last frame, but not this one.

variable m_justPressed

cpp
bool m_justPressed {false};
bool m_justPressed {false};

Read only flag indicating the object was pressed this frame (eg.

See: onPressed() Is object just pressed? Eg. was the button pressed down this frame.

onPressed() with justPressed=true was called) This flag becomes valid since the processInteractions() lifecycle step.

variable m_justReleased

cpp
bool m_justReleased {false};
bool m_justReleased {false};

Read only flag indicating the object was released this frame (eg.

See: onReleased() Is object just released? Eg. was the button released this frame.

onReleased() with justReleased true was called) This flag becomes valid since the processInteractions() lifecycle step.

variable m_labelDiwne

cpp
std::string m_labelDiwne;
std::string m_labelDiwne;

Unique string identifier, consists of <some string>:<m_idDiwne>.

variable m_rect

cpp
ImRect m_rect;
ImRect m_rect;

Rectangle bounds of the object in diwne coordinates.

See: getRect()

variable m_styleOverride

cpp
StyleOverride * m_styleOverride {nullptr};
StyleOverride * m_styleOverride {nullptr};

Style override to allow uniquely styled object types.

Protected Attributes Documentation

variable g_diwneIDCounter

cpp
static unsigned long long g_diwneIDCounter = 1;
static unsigned long long g_diwneIDCounter = 1;

Static unique ID generator, unique only for current application run.

variable m_bringToFront

cpp
bool m_bringToFront {false};
bool m_bringToFront {false};

Request the object's rendering order to be moved to the front above other objects.

variable m_forceDraw

cpp
bool m_forceDraw {true};
bool m_forceDraw {true};

Request the next draw of the object to have the ForceDraw DrawMode flag.

variable m_internalHover

cpp
bool m_internalHover {false};
bool m_internalHover {false};

Temporary storage for an internal ImGui::IsItemHovered() check Can be set in the end() method to determine if object is hovered if applicable.

variable m_openPopup

cpp
bool m_openPopup {false};
bool m_openPopup {false};

Request to open popup.

variable m_openTooltip

cpp
bool m_openTooltip {false};
bool m_openTooltip {false};

Request to open tooltip.

variable m_parentObject

cpp
DiwneObject * m_parentObject {nullptr};
DiwneObject * m_parentObject {nullptr};

Sets the parent object of object, relevant in node container and hover hierarchy.

variable m_popupEnabled

cpp
bool m_popupEnabled {true};
bool m_popupEnabled {true};

Whether this object has popup enabled.

variable m_popupLabelDiwne

cpp
std::string m_popupLabelDiwne;
std::string m_popupLabelDiwne;

ImGui popup identifier.

variable m_rendered

cpp
bool m_rendered {true};
bool m_rendered {true};

Whether the object should be drawn, this is a general flag that overrides behavior of the allowDrawing() method.

variable m_selectable

cpp
bool m_selectable {true};
bool m_selectable {true};

Should not be accessed directly.

See: setSelectable()

variable m_selected

cpp
bool m_selected {false};
bool m_selected {false};

Should not be accessed directly.

See: setSelected()

variable m_tooltipEnabled

cpp
bool m_tooltipEnabled {false};
bool m_tooltipEnabled {false};

Whether this object has tooltip enabled.

variable m_tooltipText

cpp
std::string m_tooltipText;
std::string m_tooltipText;

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