mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 13:08:47 +02:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_opengl3.cpp # backends/imgui_impl_osx.h # backends/imgui_impl_osx.mm # imgui.cpp
This commit is contained in:
41
imgui.cpp
41
imgui.cpp
@ -5544,6 +5544,27 @@ static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settin
|
||||
window->DockOrder = settings->DockOrder;
|
||||
}
|
||||
|
||||
static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool just_created, ImGuiWindowFlags new_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiWindowFlags old_flags = window->Flags;
|
||||
const bool child_flag_changed = (new_flags & ImGuiWindowFlags_ChildWindow) != (old_flags & ImGuiWindowFlags_ChildWindow);
|
||||
|
||||
if ((just_created || child_flag_changed) && !(new_flags & ImGuiWindowFlags_ChildWindow))
|
||||
{
|
||||
g.WindowsFocusOrder.push_back(window);
|
||||
window->FocusOrder = (short)(g.WindowsFocusOrder.Size - 1);
|
||||
}
|
||||
else if (child_flag_changed && (new_flags & ImGuiWindowFlags_ChildWindow))
|
||||
{
|
||||
IM_ASSERT(g.WindowsFocusOrder[window->FocusOrder] == window);
|
||||
for (int n = window->FocusOrder + 1; n < g.WindowsFocusOrder.Size; n++)
|
||||
g.WindowsFocusOrder[n]->FocusOrder--;
|
||||
g.WindowsFocusOrder.erase(g.WindowsFocusOrder.Data + window->FocusOrder);
|
||||
window->FocusOrder = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -5584,16 +5605,12 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
|
||||
window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0);
|
||||
}
|
||||
|
||||
if (!(flags & ImGuiWindowFlags_ChildWindow))
|
||||
{
|
||||
g.WindowsFocusOrder.push_back(window);
|
||||
window->FocusOrder = (short)(g.WindowsFocusOrder.Size - 1);
|
||||
}
|
||||
|
||||
if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus)
|
||||
g.Windows.push_front(window); // Quite slow but rare and only once
|
||||
else
|
||||
g.Windows.push_back(window);
|
||||
UpdateWindowInFocusOrderList(window, true, window->Flags);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
@ -6279,6 +6296,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
const bool window_just_created = (window == NULL);
|
||||
if (window_just_created)
|
||||
window = CreateNewWindow(name, flags);
|
||||
else
|
||||
UpdateWindowInFocusOrderList(window, window_just_created, flags);
|
||||
|
||||
// Automatically disable manual moving/resizing when NoInputs is set
|
||||
if ((flags & ImGuiWindowFlags_NoInputs) == ImGuiWindowFlags_NoInputs)
|
||||
@ -6372,6 +6391,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window_stack_data.StackSizesOnBegin.SetToCurrentState();
|
||||
g.CurrentWindowStack.push_back(window_stack_data);
|
||||
g.CurrentWindow = NULL;
|
||||
if (flags & ImGuiWindowFlags_ChildMenu)
|
||||
g.BeginMenuCount++;
|
||||
|
||||
if (flags & ImGuiWindowFlags_Popup)
|
||||
{
|
||||
@ -7107,6 +7128,8 @@ void ImGui::End()
|
||||
|
||||
// Pop from window stack
|
||||
g.LastItemData = g.CurrentWindowStack.back().ParentLastItemDataBackup;
|
||||
if (window->Flags & ImGuiWindowFlags_ChildMenu)
|
||||
g.BeginMenuCount--;
|
||||
if (window->Flags & ImGuiWindowFlags_Popup)
|
||||
g.BeginPopupStack.pop_back();
|
||||
g.CurrentWindowStack.back().StackSizesOnBegin.CompareWithCurrentState();
|
||||
@ -9302,7 +9325,7 @@ void ImGui::CloseCurrentPopup()
|
||||
ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window;
|
||||
bool close_parent = false;
|
||||
if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu))
|
||||
if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal))
|
||||
if (parent_popup_window && !(parent_popup_window->Flags & ImGuiWindowFlags_MenuBar))
|
||||
close_parent = true;
|
||||
if (!close_parent)
|
||||
break;
|
||||
@ -9330,7 +9353,7 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
||||
|
||||
char name[20];
|
||||
if (flags & ImGuiWindowFlags_ChildMenu)
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginMenuCount); // Recycle windows based on depth
|
||||
else
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
|
||||
|
||||
@ -17583,7 +17606,7 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con
|
||||
}
|
||||
|
||||
ImDrawList* fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list
|
||||
if (window && fg_draw_list && IsItemHovered())
|
||||
if (window && IsItemHovered() && fg_draw_list)
|
||||
fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
|
||||
if (!node_open)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user