Skip to content

Commit

Permalink
Support changing of the thickness of indivual links using PushStyleVa…
Browse files Browse the repository at this point in the history
…r(ImNodesStyleVar_LinkThickness, ...). This is a fix for Nelarius#153 .
  • Loading branch information
Simon Winkelbach committed Dec 7, 2022
1 parent d88f991 commit bacd7c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion imnodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,8 @@ void DrawLink(ImNodesEditorContext& editor, const int link_idx)
link_color = link.ColorStyle.Hovered;
}

float link_thickness = link.Thickness;

#if IMGUI_VERSION_NUM < 18000
GImNodes->CanvasDrawList->AddBezierCurve(
#else
Expand All @@ -1627,7 +1629,7 @@ void DrawLink(ImNodesEditorContext& editor, const int link_idx)
cubic_bezier.P2,
cubic_bezier.P3,
link_color,
GImNodes->Style.LinkThickness,
link_thickness,
cubic_bezier.NumSegments);
}

Expand Down Expand Up @@ -2611,6 +2613,7 @@ void Link(const int id, const int start_attr_id, const int end_attr_id)
link.ColorStyle.Base = GImNodes->Style.Colors[ImNodesCol_Link];
link.ColorStyle.Hovered = GImNodes->Style.Colors[ImNodesCol_LinkHovered];
link.ColorStyle.Selected = GImNodes->Style.Colors[ImNodesCol_LinkSelected];
link.Thickness = GImNodes->Style.LinkThickness;

// Check if this link was created by the current link event
if ((editor.ClickInteraction.Type == ImNodesClickInteractionType_LinkCreation &&
Expand Down
4 changes: 3 additions & 1 deletion imnodes_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ struct ImLinkData
ImU32 Base, Hovered, Selected;
} ColorStyle;

ImLinkData(const int link_id) : Id(link_id), StartPinIdx(), EndPinIdx(), ColorStyle() {}
float Thickness;

ImLinkData(const int link_id) : Id(link_id), StartPinIdx(), EndPinIdx(), ColorStyle(), Thickness() {}
};

struct ImClickInteractionState
Expand Down

0 comments on commit bacd7c3

Please sign in to comment.