1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Internals: add window to FocusScopeStack. (#6798)

This commit is contained in:
ocornut 2024-01-15 11:44:21 +01:00
parent 2156db7a07
commit 4b20a0217e
2 changed files with 30 additions and 17 deletions

View File

@ -3075,7 +3075,7 @@ void ImGui::PopStyleColor(int count)
ImGuiContext& g = *GImGui;
if (g.ColorStack.Size < count)
{
IM_ASSERT_USER_ERROR(g.ColorStack.Size > count, "Calling PopStyleColor() too many times: stack underflow.");
IM_ASSERT_USER_ERROR(g.ColorStack.Size > count, "Calling PopStyleColor() too many times!");
count = g.ColorStack.Size;
}
while (count > 0)
@ -3138,7 +3138,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
*pvar = val;
return;
}
IM_ASSERT_USER_ERROR(0, "Called PushStyleVar() variant with wrong type!");
IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
}
void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
@ -3152,7 +3152,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
*pvar = val;
return;
}
IM_ASSERT_USER_ERROR(0, "Called PushStyleVar() variant with wrong type!");
IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
}
void ImGui::PopStyleVar(int count)
@ -3160,7 +3160,7 @@ void ImGui::PopStyleVar(int count)
ImGuiContext& g = *GImGui;
if (g.StyleVarStack.Size < count)
{
IM_ASSERT_USER_ERROR(g.StyleVarStack.Size > count, "Calling PopStyleVar() too many times: stack underflow.");
IM_ASSERT_USER_ERROR(g.StyleVarStack.Size > count, "Calling PopStyleVar() too many times!");
count = g.StyleVarStack.Size;
}
while (count > 0)
@ -7798,16 +7798,23 @@ void ImGui::SetWindowFontScale(float scale)
void ImGui::PushFocusScope(ImGuiID id)
{
ImGuiContext& g = *GImGui;
g.FocusScopeStack.push_back(id);
ImGuiFocusScopeData data;
data.ID = id;
data.WindowID = g.CurrentWindow->ID;
g.FocusScopeStack.push_back(data);
g.CurrentFocusScopeId = id;
}
void ImGui::PopFocusScope()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.FocusScopeStack.Size > 0); // Too many PopFocusScope() ?
if (g.FocusScopeStack.Size == 0)
{
IM_ASSERT_USER_ERROR(g.FocusScopeStack.Size > 0, "Calling PopFocusScope() too many times!");
return;
}
g.FocusScopeStack.pop_back();
g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back() : 0;
g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back().ID : 0;
}
// Focus = move navigation cursor, set scrolling, set focus window.

View File

@ -1571,6 +1571,12 @@ struct ImGuiNavItemData
void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; SelectionUserData = -1; DistBox = DistCenter = DistAxial = FLT_MAX; }
};
struct ImGuiFocusScopeData
{
ImGuiID ID;
ImGuiID WindowID;
};
//-----------------------------------------------------------------------------
// [SECTION] Typing-select support
//-----------------------------------------------------------------------------
@ -1977,16 +1983,16 @@ struct ImGuiContext
bool DebugShowGroupRects;
// Shared stacks
ImGuiCol DebugFlashStyleColorIdx; // (Keep close to ColorStack to share cache line)
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
ImVector<ImGuiID> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
ImVector<ImGuiItemFlags> ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
ImVector<ImGuiGroupData> GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
ImVector<ImGuiPopupData> OpenPopupStack; // Which popups are open (persistent)
ImVector<ImGuiPopupData> BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
ImVector<ImGuiNavTreeNodeData> NavTreeNodeStack; // Stack for TreeNode() when a NavLeft requested is emitted.
ImGuiCol DebugFlashStyleColorIdx; // (Keep close to ColorStack to share cache line)
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
ImVector<ImGuiFocusScopeData> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
ImVector<ImGuiItemFlags> ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
ImVector<ImGuiGroupData> GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
ImVector<ImGuiPopupData> OpenPopupStack; // Which popups are open (persistent)
ImVector<ImGuiPopupData> BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
ImVector<ImGuiNavTreeNodeData> NavTreeNodeStack; // Stack for TreeNode() when a NavLeft requested is emitted.
int BeginMenuCount;