1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-09-24 03:28:33 +02:00

Nav: SetItemDefaultFocus() doesn't make the navigation cursorr highlight visible. Renamed NavInitResultExplicit to NavInitRequestFromMove. (#787)

This commit is contained in:
omar 2018-02-05 23:53:40 +01:00
parent 4b49f03a40
commit 0c0d811859
3 changed files with 8 additions and 8 deletions

View File

@ -231,6 +231,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- font: (api breaking) removed "TTF" from symbol names. also because it now supports OTF.
- nav: integrate navigation branch into master. (#787)
- nav: allow input system to be be more tolerant of io.DeltaTime=0.0f
- nav: Left within a tree node block as a fallback.
- nav: Esc on a flattened child
- nav: menus: allow pressing Menu to leave a sub-menu.

View File

@ -2656,8 +2656,8 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
{
SetNavID(0, g.NavLayer);
g.NavInitRequest = true;
g.NavInitRequestFromMove = false;
g.NavInitResultId = 0;
g.NavInitResultExplicit = false;
g.NavInitResultRectRel = ImRect();
NavUpdateAnyRequestFlag();
}
@ -2929,18 +2929,18 @@ static void ImGui::NavUpdate()
#endif
// Process navigation init request (select first/default focus)
if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitResultExplicit))
if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove))
{
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
IM_ASSERT(g.NavWindow);
if (g.NavInitResultExplicit)
if (g.NavInitRequestFromMove)
SetNavIDAndMoveMouse(g.NavInitResultId, g.NavLayer, g.NavInitResultRectRel);
else
SetNavID(g.NavInitResultId, g.NavLayer);
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
}
g.NavInitRequest = false;
g.NavInitResultExplicit = false;
g.NavInitRequestFromMove = false;
g.NavInitResultId = 0;
g.NavJustMovedToId = 0;
@ -3098,7 +3098,7 @@ static void ImGui::NavUpdate()
// If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match
if (g.NavMoveRequest && g.NavId == 0)
{
g.NavInitRequest = g.NavInitResultExplicit = true;
g.NavInitRequest = g.NavInitRequestFromMove = true;
g.NavInitResultId = 0;
g.NavDisableHighlight = false;
}
@ -7147,7 +7147,6 @@ void ImGui::SetItemDefaultFocus()
if (g.NavWindow == window->NavRootWindow && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
{
g.NavInitRequest = false;
g.NavInitResultExplicit = true;
g.NavInitResultId = g.NavWindow->DC.LastItemId;
g.NavInitResultRectRel = ImRect(g.NavWindow->DC.LastItemRect.Min - g.NavWindow->Pos, g.NavWindow->DC.LastItemRect.Max - g.NavWindow->Pos);
NavUpdateAnyRequestFlag();

View File

@ -630,9 +630,9 @@ struct ImGuiContext
bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest
bool NavInitRequest; // Init request for appearing window to select first item
bool NavInitRequestFromMove;
ImGuiID NavInitResultId;
ImRect NavInitResultRectRel;
bool NavInitResultExplicit; // 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
ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
@ -747,8 +747,8 @@ struct ImGuiContext
NavDisableMouseHover = false;
NavAnyRequest = false;
NavInitRequest = false;
NavInitRequestFromMove = false;
NavInitResultId = 0;
NavInitResultExplicit = false;
NavMoveFromClampedRefRect = false;
NavMoveRequest = false;
NavMoveRequestForward = ImGuiNavForward_None;