From bacd7c3c23741434e7c0173e01a02de8f7c99a99 Mon Sep 17 00:00:00 2001 From: Simon Winkelbach Date: Wed, 7 Dec 2022 15:26:04 +0100 Subject: [PATCH] Support changing of the thickness of indivual links using PushStyleVar(ImNodesStyleVar_LinkThickness, ...). This is a fix for https://github.com/Nelarius/imnodes/issues/153 . --- imnodes.cpp | 5 ++++- imnodes_internal.h | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/imnodes.cpp b/imnodes.cpp index 7689cb1..8c2d5ac 100644 --- a/imnodes.cpp +++ b/imnodes.cpp @@ -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 @@ -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); } @@ -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 && diff --git a/imnodes_internal.h b/imnodes_internal.h index 593ab49..48e96ea 100644 --- a/imnodes_internal.h +++ b/imnodes_internal.h @@ -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