|
|
@@ -1805,6 +1805,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
|
|
Collapsed = false;
|
|
|
SkipItems = false;
|
|
|
Appearing = false;
|
|
|
+ CloseButton = false;
|
|
|
BeginCount = 0;
|
|
|
PopupId = 0;
|
|
|
AutoFitFramesX = AutoFitFramesY = -1;
|
|
|
@@ -3922,6 +3923,13 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size,
|
|
|
return pos;
|
|
|
}
|
|
|
|
|
|
+static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
|
|
|
+{
|
|
|
+ window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags);
|
|
|
+ window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags);
|
|
|
+ window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags);
|
|
|
+}
|
|
|
+
|
|
|
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -3953,15 +3961,9 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|
|
|
|
|
ImGuiIniData* settings = FindWindowSettings(name);
|
|
|
if (!settings)
|
|
|
- {
|
|
|
settings = AddWindowSettings(name);
|
|
|
- }
|
|
|
else
|
|
|
- {
|
|
|
- window->SetWindowPosAllowFlags &= ~ImGuiCond_FirstUseEver;
|
|
|
- window->SetWindowSizeAllowFlags &= ~ImGuiCond_FirstUseEver;
|
|
|
- window->SetWindowCollapsedAllowFlags &= ~ImGuiCond_FirstUseEver;
|
|
|
- }
|
|
|
+ SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
|
|
|
|
|
|
if (settings->Pos.x != FLT_MAX)
|
|
|
{
|
|
|
@@ -4135,13 +4137,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
|
|
|
const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFrames == 1);
|
|
|
window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize);
|
|
|
+ window->CloseButton = (p_open != NULL);
|
|
|
|
|
|
// Process SetNextWindow***() calls
|
|
|
+ if (window->Appearing)
|
|
|
+ SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true);
|
|
|
bool window_pos_set_by_api = false, window_size_set_by_api = false;
|
|
|
if (g.SetNextWindowPosCond)
|
|
|
{
|
|
|
- if (window->Appearing)
|
|
|
- window->SetWindowPosAllowFlags |= ImGuiCond_Appearing;
|
|
|
window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.SetNextWindowPosCond) != 0;
|
|
|
if (window_pos_set_by_api && ImLengthSqr(g.SetNextWindowPosPivot) > 0.00001f)
|
|
|
{
|
|
|
@@ -4159,8 +4162,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
}
|
|
|
if (g.SetNextWindowSizeCond)
|
|
|
{
|
|
|
- if (window->Appearing)
|
|
|
- window->SetWindowSizeAllowFlags |= ImGuiCond_Appearing;
|
|
|
window_size_set_by_api = (window->SetWindowSizeAllowFlags & g.SetNextWindowSizeCond) != 0;
|
|
|
SetWindowSize(window, g.SetNextWindowSizeVal, g.SetNextWindowSizeCond);
|
|
|
g.SetNextWindowSizeCond = 0;
|
|
|
@@ -4176,8 +4177,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
}
|
|
|
if (g.SetNextWindowCollapsedCond)
|
|
|
{
|
|
|
- if (window->Appearing)
|
|
|
- window->SetWindowCollapsedAllowFlags |= ImGuiCond_Appearing;
|
|
|
SetWindowCollapsed(window, g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond);
|
|
|
g.SetNextWindowCollapsedCond = 0;
|
|
|
}
|
|
|
@@ -4186,6 +4185,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
SetWindowFocus();
|
|
|
g.SetNextWindowFocus = false;
|
|
|
}
|
|
|
+ if (window->Appearing)
|
|
|
+ SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
|
|
|
|
|
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
|
|
if (first_begin_of_the_frame)
|
|
|
@@ -4798,7 +4799,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;
|
|
|
@@ -4810,7 +4839,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;
|
|
|
|
|
|
@@ -4820,15 +4849,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()
|
|
|
@@ -10499,7 +10521,8 @@ void ImGui::EndColumns()
|
|
|
|
|
|
window->DC.ColumnsCellMaxY = ImMax(window->DC.ColumnsCellMaxY, window->DC.CursorPos.y);
|
|
|
window->DC.CursorPos.y = window->DC.ColumnsCellMaxY;
|
|
|
- window->DC.CursorMaxPos.x = ImMax(window->DC.ColumnsStartMaxPosX, window->DC.ColumnsMaxX); // Columns don't grow parent
|
|
|
+ if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_GrowParentContentsSize))
|
|
|
+ window->DC.CursorMaxPos.x = ImMax(window->DC.ColumnsStartMaxPosX, window->DC.ColumnsMaxX); // Restore cursor max pos, as columns don't grow parent
|
|
|
|
|
|
// Draw columns borders and handle resize
|
|
|
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
|