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

hello_imgui ability to modify individual window style #191

Closed kuchi closed 3 months ago

kuchi commented 3 months ago

I am wanting to change the alpha of specific windows for some overlays I am doing. I couldn't figure out a way to do this with how hello_imgui handles the windows (I am using Python).

What I was wanting to call pre begin() for the window:

imgui.push_style_color(ig.Col_.window_bg.value, ig.ImVec4(38/255,38/255,38/255, 0/255))
imgui.push_style_color(ig.Col_.frame_bg.value, ig.ImVec4(12/255,12/255,12/255, 85/255))

Then of course after the end() for the window:

           ig.pop_style_color(2)

Do you have a suggested way to do this or would it make sense to have something like pre_window_function and post_window_function in DockableWindow? Or if there was a way to allow the gui_function to manually do the begin() and end() window calls instead of hello_imgui.

pthom commented 3 months ago

Hello Anthony,

If you look at the definition of DockableWindows: https://pthom.github.io/hello_imgui/book/doc_params.html#dockable-window , you will see a field named callBeginEnd (call_begin_end in python).

pthom commented 3 months ago

See https://github.com/pthom/hello_imgui/blob/910f93f53b9cc43d75ad928e8f4b6696070926f4/src/hello_imgui/internal/docking_details.cpp#L212-L238

If you intend to display a "close window button", you will have to specify a boolean with the value True as the second parameter in the call to imgui.begin. If you were using DockableWindow.focus_window_at_next_frame, you will have to handle it manually, using inspiration from this snippet.

kuchi commented 3 months ago

Thank you, I hadn't thought of looking in the docking options. That makes sense and yes I am using docking. That is perfect.

kuchi commented 3 months ago

Closing.