|
@@ -2754,19 +2754,21 @@ void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window)
|
|
|
window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0;
|
|
window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void ImGui::SetNavID(ImGuiID id, int nav_layer)
|
|
|
|
|
|
|
+// FIXME-NAV: Refactor those functions into a single, more explicit one.
|
|
|
|
|
+void ImGui::SetNavID(ImGuiID id, int nav_layer, int focus_scope_id)
|
|
|
{
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
IM_ASSERT(g.NavWindow);
|
|
IM_ASSERT(g.NavWindow);
|
|
|
IM_ASSERT(nav_layer == 0 || nav_layer == 1);
|
|
IM_ASSERT(nav_layer == 0 || nav_layer == 1);
|
|
|
g.NavId = id;
|
|
g.NavId = id;
|
|
|
|
|
+ g.NavFocusScopeId = focus_scope_id;
|
|
|
g.NavWindow->NavLastIds[nav_layer] = id;
|
|
g.NavWindow->NavLastIds[nav_layer] = id;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel)
|
|
|
|
|
|
|
+void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, int focus_scope_id, const ImRect& rect_rel)
|
|
|
{
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
- SetNavID(id, nav_layer);
|
|
|
|
|
|
|
+ SetNavID(id, nav_layer, focus_scope_id);
|
|
|
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
|
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
|
|
g.NavMousePosDirty = true;
|
|
g.NavMousePosDirty = true;
|
|
|
g.NavDisableHighlight = false;
|
|
g.NavDisableHighlight = false;
|
|
@@ -2811,13 +2813,15 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
IM_ASSERT(id != 0);
|
|
IM_ASSERT(id != 0);
|
|
|
|
|
|
|
|
- // Assume that SetFocusID() is called in the context where its NavLayer is the current layer, which is the case everywhere we call it.
|
|
|
|
|
|
|
+ // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
|
|
|
|
|
+ // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
|
|
|
const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
|
const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
|
|
if (g.NavWindow != window)
|
|
if (g.NavWindow != window)
|
|
|
g.NavInitRequest = false;
|
|
g.NavInitRequest = false;
|
|
|
- g.NavId = id;
|
|
|
|
|
g.NavWindow = window;
|
|
g.NavWindow = window;
|
|
|
|
|
+ g.NavId = id;
|
|
|
g.NavLayer = nav_layer;
|
|
g.NavLayer = nav_layer;
|
|
|
|
|
+ g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
|
|
window->NavLastIds[nav_layer] = id;
|
|
window->NavLastIds[nav_layer] = id;
|
|
|
if (window->DC.LastItemId == id)
|
|
if (window->DC.LastItemId == id)
|
|
|
window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
|
|
window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
|
|
@@ -3082,24 +3086,24 @@ bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id)
|
|
|
|
|
|
|
|
// Increment counters
|
|
// Increment counters
|
|
|
const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0;
|
|
const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0;
|
|
|
- window->DC.FocusCounterAll++;
|
|
|
|
|
|
|
+ window->DC.FocusCounterRegular++;
|
|
|
if (is_tab_stop)
|
|
if (is_tab_stop)
|
|
|
- window->DC.FocusCounterTab++;
|
|
|
|
|
|
|
+ window->DC.FocusCounterTabStop++;
|
|
|
|
|
|
|
|
// Process TAB/Shift-TAB to tab *OUT* of the currently focused item.
|
|
// Process TAB/Shift-TAB to tab *OUT* of the currently focused item.
|
|
|
// (Note that we can always TAB out of a widget that doesn't allow tabbing in)
|
|
// (Note that we can always TAB out of a widget that doesn't allow tabbing in)
|
|
|
if (g.ActiveId == id && g.FocusTabPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.FocusRequestNextWindow == NULL)
|
|
if (g.ActiveId == id && g.FocusTabPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.FocusRequestNextWindow == NULL)
|
|
|
{
|
|
{
|
|
|
g.FocusRequestNextWindow = window;
|
|
g.FocusRequestNextWindow = window;
|
|
|
- g.FocusRequestNextCounterTab = window->DC.FocusCounterTab + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
|
|
|
|
|
|
|
+ g.FocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Handle focus requests
|
|
// Handle focus requests
|
|
|
if (g.FocusRequestCurrWindow == window)
|
|
if (g.FocusRequestCurrWindow == window)
|
|
|
{
|
|
{
|
|
|
- if (window->DC.FocusCounterAll == g.FocusRequestCurrCounterAll)
|
|
|
|
|
|
|
+ if (window->DC.FocusCounterRegular == g.FocusRequestCurrCounterRegular)
|
|
|
return true;
|
|
return true;
|
|
|
- if (is_tab_stop && window->DC.FocusCounterTab == g.FocusRequestCurrCounterTab)
|
|
|
|
|
|
|
+ if (is_tab_stop && window->DC.FocusCounterTabStop == g.FocusRequestCurrCounterTabStop)
|
|
|
{
|
|
{
|
|
|
g.NavJustTabbedId = id;
|
|
g.NavJustTabbedId = id;
|
|
|
return true;
|
|
return true;
|
|
@@ -3115,8 +3119,8 @@ bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id)
|
|
|
|
|
|
|
|
void ImGui::FocusableItemUnregister(ImGuiWindow* window)
|
|
void ImGui::FocusableItemUnregister(ImGuiWindow* window)
|
|
|
{
|
|
{
|
|
|
- window->DC.FocusCounterAll--;
|
|
|
|
|
- window->DC.FocusCounterTab--;
|
|
|
|
|
|
|
+ window->DC.FocusCounterRegular--;
|
|
|
|
|
+ window->DC.FocusCounterTabStop--;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
|
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
|
@@ -3769,26 +3773,26 @@ void ImGui::NewFrame()
|
|
|
// Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also
|
|
// Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also
|
|
|
// manipulate the Next fields even, even though they will be turned into Curr fields by the code below.
|
|
// manipulate the Next fields even, even though they will be turned into Curr fields by the code below.
|
|
|
g.FocusRequestNextWindow = g.NavWindow;
|
|
g.FocusRequestNextWindow = g.NavWindow;
|
|
|
- g.FocusRequestNextCounterAll = INT_MAX;
|
|
|
|
|
|
|
+ g.FocusRequestNextCounterRegular = INT_MAX;
|
|
|
if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
|
|
if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
|
|
|
- g.FocusRequestNextCounterTab = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
|
|
|
|
|
|
|
+ g.FocusRequestNextCounterTabStop = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
|
|
|
else
|
|
else
|
|
|
- g.FocusRequestNextCounterTab = g.IO.KeyShift ? -1 : 0;
|
|
|
|
|
|
|
+ g.FocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Turn queued focus request into current one
|
|
// Turn queued focus request into current one
|
|
|
g.FocusRequestCurrWindow = NULL;
|
|
g.FocusRequestCurrWindow = NULL;
|
|
|
- g.FocusRequestCurrCounterAll = g.FocusRequestCurrCounterTab = INT_MAX;
|
|
|
|
|
|
|
+ g.FocusRequestCurrCounterRegular = g.FocusRequestCurrCounterTabStop = INT_MAX;
|
|
|
if (g.FocusRequestNextWindow != NULL)
|
|
if (g.FocusRequestNextWindow != NULL)
|
|
|
{
|
|
{
|
|
|
ImGuiWindow* window = g.FocusRequestNextWindow;
|
|
ImGuiWindow* window = g.FocusRequestNextWindow;
|
|
|
g.FocusRequestCurrWindow = window;
|
|
g.FocusRequestCurrWindow = window;
|
|
|
- if (g.FocusRequestNextCounterAll != INT_MAX && window->DC.FocusCounterAll != -1)
|
|
|
|
|
- g.FocusRequestCurrCounterAll = ImModPositive(g.FocusRequestNextCounterAll, window->DC.FocusCounterAll + 1);
|
|
|
|
|
- if (g.FocusRequestNextCounterTab != INT_MAX && window->DC.FocusCounterTab != -1)
|
|
|
|
|
- g.FocusRequestCurrCounterTab = ImModPositive(g.FocusRequestNextCounterTab, window->DC.FocusCounterTab + 1);
|
|
|
|
|
|
|
+ if (g.FocusRequestNextCounterRegular != INT_MAX && window->DC.FocusCounterRegular != -1)
|
|
|
|
|
+ g.FocusRequestCurrCounterRegular = ImModPositive(g.FocusRequestNextCounterRegular, window->DC.FocusCounterRegular + 1);
|
|
|
|
|
+ if (g.FocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1)
|
|
|
|
|
+ g.FocusRequestCurrCounterTabStop = ImModPositive(g.FocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1);
|
|
|
g.FocusRequestNextWindow = NULL;
|
|
g.FocusRequestNextWindow = NULL;
|
|
|
- g.FocusRequestNextCounterAll = g.FocusRequestNextCounterTab = INT_MAX;
|
|
|
|
|
|
|
+ g.FocusRequestNextCounterRegular = g.FocusRequestNextCounterTabStop = INT_MAX;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
g.NavIdTabCounter = INT_MAX;
|
|
g.NavIdTabCounter = INT_MAX;
|
|
@@ -5535,8 +5539,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->WindowPadding = style.WindowPadding;
|
|
window->WindowPadding = style.WindowPadding;
|
|
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
|
|
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
|
|
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
|
|
|
- window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
|
|
|
|
- window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
|
|
|
|
|
|
|
|
|
// Collapse window by double-clicking on title bar
|
|
// Collapse window by double-clicking on title bar
|
|
|
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
|
|
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
|
|
@@ -5844,27 +5846,35 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->DC.CursorMaxPos = window->DC.CursorStartPos;
|
|
window->DC.CursorMaxPos = window->DC.CursorStartPos;
|
|
|
window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f);
|
|
window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f);
|
|
|
window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f;
|
|
window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f;
|
|
|
- window->DC.NavHideHighlightOneFrame = false;
|
|
|
|
|
- window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
|
|
|
|
+ window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
|
|
|
window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext;
|
|
window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext;
|
|
|
window->DC.NavLayerActiveMaskNext = 0x00;
|
|
window->DC.NavLayerActiveMaskNext = 0x00;
|
|
|
|
|
+ window->DC.NavFocusScopeIdCurrent = 0;
|
|
|
|
|
+ window->DC.NavHideHighlightOneFrame = false;
|
|
|
|
|
+ window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f);
|
|
|
|
|
+
|
|
|
window->DC.MenuBarAppending = false;
|
|
window->DC.MenuBarAppending = false;
|
|
|
|
|
+ window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
|
|
|
|
+ window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
|
|
|
|
+ window->DC.MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
|
|
|
|
|
+ window->DC.TreeDepth = 0;
|
|
|
|
|
+ window->DC.TreeJumpToParentOnPopMask = 0x00;
|
|
|
window->DC.ChildWindows.resize(0);
|
|
window->DC.ChildWindows.resize(0);
|
|
|
|
|
+ window->DC.StateStorage = &window->StateStorage;
|
|
|
|
|
+ window->DC.CurrentColumns = NULL;
|
|
|
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
|
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
|
|
window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical;
|
|
window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical;
|
|
|
- window->DC.FocusCounterAll = window->DC.FocusCounterTab = -1;
|
|
|
|
|
|
|
+ window->DC.FocusCounterRegular = window->DC.FocusCounterTabStop = -1;
|
|
|
|
|
+
|
|
|
window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_;
|
|
window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_;
|
|
|
window->DC.ItemWidth = window->ItemWidthDefault;
|
|
window->DC.ItemWidth = window->ItemWidthDefault;
|
|
|
window->DC.TextWrapPos = -1.0f; // disabled
|
|
window->DC.TextWrapPos = -1.0f; // disabled
|
|
|
window->DC.ItemFlagsStack.resize(0);
|
|
window->DC.ItemFlagsStack.resize(0);
|
|
|
window->DC.ItemWidthStack.resize(0);
|
|
window->DC.ItemWidthStack.resize(0);
|
|
|
window->DC.TextWrapPosStack.resize(0);
|
|
window->DC.TextWrapPosStack.resize(0);
|
|
|
- window->DC.CurrentColumns = NULL;
|
|
|
|
|
- window->DC.TreeDepth = 0;
|
|
|
|
|
- window->DC.TreeJumpToParentOnPopMask = 0x00;
|
|
|
|
|
- window->DC.StateStorage = &window->StateStorage;
|
|
|
|
|
window->DC.GroupStack.resize(0);
|
|
window->DC.GroupStack.resize(0);
|
|
|
- window->MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
|
|
|
|
|
|
|
|
|
|
if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags))
|
|
if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags))
|
|
|
{
|
|
{
|
|
@@ -6044,6 +6054,7 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|
|
g.NavMousePosDirty = true;
|
|
g.NavMousePosDirty = true;
|
|
|
g.NavInitRequest = false;
|
|
g.NavInitRequest = false;
|
|
|
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
|
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
|
|
|
|
+ g.NavFocusScopeId = 0;
|
|
|
g.NavIdIsAlive = false;
|
|
g.NavIdIsAlive = false;
|
|
|
g.NavLayer = ImGuiNavLayer_Main;
|
|
g.NavLayer = ImGuiNavLayer_Main;
|
|
|
//IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
|
|
//IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
|
|
@@ -6900,14 +6911,30 @@ void ImGui::ActivateItem(ImGuiID id)
|
|
|
g.NavNextActivateId = id;
|
|
g.NavNextActivateId = id;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void ImGui::PushFocusScope(ImGuiID id)
|
|
|
|
|
+{
|
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
|
+ ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
+ window->IDStack.push_back(window->DC.NavFocusScopeIdCurrent);
|
|
|
|
|
+ window->DC.NavFocusScopeIdCurrent = id;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void ImGui::PopFocusScope()
|
|
|
|
|
+{
|
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
|
+ ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
+ window->DC.NavFocusScopeIdCurrent = window->IDStack.back();
|
|
|
|
|
+ window->IDStack.pop_back();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void ImGui::SetKeyboardFocusHere(int offset)
|
|
void ImGui::SetKeyboardFocusHere(int offset)
|
|
|
{
|
|
{
|
|
|
IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
|
IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
g.FocusRequestNextWindow = window;
|
|
g.FocusRequestNextWindow = window;
|
|
|
- g.FocusRequestNextCounterAll = window->DC.FocusCounterAll + 1 + offset;
|
|
|
|
|
- g.FocusRequestNextCounterTab = INT_MAX;
|
|
|
|
|
|
|
+ g.FocusRequestNextCounterRegular = window->DC.FocusCounterRegular + 1 + offset;
|
|
|
|
|
+ g.FocusRequestNextCounterTabStop = INT_MAX;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ImGui::SetItemDefaultFocus()
|
|
void ImGui::SetItemDefaultFocus()
|
|
@@ -8036,21 +8063,22 @@ static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, con
|
|
|
#endif
|
|
#endif
|
|
|
if (new_best)
|
|
if (new_best)
|
|
|
{
|
|
{
|
|
|
- result->ID = id;
|
|
|
|
|
- result->SelectScopeId = g.MultiSelectScopeId;
|
|
|
|
|
result->Window = window;
|
|
result->Window = window;
|
|
|
|
|
+ result->ID = id;
|
|
|
|
|
+ result->FocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
|
|
result->RectRel = nav_bb_rel;
|
|
result->RectRel = nav_bb_rel;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
|
|
|
const float VISIBLE_RATIO = 0.70f;
|
|
const float VISIBLE_RATIO = 0.70f;
|
|
|
if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
|
|
if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
|
|
|
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
|
|
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
|
|
|
if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
|
|
if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
|
|
|
{
|
|
{
|
|
|
result = &g.NavMoveResultLocalVisibleSet;
|
|
result = &g.NavMoveResultLocalVisibleSet;
|
|
|
- result->ID = id;
|
|
|
|
|
- result->SelectScopeId = g.MultiSelectScopeId;
|
|
|
|
|
result->Window = window;
|
|
result->Window = window;
|
|
|
|
|
+ result->ID = id;
|
|
|
|
|
+ result->FocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
|
|
result->RectRel = nav_bb_rel;
|
|
result->RectRel = nav_bb_rel;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -8060,8 +8088,9 @@ static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, con
|
|
|
{
|
|
{
|
|
|
g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window.
|
|
g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window.
|
|
|
g.NavLayer = window->DC.NavLayerCurrent;
|
|
g.NavLayer = window->DC.NavLayerCurrent;
|
|
|
|
|
+ g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
|
|
g.NavIdIsAlive = true;
|
|
g.NavIdIsAlive = true;
|
|
|
- g.NavIdTabCounter = window->DC.FocusCounterTab;
|
|
|
|
|
|
|
+ g.NavIdTabCounter = window->DC.FocusCounterTabStop;
|
|
|
window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position)
|
|
window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -8150,10 +8179,11 @@ static void NavRestoreLayer(ImGuiNavLayer layer)
|
|
|
g.NavLayer = layer;
|
|
g.NavLayer = layer;
|
|
|
if (layer == 0)
|
|
if (layer == 0)
|
|
|
g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow);
|
|
g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow);
|
|
|
- if (layer == 0 && g.NavWindow->NavLastIds[0] != 0)
|
|
|
|
|
- ImGui::SetNavIDWithRectRel(g.NavWindow->NavLastIds[0], layer, g.NavWindow->NavRectRel[0]);
|
|
|
|
|
|
|
+ ImGuiWindow* window = g.NavWindow;
|
|
|
|
|
+ if (layer == 0 && window->NavLastIds[0] != 0)
|
|
|
|
|
+ ImGui::SetNavIDWithRectRel(window->NavLastIds[0], layer, 0, window->NavRectRel[0]);
|
|
|
else
|
|
else
|
|
|
- ImGui::NavInitWindow(g.NavWindow, true);
|
|
|
|
|
|
|
+ ImGui::NavInitWindow(window, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static inline void ImGui::NavUpdateAnyRequestFlag()
|
|
static inline void ImGui::NavUpdateAnyRequestFlag()
|
|
@@ -8176,7 +8206,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|
|
//IMGUI_DEBUG_LOG("[Nav] NavInitWindow() init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer);
|
|
//IMGUI_DEBUG_LOG("[Nav] NavInitWindow() init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer);
|
|
|
if (init_for_nav)
|
|
if (init_for_nav)
|
|
|
{
|
|
{
|
|
|
- SetNavID(0, g.NavLayer);
|
|
|
|
|
|
|
+ SetNavID(0, g.NavLayer, 0);
|
|
|
g.NavInitRequest = true;
|
|
g.NavInitRequest = true;
|
|
|
g.NavInitRequestFromMove = false;
|
|
g.NavInitRequestFromMove = false;
|
|
|
g.NavInitResultId = 0;
|
|
g.NavInitResultId = 0;
|
|
@@ -8186,6 +8216,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
g.NavId = window->NavLastIds[0];
|
|
g.NavId = window->NavLastIds[0];
|
|
|
|
|
+ g.NavFocusScopeId = 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -8292,9 +8323,9 @@ static void ImGui::NavUpdate()
|
|
|
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
|
|
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
|
|
|
//IMGUI_DEBUG_LOG("[Nav] Apply NavInitRequest result: 0x%08X Layer %d in \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
|
|
//IMGUI_DEBUG_LOG("[Nav] Apply NavInitRequest result: 0x%08X Layer %d in \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
|
|
|
if (g.NavInitRequestFromMove)
|
|
if (g.NavInitRequestFromMove)
|
|
|
- SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, g.NavInitResultRectRel);
|
|
|
|
|
|
|
+ SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel);
|
|
|
else
|
|
else
|
|
|
- SetNavID(g.NavInitResultId, g.NavLayer);
|
|
|
|
|
|
|
+ SetNavID(g.NavInitResultId, g.NavLayer, 0);
|
|
|
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
|
|
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
|
|
|
}
|
|
}
|
|
|
g.NavInitRequest = false;
|
|
g.NavInitRequest = false;
|
|
@@ -8361,7 +8392,7 @@ static void ImGui::NavUpdate()
|
|
|
ImGuiWindow* parent_window = g.NavWindow->ParentWindow;
|
|
ImGuiWindow* parent_window = g.NavWindow->ParentWindow;
|
|
|
IM_ASSERT(child_window->ChildId != 0);
|
|
IM_ASSERT(child_window->ChildId != 0);
|
|
|
FocusWindow(parent_window);
|
|
FocusWindow(parent_window);
|
|
|
- SetNavID(child_window->ChildId, 0);
|
|
|
|
|
|
|
+ SetNavID(child_window->ChildId, 0, 0);
|
|
|
// Reassigning with same value, we're being explicit here.
|
|
// Reassigning with same value, we're being explicit here.
|
|
|
g.NavIdIsAlive = false; // -V1048
|
|
g.NavIdIsAlive = false; // -V1048
|
|
|
if (g.NavDisableMouseHover)
|
|
if (g.NavDisableMouseHover)
|
|
@@ -8383,7 +8414,7 @@ static void ImGui::NavUpdate()
|
|
|
// Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
|
|
// Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
|
|
|
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
|
|
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
|
|
|
g.NavWindow->NavLastIds[0] = 0;
|
|
g.NavWindow->NavLastIds[0] = 0;
|
|
|
- g.NavId = 0;
|
|
|
|
|
|
|
+ g.NavId = g.NavFocusScopeId = 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -8503,7 +8534,7 @@ static void ImGui::NavUpdate()
|
|
|
float pad = window->CalcFontSize() * 0.5f;
|
|
float pad = window->CalcFontSize() * 0.5f;
|
|
|
window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item
|
|
window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item
|
|
|
window->NavRectRel[g.NavLayer].ClipWith(window_rect_rel);
|
|
window->NavRectRel[g.NavLayer].ClipWith(window_rect_rel);
|
|
|
- g.NavId = 0;
|
|
|
|
|
|
|
+ g.NavId = g.NavFocusScopeId = 0;
|
|
|
}
|
|
}
|
|
|
g.NavMoveFromClampedRefRect = false;
|
|
g.NavMoveFromClampedRefRect = false;
|
|
|
}
|
|
}
|
|
@@ -8583,9 +8614,10 @@ static void ImGui::NavUpdateMoveResult()
|
|
|
{
|
|
{
|
|
|
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
|
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
|
|
g.NavJustMovedToId = result->ID;
|
|
g.NavJustMovedToId = result->ID;
|
|
|
- g.NavJustMovedToMultiSelectScopeId = result->SelectScopeId;
|
|
|
|
|
|
|
+ g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- SetNavIDWithRectRel(result->ID, g.NavLayer, result->RectRel);
|
|
|
|
|
|
|
+ SetNavIDWithRectRel(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
|
|
|
g.NavMoveFromClampedRefRect = false;
|
|
g.NavMoveFromClampedRefRect = false;
|
|
|
}
|
|
}
|
|
|
|
|
|