pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
604 stars 91 forks source link

how to add a toolbar (or other fixed windows) that limits the available main docking space? #88

Closed wkjarosz closed 5 months ago

wkjarosz commented 5 months ago

I've been trying to find a way to create a toolbar along the top of the screen (but under the menu bar). I've found explanations for various ways to accomplish this, including using BeginViewportSideBar, but I'm struggling to get this to work because HelloImGui takes over the creation of the docking spaces in e.g. DoCreateFullScreenImGuiWindow. I found that by manually using a BeginMainMenuBar and a BeginViewportSideBar I can get the effect I want, but the full screen docking space that HelloImGui creates only knows about its own status bar at the bottom, so the docking space is sized and position in a way where my additional menubar and tool/sidebar cover up the docking drop zones and HelloImGui's own menubar. If I edit DoCreateFullScreenImGuiWindow, I can make the fullscreen docking space start just below my top bars, but I'd prefer to find a solution that didn't require me to manually change/fork HelloImGui.

Do you have a suggested way to accomplish this, or is this currently outside the scope of what HelloImGui can allow? If its not possible to accomplish this right now, is there a clean way for me to create and manage my own docking spaces, menu/tool/statusbars, but still rely on HelloImGui's crossplatform backend and asset support?

(On a related note, is there a reason why you used BeginMenuBar and not BeginMainMenuBar for the top menu in docking mode?)

Thanks

pthom commented 5 months ago

Can you Please post a sample for repro

pthom commented 5 months ago

Done, see ImGuiWindowParams doc (look for "Change the dockspace or background window size")

See 60d9429ae7ecbcba884e591ab49e266c409702e9 and 21b0162f1e96f8dab1a19e5bef259e0524199ead

wkjarosz commented 5 months ago

Thanks. I'll give it a try! I suspect, however, that this will only allow adding a toolbar above the top menu bar, since BeginMenuBar is created within the full dock space/window. Using BeginMainMenuBar in that situation might be a way to solve this.

wkjarosz commented 5 months ago

I probably spoke too soon, I see there are mentions of BeginMainMenuBar in the new code. I'll try it out.

wkjarosz commented 5 months ago

This is fantastic! Exactly what I needed. Thank you for the rapid response.

There is one issue, which is that below my toolbar, there is a hidden and unused menubar. I believe this is because the main docking window still has the menubar flag set, which is not needed since the menubar is now provided by BeginMainMenuBar now. Here is a screenshot showing this when setting the windowbg color to be pretty transparent. Note that you can see the blue of the custom background through the top part of the semitransparent toolbar, but the bottom part of it is darker because there is a menu bar behind it too.

image

pthom commented 5 months ago

This is fantastic! Exactly what I needed. Thank you for the rapid response.

Thanks !

There is one issue, which is that below my toolbar, there is a hidden and unused menubar. I believe this is because the main docking window still has the menubar flag set, which is not needed since the menubar is now provided by BeginMainMenuBar

Since you have the setup to reproduce the issue, can you try and remove

    if (imGuiWindowParams.showMenuBar)
        window_flags |= ImGuiWindowFlags_MenuBar;

inside DoCreateFullScreenImGuiWindow, and if it works push a PR (or inform me)

pthom commented 5 months ago

Your suggestion made me think that I should add a callback ShowTopToolbar to RunnerCallbacks

pthom commented 5 months ago

The issue with transparent window bg was actually complex to track: it required to call BeginMainMenuBar() when no window is created.

This commit fixes this, and also add support for Edge Toolbars: see related doc

wkjarosz commented 5 months ago

I can confirm this works great. Thanks! As far as I'm concerned, this issue is resolved, so feel free to close.