-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Docking Issue: MainMenuBar occluded by dock #2474
Comments
You made a mistake here. I’ll let you check the Demo and the Metrics window to understand what you did wrong. |
Oh; should I be using the dockspace stuff directly then? Using the demo window I could get what I wanted to work by using dockspace. Pardon my ignorance, but if you're inclined to teach me how to fish; how should I have used the Metrics window to discover this? |
You are calling the wrong functions.
The Metrics window can allow you to see which windows are active and their relationship and if you compare your code to eg the menu bar in the demo window you’ll see a difference both in code and in the effects visible in Metrics.
|
OK. I seem to have it fixed with using this: ImVec2 vWindowSize = ImGui::GetMainViewport()->Size;
ImVec2 vPos0 = ImGui::GetMainViewport()->Pos;
ImGui::SetNextWindowPos( ImVec2( (float) vPos0.x, (float) vPos0.y ), ImGuiCond_Always );
ImGui::SetNextWindowSize( ImVec2( (float) vWindowSize.x, (float) vWindowSize.y ), ImGuiSetCond_Always );
if ( ImGui::Begin(
"Editor",
/*p_open=*/nullptr,
ImGuiWindowFlags_MenuBar |
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoTitleBar
)
)
{
{
static const ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None;
ImGuiID dockSpace = ImGui::GetID( "MainWindowDockspace" );
ImGui::DockSpace( dockSpace, ImVec2( 0.0f, 0.0f ), dockspaceFlags );
if ( ImGui::BeginMainMenuBar() )
{
if ( ImGui::BeginMenu( "File" ) )
{
if ( ImGui::MenuItem( "New map" ) )
{
}
if ( ImGui::MenuItem( "Load map..." ) )
{
}
if ( ImGui::MenuItem( "Save map" ) )
{
}
if ( ImGui::MenuItem( "Save map as..." ) )
{
}
if ( ImGui::MenuItem( "Exit" ) )
{
}
ImGui::EndMenu();
}
}
ImGui::EndMainMenuBar();
if ( ImGui::Begin( "One" ) )
{
ImGui::Text( "Text" );
ImGui::End();
}
}
ImGui::End();
} After having looked through the docking API, this seems to be the 'right' way to do what I'm doing? Lastly, I notice that I can programmatically cause a dock with SetNextWindowDockID(); but I'd really like to be able to lay it out. I can't see any API surface similar to SetNextWindowDockID(..., [axis]); do you have plans for something like that? |
BeginMainMenuBar create a dedicated window, you are not using the actual menu bar of your host window. You can use BeginMenuBar for that.
|
( If you want to use a MainMenuBar instead of a regular in-window MenuBar, then make sure your other window doesn’t sit right in front of it, by positioning/sizing it accordingly. ) |
Interesting. Functionally it didn't seem to create a difference either way until I created the dockspace however. Also; is there a faculty to programmatically dock to one side of a dockspace? I can't see anything in the public API, and the private stuff seems to use internal splitter/treeview stuff. |
There’s a private/wip DockBuilder api for that, it is discussed in the main docking thread. |
There's a large difference.
In your situation, the overlapping position made this confusion. |
…-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.
I'm not sure if this is expected, but using the docking feature, if I have a BeginMainMenuBar, any docked windows will occlude it. I'd expect that the sizeable space for the dock would respect the mainmenubar where possible.
Example code
If you drag and drop the window named "One" onto any of the docks (directional or 'middle'), it'll hide the mainmenu bar.
The text was updated successfully, but these errors were encountered: