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.