mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Nav: Renaming NavInitDefaultRequest -> NavInitRequest
This commit is contained in:
parent
4d83078885
commit
69dd895358
52
imgui.cpp
52
imgui.cpp
@ -2174,7 +2174,7 @@ static bool NavScoreItem(ImRect cand)
|
|||||||
static inline void NavUpdateAnyRequestFlag()
|
static inline void NavUpdateAnyRequestFlag()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
g.NavAnyRequest = g.NavMoveRequest || g.NavInitDefaultRequest || IMGUI_DEBUG_NAV;
|
g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || IMGUI_DEBUG_NAV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NavMoveRequestCancel()
|
static void NavMoveRequestCancel()
|
||||||
@ -2191,18 +2191,18 @@ static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGu
|
|||||||
// return;
|
// return;
|
||||||
const ImGuiItemFlags item_flags = window->DC.ItemFlags;
|
const ImGuiItemFlags item_flags = window->DC.ItemFlags;
|
||||||
const ImRect nav_bb_rel(nav_bb.Min - g.NavWindow->Pos, nav_bb.Max - g.NavWindow->Pos);
|
const ImRect nav_bb_rel(nav_bb.Min - g.NavWindow->Pos, nav_bb.Max - g.NavWindow->Pos);
|
||||||
if (g.NavInitDefaultRequest && g.NavLayer == window->DC.NavLayerCurrent)
|
if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent)
|
||||||
{
|
{
|
||||||
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
|
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
|
||||||
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
||||||
{
|
{
|
||||||
g.NavInitDefaultRequest = g.NavInitDefaultResultExplicit = false; // Found a match, clear request
|
g.NavInitRequest = g.NavInitResultExplicit = false; // Found a match, clear request
|
||||||
NavUpdateAnyRequestFlag();
|
NavUpdateAnyRequestFlag();
|
||||||
}
|
}
|
||||||
if (g.NavInitDefaultResultId == 0 || !(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
if (g.NavInitResultId == 0 || !(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
|
||||||
{
|
{
|
||||||
g.NavInitDefaultResultId = id;
|
g.NavInitResultId = id;
|
||||||
g.NavInitDefaultResultRectRel = nav_bb_rel;
|
g.NavInitResultRectRel = nav_bb_rel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2245,10 +2245,10 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
|
|||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
// Navigation processing runs prior to clipping early-out
|
// Navigation processing runs prior to clipping early-out
|
||||||
// (a) So that NavInitDefaultRequest can be honored, for newly opened windows to select a default widget
|
// (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
|
||||||
// (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window.
|
// (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window.
|
||||||
// it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
|
// it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
|
||||||
// We could early out with `if (is_clipped && !g.NavInitDefaultRequest) return false;` but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
|
// We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
|
||||||
window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
|
window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
|
||||||
if (g.NavWindow == window->RootNavWindow)
|
if (g.NavWindow == window->RootNavWindow)
|
||||||
if (g.NavId == id || g.NavAnyRequest)
|
if (g.NavId == id || g.NavAnyRequest)
|
||||||
@ -2511,10 +2511,10 @@ static void NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|||||||
if (init_for_nav)
|
if (init_for_nav)
|
||||||
{
|
{
|
||||||
SetNavId(0, g.NavLayer);
|
SetNavId(0, g.NavLayer);
|
||||||
g.NavInitDefaultRequest = true;
|
g.NavInitRequest = true;
|
||||||
g.NavInitDefaultResultId = 0;
|
g.NavInitResultId = 0;
|
||||||
g.NavInitDefaultResultExplicit = false;
|
g.NavInitResultExplicit = false;
|
||||||
g.NavInitDefaultResultRectRel = ImRect();
|
g.NavInitResultRectRel = ImRect();
|
||||||
NavUpdateAnyRequestFlag();
|
NavUpdateAnyRequestFlag();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2616,18 +2616,18 @@ static void NavUpdate()
|
|||||||
g.IO.WantMoveMouse = false;
|
g.IO.WantMoveMouse = false;
|
||||||
|
|
||||||
// Process navigation init request (select first/default focus)
|
// Process navigation init request (select first/default focus)
|
||||||
if (g.NavInitDefaultResultId != 0 && (!g.NavDisableHighlight || g.NavInitDefaultResultExplicit))
|
if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitResultExplicit))
|
||||||
{
|
{
|
||||||
// Apply result from previous navigation init request (typically select the first item, unless SetItemDefaultFocus() has been called)
|
// Apply result from previous navigation init request (typically select the first item, unless SetItemDefaultFocus() has been called)
|
||||||
IM_ASSERT(g.NavWindow);
|
IM_ASSERT(g.NavWindow);
|
||||||
SetNavId(g.NavInitDefaultResultId, g.NavLayer);
|
SetNavId(g.NavInitResultId, g.NavLayer);
|
||||||
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitDefaultResultRectRel;
|
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
|
||||||
if (g.NavDisableMouseHover)
|
if (g.NavDisableMouseHover)
|
||||||
g.NavMousePosDirty = true;
|
g.NavMousePosDirty = true;
|
||||||
}
|
}
|
||||||
g.NavInitDefaultRequest = false;
|
g.NavInitRequest = false;
|
||||||
g.NavInitDefaultResultExplicit = false;
|
g.NavInitResultExplicit = false;
|
||||||
g.NavInitDefaultResultId = 0;
|
g.NavInitResultId = 0;
|
||||||
g.NavJustNavigatedId = 0;
|
g.NavJustNavigatedId = 0;
|
||||||
|
|
||||||
// Process navigation move request
|
// Process navigation move request
|
||||||
@ -2775,7 +2775,7 @@ static void NavUpdate()
|
|||||||
|
|
||||||
// Set output flags for user application
|
// Set output flags for user application
|
||||||
g.IO.NavUsable = g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
|
g.IO.NavUsable = g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
|
||||||
g.IO.NavActive = (g.IO.NavUsable && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL) || g.NavInitDefaultRequest;
|
g.IO.NavActive = (g.IO.NavUsable && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL) || g.NavInitRequest;
|
||||||
|
|
||||||
// Process NavCancel input (to close a popup, get back to parent, clear focus)
|
// Process NavCancel input (to close a popup, get back to parent, clear focus)
|
||||||
if (IsNavInputPressed(ImGuiNavInput_PadCancel, ImGuiNavReadMode_Pressed))
|
if (IsNavInputPressed(ImGuiNavInput_PadCancel, ImGuiNavReadMode_Pressed))
|
||||||
@ -2872,8 +2872,8 @@ static void 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 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)
|
if (g.NavMoveRequest && g.NavId == 0)
|
||||||
{
|
{
|
||||||
g.NavInitDefaultRequest = g.NavInitDefaultResultExplicit = true;
|
g.NavInitRequest = g.NavInitResultExplicit = true;
|
||||||
g.NavInitDefaultResultId = 0;
|
g.NavInitResultId = 0;
|
||||||
g.NavDisableHighlight = false;
|
g.NavDisableHighlight = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6429,12 +6429,12 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
|||||||
void ImGui::SetItemDefaultFocus()
|
void ImGui::SetItemDefaultFocus()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.NavWindow == g.CurrentWindow->RootNavWindow && (g.NavInitDefaultRequest || g.NavInitDefaultResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
|
if (g.NavWindow == g.CurrentWindow->RootNavWindow && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
|
||||||
{
|
{
|
||||||
g.NavInitDefaultRequest = false;
|
g.NavInitRequest = false;
|
||||||
g.NavInitDefaultResultExplicit = true;
|
g.NavInitResultExplicit = true;
|
||||||
g.NavInitDefaultResultId = g.NavWindow->DC.LastItemId;
|
g.NavInitResultId = g.NavWindow->DC.LastItemId;
|
||||||
g.NavInitDefaultResultRectRel = ImRect(g.NavWindow->DC.LastItemRect.Min - g.NavWindow->Pos, g.NavWindow->DC.LastItemRect.Max - g.NavWindow->Pos);
|
g.NavInitResultRectRel = ImRect(g.NavWindow->DC.LastItemRect.Min - g.NavWindow->Pos, g.NavWindow->DC.LastItemRect.Max - g.NavWindow->Pos);
|
||||||
NavUpdateAnyRequestFlag();
|
NavUpdateAnyRequestFlag();
|
||||||
if (!IsItemVisible())
|
if (!IsItemVisible())
|
||||||
SetScrollHere();
|
SetScrollHere();
|
||||||
|
@ -480,11 +480,11 @@ struct ImGuiContext
|
|||||||
bool NavMousePosDirty;
|
bool NavMousePosDirty;
|
||||||
bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (nb: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
|
bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (nb: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
|
||||||
bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
|
bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
|
||||||
bool NavAnyRequest; // ~~ NavMoveRequest || NavInitDefaultRequest
|
bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest
|
||||||
bool NavInitDefaultRequest; // Init request for appearing window to select first item
|
bool NavInitRequest; // Init request for appearing window to select first item
|
||||||
ImGuiID NavInitDefaultResultId;
|
ImGuiID NavInitResultId;
|
||||||
ImRect NavInitDefaultResultRectRel;
|
ImRect NavInitResultRectRel;
|
||||||
bool NavInitDefaultResultExplicit; // Whether the result was explicitly requested with SetItemDefaultFocus()
|
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 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
|
bool NavMoveRequest; // Move request for this frame
|
||||||
int NavMoveRequestForwardStep; // 0: no forward, 1: forward request, 2: forward result (this is used to navigate sibling parent menus from a child menu)
|
int NavMoveRequestForwardStep; // 0: no forward, 1: forward request, 2: forward result (this is used to navigate sibling parent menus from a child menu)
|
||||||
@ -598,9 +598,9 @@ struct ImGuiContext
|
|||||||
NavDisableHighlight = true;
|
NavDisableHighlight = true;
|
||||||
NavDisableMouseHover = false;
|
NavDisableMouseHover = false;
|
||||||
NavAnyRequest = false;
|
NavAnyRequest = false;
|
||||||
NavInitDefaultRequest = false;
|
NavInitRequest = false;
|
||||||
NavInitDefaultResultId = 0;
|
NavInitResultId = 0;
|
||||||
NavInitDefaultResultExplicit = false;
|
NavInitResultExplicit = false;
|
||||||
NavMoveFromClampedRefRect = false;
|
NavMoveFromClampedRefRect = false;
|
||||||
NavMoveRequest = false;
|
NavMoveRequest = false;
|
||||||
NavMoveRequestForwardStep = 0;
|
NavMoveRequestForwardStep = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user