Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support changing of the thickness of indivual links using PushStyleVar(ImNodesStyleVar_LinkThickness, ...). This is a fix for https://github.com/Nelarius/imnodes/issues/153 . #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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