mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-24 16:46:36 +00:00
window->RootWindow persist across frames. Fix calling SetWindowFocus(const char* name) on a child window (last fix for #147)
This commit is contained in:
parent
4535644fcb
commit
f18febca11
@ -1845,13 +1845,11 @@ void ImGui::NewFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark all windows as not visible
|
// Mark all windows as not visible
|
||||||
// Clear root windows at this point.
|
|
||||||
for (size_t i = 0; i != g.Windows.size(); i++)
|
for (size_t i = 0; i != g.Windows.size(); i++)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[i];
|
ImGuiWindow* window = g.Windows[i];
|
||||||
window->Visible = false;
|
window->Visible = false;
|
||||||
window->Accessed = false;
|
window->Accessed = false;
|
||||||
window->RootWindow = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No window should be open at the beginning of the frame.
|
// No window should be open at the beginning of the frame.
|
||||||
@ -2727,7 +2725,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
|
|||||||
// Find parent
|
// Find parent
|
||||||
ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL;
|
ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL;
|
||||||
|
|
||||||
// Find root (if we are a child window)
|
// Update known root window (if we are a child window, otherwise window == window->RootWindow)
|
||||||
size_t root_idx = g.CurrentWindowStack.size() - 1;
|
size_t root_idx = g.CurrentWindowStack.size() - 1;
|
||||||
while (root_idx > 0)
|
while (root_idx > 0)
|
||||||
{
|
{
|
||||||
@ -3128,7 +3126,7 @@ void ImGui::End()
|
|||||||
ImGui::LogFinish();
|
ImGui::LogFinish();
|
||||||
|
|
||||||
// Pop
|
// Pop
|
||||||
// NB: we don't clear 'window->RootWindow' yet, it will be used then cleared in NewFrame()
|
// NB: we don't clear 'window->RootWindow'. The pointer is allowed to live until the next call to Begin().
|
||||||
g.CurrentWindowStack.pop_back();
|
g.CurrentWindowStack.pop_back();
|
||||||
g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
|
g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
|
||||||
}
|
}
|
||||||
@ -3142,7 +3140,6 @@ static void FocusWindow(ImGuiWindow* window)
|
|||||||
g.FocusedWindow = window;
|
g.FocusedWindow = window;
|
||||||
|
|
||||||
// And move its root window to the top of the pile
|
// And move its root window to the top of the pile
|
||||||
// FIXME: RootWindow is set as we do Begin() on the window, so this won't work if called SetWindowFocus(const char* name) on a child window prior to window calling Begin(). Bit of an edge.
|
|
||||||
if (window->RootWindow)
|
if (window->RootWindow)
|
||||||
window = window->RootWindow;
|
window = window->RootWindow;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user