mirror of https://github.com/ocornut/imgui
Nav: Menus and popups now have move request wrap around vertically (using the move request forward thing added recently). (#787)
This commit is contained in:
parent
3ddcdcf6e7
commit
f326fac64a
19
imgui.cpp
19
imgui.cpp
|
@ -4476,11 +4476,28 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags ext
|
|||
return is_open;
|
||||
}
|
||||
|
||||
static void NavProcessMoveRequestWrapAround(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.NavMoveRequest && g.NavWindow == window && g.NavMoveResultId == 0)
|
||||
if ((g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) && g.NavMoveRequestForwardStep == 0 && g.NavLayer == 0)
|
||||
{
|
||||
g.NavMoveRequest = false;
|
||||
g.NavMoveRequestForwardStep = 1;
|
||||
g.NavWindow->NavRectRel[0].Min.y = g.NavWindow->NavRectRel[0].Max.y = (g.NavMoveDir == ImGuiDir_Up) ? window->SizeFull.y : 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::EndPopup()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
|
||||
IM_ASSERT(GImGui->CurrentPopupStack.Size > 0);
|
||||
IM_ASSERT(g.CurrentPopupStack.Size > 0);
|
||||
|
||||
// Make all menus and popups wrap around for now, may need to expose that policy.
|
||||
NavProcessMoveRequestWrapAround(window);
|
||||
|
||||
End();
|
||||
if (!(window->Flags & ImGuiWindowFlags_Modal))
|
||||
PopStyleVar();
|
||||
|
|
|
@ -484,9 +484,9 @@ struct ImGuiContext
|
|||
bool NavInitDefaultResultExplicit; // Whether the result was explicitly requested with SetItemDefaultFocus()
|
||||
bool NavMoveFromClampedRefRect; // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items
|
||||
bool NavMoveRequest; // Move request for this frame
|
||||
int NavMoveRequestForwardStep; // 0: no forward, 1: forward request, 2: forward result
|
||||
ImGuiDir NavMoveDir; // West/East/North/South
|
||||
ImGuiDir NavMoveDirLast; //
|
||||
int NavMoveRequestForwardStep; // 0: no forward, 1: forward request, 2: forward result (this is used to navigate sibling parent menus from a child menu)
|
||||
ImGuiDir NavMoveDir; // Direction of the move request (left/right/up/down)
|
||||
ImGuiDir NavMoveDirLast; // Direction of the previous move request
|
||||
ImGuiID NavMoveResultId; // Best move request candidate
|
||||
ImGuiID NavMoveResultParentId; //
|
||||
float NavMoveResultDistBox; // Best move request candidate box distance to current NavId
|
||||
|
|
Loading…
Reference in New Issue