mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Internals: Added BringWindowToFront(), BringWindowToBack() helpers.
This commit is contained in:
parent
e9a7e73bba
commit
7c4be0a000
43
imgui.cpp
43
imgui.cpp
@ -4793,7 +4793,35 @@ void ImGui::Scrollbar(ImGuiLayoutType direction)
|
||||
window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding);
|
||||
}
|
||||
|
||||
// Moving window to front of display (which happens to be back of our sorted list)
|
||||
void ImGui::BringWindowToFront(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.Windows.back() == window)
|
||||
return;
|
||||
for (int i = 0; i < g.Windows.Size; i++)
|
||||
if (g.Windows[i] == window)
|
||||
{
|
||||
g.Windows.erase(g.Windows.begin() + i);
|
||||
g.Windows.push_back(window);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::BringWindowToBack(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.Windows[0] == window)
|
||||
return;
|
||||
for (int i = 0; i < g.Windows.Size; i++)
|
||||
if (g.Windows[i] == window)
|
||||
{
|
||||
memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*));
|
||||
g.Windows[0] = window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Moving window to front of display and set focus (which happens to be back of our sorted list)
|
||||
void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -4805,7 +4833,7 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
// And move its root window to the top of the pile
|
||||
// Move the root window to the top of the pile
|
||||
if (window->RootWindow)
|
||||
window = window->RootWindow;
|
||||
|
||||
@ -4815,15 +4843,8 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
ClearActiveID();
|
||||
|
||||
// Bring to front
|
||||
if ((window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus) || g.Windows.back() == window)
|
||||
return;
|
||||
for (int i = 0; i < g.Windows.Size; i++)
|
||||
if (g.Windows[i] == window)
|
||||
{
|
||||
g.Windows.erase(g.Windows.begin() + i);
|
||||
break;
|
||||
}
|
||||
g.Windows.push_back(window);
|
||||
if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus))
|
||||
BringWindowToFront(window);
|
||||
}
|
||||
|
||||
void ImGui::FocusPreviousWindow()
|
||||
|
@ -779,6 +779,8 @@ namespace ImGui
|
||||
IMGUI_API ImGuiWindow* GetParentWindow();
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
IMGUI_API void BringWindowToFront(ImGuiWindow* window);
|
||||
IMGUI_API void BringWindowToBack(ImGuiWindow* window);
|
||||
|
||||
IMGUI_API void Initialize();
|
||||
IMGUI_API void EndFrame(); // Ends the ImGui frame. Automatically called by Render()! you most likely don't need to ever call that yourself directly. If you don't need to render you can call EndFrame() but you'll have wasted CPU already. If you don't need to render, don't create any windows instead!
|
||||
|
Loading…
Reference in New Issue
Block a user