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

DockSpaceOverViewport with BeginMainMenuBar? #2889

Closed
philrdubois opened this issue Nov 11, 2019 · 6 comments
Closed

DockSpaceOverViewport with BeginMainMenuBar? #2889

philrdubois opened this issue Nov 11, 2019 · 6 comments
Labels
docking menus menu bars, menu items

Comments

@philrdubois
Copy link

philrdubois commented Nov 11, 2019

Version/Branch of Dear ImGui:

Version: 1.74 WIP (17301)
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
Compiler: g++
Operating System: linux

My Issue/Question:

Hey all,

What a wonderful and useful library! There is however an issue I've been fighting with.

Whenever using the dockspace over viewport feature, use of the main menu bar draws over the tab bar / window decoration. I know there's mention in the code that DockSpaceOverViewport() would prevent the use of BeginMainMenuBar(), however this would seem to be common use so it would be nice if it was implemented. Something such as padding to the top of the viewport for docking would do the trick, however I don't know where to begin to implement such a thing!

Thanks,
Phil.

Screenshots/Video
Note that window decorations and tab bars work for other windows:
Screenshot_2019-11-11_14-49-04

Standalone, minimal, complete and verifiable example:

ImGui::DockSpaceOverViewport();
if (ImGui::BeginMainMenuBar()) {
    if (ImGui::BeginMenu("File")) {
        ImGui::EndMenu();
    }
    if (ImGui::BeginMenu("Edit")) {
        ImGui::EndMenu();
    }
    ImGui::EndMainMenuBar();
}
ImGui::ShowAboutWindow();
@ocornut ocornut added docking menus menu bars, menu items labels Nov 12, 2019
@ocornut
Copy link
Owner

ocornut commented Nov 12, 2019

The comment for DockspaceOverViewport() says:

// Tips: Use with ImGuiDockNodeFlags_PassthruCentralNode!
// The limitation with this call is that your window won't have a menu bar.
// Even though we could pass window flags, it would also require the user to be able to call BeginMenuBar() somehow meaning we can't Begin/End in a single function.
// So if you want a menu bar you need to repeat this code manually ourselves. As with advanced other Docking API, we may change this function signature.

For now you'll probably want to create your own window hosting the dockspace by essentially replicating the code in DockSpaceOverViewport(), and:

  • either you add a menu to that window (using BeginMenuBar() instead of BeginMainMenuBar())
  • either you alter the position and size of the window to leave space for the main menu bar.

Ideally we need another solution such as main menu bar communicating their need to take space from the main work area (which would also have the effect that, e.g. you can't lose a thin window under a menu bar).

@philrdubois
Copy link
Author

Thanks for the rapid response.

I was afraid you'd say that... I had considered the first point there but was worried I'd be going down a rabbit hole. Sobeit, it will give me the opportunity to learn more about OpenGL and this library.

If I find a worthy solution, I'll post it here.

@ocornut
Copy link
Owner

ocornut commented Nov 13, 2019

I'm not sure what this has to do with "OpenGL" ? I gave you a solution above, copy DockSpaceOverViewport() into your own function. All the calls in there are public ImGui API calls the function does nothing very special.

@philrdubois
Copy link
Author

Apologies, I must have misunderstood. I have very little graphics experience, and no 3D experience. I was under the impression that it would be more difficult to draw in an ImGui window than in the default viewport, but if that's not the case then disregard my comment.

@ocornut
Copy link
Owner

ocornut commented Feb 25, 2020

Closing as duplicate of #3035. Even though #3035 came in later the discussion there is envisioning a possible solution so I'll leave the other open until solved.

@ocornut ocornut closed this as completed Feb 25, 2020
ocornut added a commit that referenced this issue Feb 26, 2020
…-bars. Fixed DocksapceOverViewport() and demo code (overlay etc) (#3035, #2889, #2474, #1542, #2109)

Clarified that BeginMenuMainBar() had an incorrect knowledge of its height (which was previously harmless).
Designed to easily allow for status bars although we don't have/use them yet, but custom code could use them.
@ocornut
Copy link
Owner

ocornut commented Feb 26, 2020

Update: this is now fixed by 75de34e !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docking menus menu bars, menu items
Projects
None yet
Development

No branches or pull requests

2 participants