Closed ketoo closed 4 years ago
Thanks for the contribution again!
I have an alternate proposal for adding icons to the title bar: check out the commit in my title_bar_rework
branch. It makes the title bar immediate-mode, just like the node attributes.
I think it's a better approach since it actually reduces the node state, and as a result there's fewer things that the imnodes
API needs to "know" about. As a bonus, you can now leave the title bar out by just not calling Begin/EndNodeTitleBar!
Here's a quick and dirty example I did using ImGui's font atlas texture 😄 :
And the code to generate the node in the screencap:
imnodes::BeginNode(1);
// Here's the new bit 👇
imnodes::BeginNodeTitleBar();
ImGui::Image(
texture.id,
ImVec2(40.f, 15.f),
ImVec2(0.f, 0.f),
ImVec2(0.2f, 0.5f));
ImGui::SameLine();
ImGui::TextUnformatted("image node");
imnodes::EndNodeTitleBar();
imnodes::BeginInputAttribute(2);
ImGui::Text("input");
imnodes::EndAttribute();
imnodes::BeginOutputAttribute(3);
ImGui::Indent(80.0f);
ImGui::Text("output");
imnodes::EndAttribute();
imnodes::EndNode();
If you have nothing against this approach, I will close this pr and merge my branch 👍
Great, your way better and close the concept of immediate-mode. Please close this PR and merge your branch into the master branch.
Demo listed below: