mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Nav: Menus: Fix for using Left direction inside a menu with widgets layed out horizontally. Left to close is now handled as a fallback inside EndMenu(). (#787)
This commit is contained in:
parent
c09016b12a
commit
8227176c17
18
imgui.cpp
18
imgui.cpp
@ -10842,7 +10842,7 @@ void ImGui::EndMenuBar()
|
||||
return;
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
// When a move request within one of our child menu failed, capture the request to navigate among our siblings.
|
||||
// Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings.
|
||||
if (g.NavMoveRequest && g.NavMoveResultId == 0 && (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) && (g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
|
||||
{
|
||||
ImGuiWindow* nav_earliest_child = g.NavWindow;
|
||||
@ -10926,7 +10926,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
g.NavWindow = backed_nav_window;
|
||||
|
||||
bool want_open = false, want_close = false;
|
||||
if (window->DC.LayoutType != ImGuiLayoutType_Horizontal) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
|
||||
if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
|
||||
{
|
||||
// Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive.
|
||||
bool moving_within_opened_triangle = false;
|
||||
@ -10960,11 +10960,6 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
want_open = true;
|
||||
g.NavMoveRequest = false;
|
||||
}
|
||||
if (g.NavWindow && g.NavWindow->ParentWindow == window && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Left && IsPopupOpen(id)) // Nav-Left to close
|
||||
{
|
||||
want_close = true;
|
||||
g.NavMoveRequest = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -11013,6 +11008,15 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
|
||||
void ImGui::EndMenu()
|
||||
{
|
||||
// Nav: When a left move request within our child menu failed, close the menu
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (g.NavWindow && g.NavWindow->ParentWindow == window && g.NavMoveRequest && g.NavMoveResultId == 0 && g.NavMoveDir == ImGuiDir_Left && window->DC.LayoutType == ImGuiLayoutType_Vertical)
|
||||
{
|
||||
ClosePopupToLevel(g.OpenPopupStack.Size - 1);
|
||||
g.NavMoveRequest = false;
|
||||
}
|
||||
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user