Skip to content

DIWNE::Pin

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

Inherits from DIWNE::DiwneObject, std::enable_shared_from_this< DiwneObject >

Inherited by Workspace::CorePin

Public Functions

Name
Pin(NodeEditor & diwne, Node * node, bool isInput, std::string labelDiwne ="DiwnePin")
virtual voidafterDraw(DrawInfo & context) override<br>Called last during drawing.
virtual boolallowConnection() const<br>A condition for starting and receiving a link connection.
virtual boolallowDragStart() const override<br>Determines whether a drag operation can start from this object.
virtual boolallowPopup() const override<br>Determines whether a popup can be raised over the object.
virtual voidbegin(DrawInfo & context) override<br>First method to be called during object drawing.
virtual boolcanPlug(Pin * other) const<br>Quick check of compatibility between this and some other pin.
boolconnectionChanged() const
virtual voidcontent(DrawInfo & context) override<br>Called after begin() during drawing.
virtual std::shared_ptr< Link >createLink()<br>Method responsible for constructing a new link for this pin.
virtual voidend(DrawInfo & context) override<br>Called after content().
virtual const ImVec2 &getConnectionPoint()
const ImRect &getDragRect() const
Link *getLink(size_t index =0)
template <typename T =Node&gt; <br>T *getNode()
Node *getNode()
const ImRect &getPinRect() const
virtual voidinitialize(DrawInfo & context) override<br>First method to be called every frame.
virtual boolisDisabled() const<br>/// Whether the pin is disabled or not. When disabled it cannot be plugged in.
virtual boolisDragAreaHovered() const<br>Condition determining when a new link can be created from the pin on drag.
boolisInput() const<br>Whether this is an input or output pin.
boolisLeft() const<br>Whether the pin is rendered on the left side of a node.
boolisPlugged() const
voidmakeInput()<br>Called to initialize an input pin or to switch to being one.
voidmakeOutput()<br>Called to initialize an output pin or to switch to being one.
virtual voidonDestroy(bool logEvent) override<br>Gets called the moment the object is marked for deletion by destroy().
virtual voidonDrag(DrawInfo & context, bool dragStart, bool dragEnd) override<br>This method gets called when the object is being dragged.
virtual voidonPlug(Pin * otherPin, Link * link, bool isStartPin, bool logEvent =true)<br>Called after the pin has been connected to another pin using a link.
virtual voidonUnplug(Pin * otherPin, Link * link, bool wasStartPin, bool logEvent =true)<br>Called after the link connecting this pin to another is disconnected.
virtual boolplug(Pin * otherPin, bool logEvent =true)<br>Create a new link between this pin and the other pin.
template <typename T &gt; <br>boolplug(Pin * otherPin, T logEvent) =delete
virtual boolplugLink(Pin * otherPin, Link * link, bool logEvent =true)<br>Connect this and some other pin together using an existing link.
virtual boolpreparePlug(Pin * otherPin, Link * link, bool hovering, DIWNE::DrawInfo & context)<br>Called when the mouse is dragging a new link and is hovering over this pin as well as when it is released.
virtual voidprocessInteractions(DrawInfo & context) override<br>Method for reacting to user input after the object is fully drawn and its dimensions are known.
boolregisterLink(Link * link)<br>Adds the link to the pin's list of links.
virtual voidsetConnectionPointDiwne(const ImVec2 & value)<br>Set the point to which connected links are attached.
virtual voidtranslate(const ImVec2 & vec) override<br>Move the object's rect and any other associated positional data.
virtual boolunplug(bool logEvent =true, bool deleteLinks =true)<br>Unplug all links from this pin.
boolunregisterLink(Link * link)<br>Removes the link from the pin's list of links.
virtual voidupdateLayout(DrawInfo & context) override<br>Updates object's m_rect, m_displayRect and any other object size variables.

Protected Functions

Name
voiddrawPinBackground()
virtual voidupdateConnectionPoint()<br>Updates the connection point.

Public Attributes

Name
boolm_allowMultipleConnections <br>Only allow one link to be connected, set to false for input pins.
boolm_isInput <br>Whether this is an input or output pin,.
boolm_isLeft <br>Whether this pin is on the left or right side of a node Determined from m_isInput by default (inputs are on the right)
PinIconDrawDatam_pinIconData <br>Temporary data used while drawing the pin.

Protected Attributes

Name
boolm_connectionChanged <br>Flag indicating that the pin has been plugged or unplugged last time the pin was drawn.
ImVec2m_connectionPoint <br>Point where a link connects to this pin.
ImRectm_dragRect <br>Rect of the area that can be dragged to start a new connection.
std::vector< Link * >m_links <br>Links connected to this pin.
Node *m_node <br>Node this pin belongs to.
ImRectm_pinRect <br>Rect of the pin icon/socket. Links will connect to this.
boolm_previewPlugged <br>Style the pin as if it was plugged in.
boolm_previewPluggedInternal <br>Temp flag during drawing.

Additional inherited members

Public Functions inherited from DIWNE::DiwneObject

Name
DiwneObject(DIWNE::NodeEditor & diwne, std::string labelDiwne)
virtual~DiwneObject()
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 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 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 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
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 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.
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.

Protected Functions inherited from DIWNE::DiwneObject

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 inherited from DIWNE::DiwneObject

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 inherited from DIWNE::DiwneObject

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 Pin

cpp
Pin(
    NodeEditor & diwne,
    Node * node,
    bool isInput,
    std::string labelDiwne ="DiwnePin"
)
Pin(
    NodeEditor & diwne,
    Node * node,
    bool isInput,
    std::string labelDiwne ="DiwnePin"
)

function afterDraw

cpp
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 allowConnection

cpp
virtual bool allowConnection() const
virtual bool allowConnection() const

A condition for starting and receiving a link connection.

Reimplemented by: Workspace::CorePin::allowConnection

Can be used to specify an area where the pin can be dragged from or a link dropped at.

function allowDragStart

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

Determines whether a drag operation can start from this object.

See: isDraggedDiwne(), allowPress()

Reimplements: DIWNE::DiwneObject::allowDragStart

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

function allowPopup

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

Determines whether a popup can be raised over the object.

See: processPopupDiwne()

Reimplements: DIWNE::DiwneObject::allowPopup

Allowed by default.

function begin

cpp
virtual void begin(
    DrawInfo & context
) override
virtual void begin(
    DrawInfo & context
) override

First method to be called during object drawing.

Reimplements: DIWNE::DiwneObject::begin

Can be used to initialize drawing code.

function canPlug

cpp
virtual bool canPlug(
    Pin * other
) const
virtual bool canPlug(
    Pin * other
) const

Quick check of compatibility between this and some other pin.

See: preparePlug()

Used for invalid pin dimming. The check in preparePlug() is expected to be more precise and potentially more demanding (checking of loops), that's why this "quick" check exists, since it gets called very often from all pins on the screen when dragging.

function connectionChanged

cpp
bool connectionChanged() const
bool connectionChanged() const

function content

cpp
virtual void content(
    DrawInfo & context
) override
virtual void content(
    DrawInfo & context
) override

Called after begin() during drawing.

Reimplements: DIWNE::DiwneObject::content

Draws object content.

cpp
virtual std::shared_ptr< Link > createLink()
virtual std::shared_ptr< Link > createLink()

Method responsible for constructing a new link for this pin.

Return: The new Link instance, it is already registered with the current editor and has no connections yet.

Reimplemented by: Workspace::CorePin::createLink

By default a standard Link object is used, however this method can be overriden to allow specific pins to use specialized link subclasses.

function end

cpp
virtual void end(
    DrawInfo & context
) override
virtual void end(
    DrawInfo & context
) override

Called after content().

Reimplements: DIWNE::DiwneObject::end

Used to end content drawing.

function getConnectionPoint

cpp
virtual const ImVec2 & getConnectionPoint()
virtual const ImVec2 & getConnectionPoint()

function getDragRect

cpp
const ImRect & getDragRect() const
const ImRect & getDragRect() const

See: m_dragRect

cpp
Link * getLink(
    size_t index =0
)
Link * getLink(
    size_t index =0
)

function getNode

cpp
template <typename T  =Node>
inline T * getNode()
template <typename T  =Node>
inline T * getNode()

function getNode

cpp
Node * getNode()
Node * getNode()

function getPinRect

cpp
const ImRect & getPinRect() const
const ImRect & getPinRect() const

See: m_pinRect

function initialize

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

First method to be called every frame.

Reimplements: DIWNE::DiwneObject::initialize

Does not handle drawing.

function isDisabled

cpp
virtual bool isDisabled() const
virtual bool isDisabled() const

/// Whether the pin is disabled or not. When disabled it cannot be plugged in.

Reimplemented by: Workspace::CorePin::isDisabled

function isDragAreaHovered

cpp
virtual bool isDragAreaHovered() const
virtual bool isDragAreaHovered() const

Condition determining when a new link can be created from the pin on drag.

The drag area is defined by the m_dragRect, or the m_pinRect if dragging by labels is disabled.

function isInput

cpp
bool isInput() const
bool isInput() const

Whether this is an input or output pin.

See: isLeft()

Input pins are restricted to only accept at most one connection. They also force links to always end in them, meaning a link can't begin in an input pin. Output pins have no such restrictions. They can be on either end of a link and have any amount of connections, when m_allowMultipleConnections is enabled. For input pins that flag is forced to false.

function isLeft

cpp
bool isLeft() const
bool isLeft() const

Whether the pin is rendered on the left side of a node.

Usually input pins are rendered on the left but they don't always have to. Hence one shouldn't rely on this method returning the same as isInput()

function isPlugged

cpp
bool isPlugged() const
bool isPlugged() const

function makeInput

cpp
void makeInput()
void makeInput()

Called to initialize an input pin or to switch to being one.

function makeOutput

cpp
void makeOutput()
void makeOutput()

Called to initialize an output pin or to switch to being one.

function onDestroy

cpp
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

cpp
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

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.

Reset valid flag

function onPlug

cpp
virtual void onPlug(
    Pin * otherPin,
    Link * link,
    bool isStartPin,
    bool logEvent =true
)
virtual void onPlug(
    Pin * otherPin,
    Link * link,
    bool isStartPin,
    bool logEvent =true
)

Called after the pin has been connected to another pin using a link.

Parameters:

  • otherPin The pin on the other side of the link. Cannot be null.
  • link The link of the new connection with both ends plugged.
  • isStartPin Whether this pin is the start of the connection (otherwise it's the end).
  • logEvent The flag passed to the origin of the action.

Reimplemented by: Workspace::CorePin::onPlug

function onUnplug

cpp
virtual void onUnplug(
    Pin * otherPin,
    Link * link,
    bool wasStartPin,
    bool logEvent =true
)
virtual void onUnplug(
    Pin * otherPin,
    Link * link,
    bool wasStartPin,
    bool logEvent =true
)

Called after the link connecting this pin to another is disconnected.

Parameters:

  • otherPin The pin on the other side of the link. Can be null.
  • link The link of the disconnected connection.
  • wasStartPin Whether this pin was the start of the connection (otherwise it was the end).
  • logEvent The flag passed to the origin of the action.

Reimplemented by: Workspace::CorePin::onUnplug

function plug

cpp
virtual bool plug(
    Pin * otherPin,
    bool logEvent =true
)
virtual bool plug(
    Pin * otherPin,
    bool logEvent =true
)

Create a new link between this pin and the other pin.

Parameters:

  • otherPin The other pin on the other side of the new link.
  • logEvent The boolean flag passed to onPlug() on successful connect

Return: True on success, false otherwise

The other pin is considered the start of the link, except when it is an input pin. Both pins cannot be input pins.

function plug

cpp
template <typename T >
bool plug(
    Pin * otherPin,
    T logEvent
) =delete
template <typename T >
bool plug(
    Pin * otherPin,
    T logEvent
) =delete
cpp
virtual bool plugLink(
    Pin * otherPin,
    Link * link,
    bool logEvent =true
)
virtual bool plugLink(
    Pin * otherPin,
    Link * link,
    bool logEvent =true
)

Connect this and some other pin together using an existing link.

Parameters:

  • otherPin The other pin on the other side of the link.
  • link
  • logEvent The boolean flag passed to onUnplug() on successful disconnect

Return: true

Reimplemented by: Workspace::CorePin::plugLink

The other pin is considered the start of the link, except when it is an input pin. Both pins cannot be input pins. The link will get unplugged from other pins if necessary.

function preparePlug

cpp
virtual bool preparePlug(
    Pin * otherPin,
    Link * link,
    bool hovering,
    DIWNE::DrawInfo & context
)
virtual bool preparePlug(
    Pin * otherPin,
    Link * link,
    bool hovering,
    DIWNE::DrawInfo & context
)

Called when the mouse is dragging a new link and is hovering over this pin as well as when it is released.

Parameters:

  • otherPin The other pin, usually the starting pin of the link, but it can be the end pin as well.
  • link The link that's being prepared for plugging
  • hovering True when the mouse is only hovering over the pin and it shouldn't be plugged in yet.

See: canPlug()

Return: Whether the link is ready to be plugged in.

When the hovering argument is false, the mouse was released and the link should be connected. The method is responsible for the underlying plug in logic and determining whether the connection is valid.

function processInteractions

cpp
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

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

cpp
bool registerLink(
    Link * link
)
bool registerLink(
    Link * link
)

Adds the link to the pin's list of links.

Return: true if the link was added, false if it already existed

function setConnectionPointDiwne

cpp
virtual void setConnectionPointDiwne(
    const ImVec2 & value
)
virtual void setConnectionPointDiwne(
    const ImVec2 & value
)

Set the point to which connected links are attached.

function translate

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

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

Reimplements: DIWNE::DiwneObject::translate

function unplug

cpp
virtual bool unplug(
    bool logEvent =true,
    bool deleteLinks =true
)
virtual bool unplug(
    bool logEvent =true,
    bool deleteLinks =true
)

Unplug all links from this pin.

Parameters:

  • logEvent The boolean flag passed to onUnplug() on successful disconnect
  • deleteLinks Whether to also destroy the links after unplugging.

Return: True on success, false otherwise

cpp
bool unregisterLink(
    Link * link
)
bool unregisterLink(
    Link * link
)

Removes the link from the pin's list of links.

Return: true if removed, false if it didn't exist

function updateLayout

cpp
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 drawPinBackground

cpp
void drawPinBackground()
void drawPinBackground()

function updateConnectionPoint

cpp
virtual void updateConnectionPoint()
virtual void updateConnectionPoint()

Updates the connection point.

Public Attributes Documentation

variable m_allowMultipleConnections

cpp
bool m_allowMultipleConnections {true};
bool m_allowMultipleConnections {true};

Only allow one link to be connected, set to false for input pins.

variable m_isInput

cpp
bool m_isInput {false};
bool m_isInput {false};

Whether this is an input or output pin,.

See: isInput()

variable m_isLeft

cpp
bool m_isLeft {true};
bool m_isLeft {true};

Whether this pin is on the left or right side of a node Determined from m_isInput by default (inputs are on the right)

variable m_pinIconData

cpp
PinIconDrawData m_pinIconData;
PinIconDrawData m_pinIconData;

Temporary data used while drawing the pin.

Protected Attributes Documentation

variable m_connectionChanged

cpp
bool m_connectionChanged;
bool m_connectionChanged;

Flag indicating that the pin has been plugged or unplugged last time the pin was drawn.

Note: This flag gets reset the moment the pin is drawn. Meaning if the node owning this pin needs that information AFTER the pin is drawn, it is a good idea to save or react to this flag during initialize() or begin().

variable m_connectionPoint

cpp
ImVec2 m_connectionPoint {ImVec2(0, 0)};
ImVec2 m_connectionPoint {ImVec2(0, 0)};

Point where a link connects to this pin.

variable m_dragRect

cpp
ImRect m_dragRect;
ImRect m_dragRect;

Rect of the area that can be dragged to start a new connection.

cpp
std::vector< Link * > m_links;
std::vector< Link * > m_links;

Links connected to this pin.

variable m_node

cpp
Node * m_node;
Node * m_node;

Node this pin belongs to.

variable m_pinRect

cpp
ImRect m_pinRect;
ImRect m_pinRect;

Rect of the pin icon/socket. Links will connect to this.

variable m_previewPlugged

cpp
bool m_previewPlugged {false};
bool m_previewPlugged {false};

Style the pin as if it was plugged in.

variable m_previewPluggedInternal

cpp
bool m_previewPluggedInternal {false};
bool m_previewPluggedInternal {false};

Temp flag during drawing.


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