From 0c0d811859aeede5d0dca5d3d7e5026b8d5ee5a8 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 5 Feb 2018 23:53:40 +0100 Subject: [PATCH] Nav: SetItemDefaultFocus() doesn't make the navigation cursorr highlight visible. Renamed NavInitResultExplicit to NavInitRequestFromMove. (#787) --- TODO.txt | 1 + imgui.cpp | 11 +++++------ imgui_internal.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TODO.txt b/TODO.txt index 6f6ab7cc3..fe9b6ccec 100644 --- a/TODO.txt +++ b/TODO.txt @@ -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. diff --git a/imgui.cpp b/imgui.cpp index bb78b9a5f..a63073b95 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -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(); diff --git a/imgui_internal.h b/imgui_internal.h index 785b68079..d2183b92b 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -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;