pthom / imgui_bundle

Dear ImGui Bundle: an extensive set of Ready-to-use widgets and libraries, based on ImGui. Start your first app in 5 lines of code, or less. Whether you prefer Python or C++, this pack has your back!
https://pthom.github.io/imgui_bundle/
MIT License
590 stars 62 forks source link

[imgui_node_editor] Can't set value for `Colors[StyleColor_*]` #205

Closed hugle closed 2 months ago

hugle commented 2 months ago

Is there a way to set default StyleColor for node editor?

I notice that the c++ signature was not bind into python API for imgui_node_editor. The commended code is here within Style class:

https://github.com/pthom/imgui_bundle/blob/85d3fafa16794f0eb3d8c6fcf1a7918550ee9591/bindings/imgui_bundle/imgui_node_editor.pyi#L389-L407

Is there a way to access those Colors attributes?

pthom commented 2 months ago

There is no way to access them as an array, but there is a way to set them:

    ed.push_style_color(ed.StyleColor.node_bg, ImVec4(0.2, 0.2, 0.2, 1.0))
hugle commented 2 months ago

But I see imgui style color is done correctly at:

https://github.com/pthom/imgui_bundle/blob/f9d61bfe10ff2d13b0e08bee9eaf18639088d10b/bindings/imgui_bundle/imgui/__init__.pyi#L7804-L7811

Why not apply the same wrapper?

hugle commented 2 months ago

Or maybe, is the same way imgui does also applies to imgui_node_editor? If so, I could create a PR if you don't have capacity for this.

pthom commented 2 months ago

Thanks for the proposition. I'm always happy to accept qualitative PRs :-)

In this case I had already started working on it, so I finished it.

Here is some more information if you want to contribute in a later: This kind of work requires to run the generator. There is some doc about it here: https://pthom.github.io/imgui_bundle/devel_docs/bindings.html, and here: https://pthom.github.io/litgen/litgen_book/00_00_intro.html

  1. First I had to add some manual new methods in the node editor fork: https://github.com/pthom/imgui-node-editor/compare/daccee1e227f50f2636634396d5334b4b081d5a3...cefbd3eec32b22cc7fb96f343a130d6677a67400#diff-805621e5151ef6f5b47901439963a38fa5a9f2bfb7dee7cb6a9f18116bb2fc9f (They are protected by this specific define: IMGUI_BUNDLE_PYTHON_API)

  2. Then I had to add this specific define in the generator options, then rerun the generator: https://github.com/pthom/imgui_bundle/commit/7b61b6cb3786eac22bb09ee3878aaf4e4a9d612f

hugle commented 2 months ago

Cool, @pthom , thanks very much for the fast patch.