MCPcopy Create free account
hub / github.com/Raais/ImStudio / EndMenuBar

Method EndMenuBar

src/third-party/imgui/imgui_widgets.cpp:6712–6751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6710}
6711
6712void ImGui::EndMenuBar()
6713{
6714 ImGuiWindow* window = GetCurrentWindow();
6715 if (window->SkipItems)
6716 return;
6717 ImGuiContext& g = *GImGui;
6718
6719 // Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings.
6720 if (NavMoveRequestButNoResultYet() && (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) && (g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
6721 {
6722 // Try to find out if the request is for one of our child menu
6723 ImGuiWindow* nav_earliest_child = g.NavWindow;
6724 while (nav_earliest_child->ParentWindow && (nav_earliest_child->ParentWindow->Flags & ImGuiWindowFlags_ChildMenu))
6725 nav_earliest_child = nav_earliest_child->ParentWindow;
6726 if (nav_earliest_child->ParentWindow == window && nav_earliest_child->DC.ParentLayoutType == ImGuiLayoutType_Horizontal && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded) == 0)
6727 {
6728 // To do so we claim focus back, restore NavId and then process the movement request for yet another frame.
6729 // This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth bothering)
6730 const ImGuiNavLayer layer = ImGuiNavLayer_Menu;
6731 IM_ASSERT(window->DC.NavLayersActiveMaskNext & (1 << layer)); // Sanity check
6732 FocusWindow(window);
6733 SetNavID(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]);
6734 g.NavDisableHighlight = true; // Hide highlight for the current frame so we don't see the intermediary selection.
6735 g.NavDisableMouseHover = g.NavMousePosDirty = true;
6736 NavMoveRequestForward(g.NavMoveDir, g.NavMoveClipDir, g.NavMoveFlags, g.NavMoveScrollFlags); // Repeat
6737 }
6738 }
6739
6740 IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'"
6741 IM_ASSERT(window->Flags & ImGuiWindowFlags_MenuBar);
6742 IM_ASSERT(window->DC.MenuBarAppending);
6743 PopClipRect();
6744 PopID();
6745 window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->Pos.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
6746 g.GroupStack.back().EmitItem = false;
6747 EndGroup(); // Restore position on layer 0
6748 window->DC.LayoutType = ImGuiLayoutType_Vertical;
6749 window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
6750 window->DC.MenuBarAppending = false;
6751}
6752
6753// Important: calling order matters!
6754// FIXME: Somehow overlapping with docking tech.

Callers

nothing calls this directly

Calls 1

GetCurrentWindowFunction · 0.85

Tested by

no test coverage detected