|
@@ -1,4 +1,4 @@
|
|
-// dear imgui, v1.65
|
|
|
|
|
|
+// dear imgui, v1.66 WIP
|
|
// (main code and documentation)
|
|
// (main code and documentation)
|
|
|
|
|
|
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
|
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
|
@@ -917,7 +917,7 @@ static void CheckStacksSize(ImGuiWindow* window, bool write);
|
|
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges);
|
|
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges);
|
|
|
|
|
|
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
|
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
|
-static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
|
|
|
|
|
|
+static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
|
|
|
|
|
|
// Settings
|
|
// Settings
|
|
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
|
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
|
@@ -3358,6 +3358,7 @@ void ImGui::NewFrame()
|
|
g.NavIdTabCounter = INT_MAX;
|
|
g.NavIdTabCounter = INT_MAX;
|
|
|
|
|
|
// Mark all windows as not visible
|
|
// Mark all windows as not visible
|
|
|
|
+ IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size);
|
|
for (int i = 0; i != g.Windows.Size; i++)
|
|
for (int i = 0; i != g.Windows.Size; i++)
|
|
{
|
|
{
|
|
ImGuiWindow* window = g.Windows[i];
|
|
ImGuiWindow* window = g.Windows[i];
|
|
@@ -3369,7 +3370,7 @@ void ImGui::NewFrame()
|
|
|
|
|
|
// Closing the focused window restore focus to the first active root window in descending z-order
|
|
// Closing the focused window restore focus to the first active root window in descending z-order
|
|
if (g.NavWindow && !g.NavWindow->WasActive)
|
|
if (g.NavWindow && !g.NavWindow->WasActive)
|
|
- FocusFrontMostActiveWindowIgnoringOne(NULL);
|
|
|
|
|
|
+ FocusPreviousWindowIgnoringOne(NULL);
|
|
|
|
|
|
// No window should be open at the beginning of the frame.
|
|
// No window should be open at the beginning of the frame.
|
|
// But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
|
|
// But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
|
|
@@ -3424,7 +3425,12 @@ void ImGui::Shutdown(ImGuiContext* context)
|
|
|
|
|
|
// Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file)
|
|
// Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file)
|
|
if (g.SettingsLoaded && g.IO.IniFilename != NULL)
|
|
if (g.SettingsLoaded && g.IO.IniFilename != NULL)
|
|
|
|
+ {
|
|
|
|
+ ImGuiContext* backup_context = GImGui;
|
|
|
|
+ SetCurrentContext(context);
|
|
SaveIniSettingsToDisk(g.IO.IniFilename);
|
|
SaveIniSettingsToDisk(g.IO.IniFilename);
|
|
|
|
+ SetCurrentContext(backup_context);
|
|
|
|
+ }
|
|
|
|
|
|
// Destroy platform windows
|
|
// Destroy platform windows
|
|
ImGuiContext* backup_context = ImGui::GetCurrentContext();
|
|
ImGuiContext* backup_context = ImGui::GetCurrentContext();
|
|
@@ -3436,6 +3442,7 @@ void ImGui::Shutdown(ImGuiContext* context)
|
|
for (int i = 0; i < g.Windows.Size; i++)
|
|
for (int i = 0; i < g.Windows.Size; i++)
|
|
IM_DELETE(g.Windows[i]);
|
|
IM_DELETE(g.Windows[i]);
|
|
g.Windows.clear();
|
|
g.Windows.clear();
|
|
|
|
+ g.WindowsFocusOrder.clear();
|
|
g.WindowsSortBuffer.clear();
|
|
g.WindowsSortBuffer.clear();
|
|
g.CurrentWindow = NULL;
|
|
g.CurrentWindow = NULL;
|
|
g.CurrentWindowStack.clear();
|
|
g.CurrentWindowStack.clear();
|
|
@@ -3485,7 +3492,7 @@ static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs)
|
|
return (a->BeginOrderWithinParent - b->BeginOrderWithinParent);
|
|
return (a->BeginOrderWithinParent - b->BeginOrderWithinParent);
|
|
}
|
|
}
|
|
|
|
|
|
-static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window)
|
|
|
|
|
|
+static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window)
|
|
{
|
|
{
|
|
out_sorted_windows->push_back(window);
|
|
out_sorted_windows->push_back(window);
|
|
if (window->Active)
|
|
if (window->Active)
|
|
@@ -3497,7 +3504,7 @@ static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>* out_sorted_windows,
|
|
{
|
|
{
|
|
ImGuiWindow* child = window->DC.ChildWindows[i];
|
|
ImGuiWindow* child = window->DC.ChildWindows[i];
|
|
if (child->Active)
|
|
if (child->Active)
|
|
- AddWindowToSortedBuffer(out_sorted_windows, child);
|
|
|
|
|
|
+ AddWindowToSortBuffer(out_sorted_windows, child);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3731,7 +3738,7 @@ void ImGui::EndFrame()
|
|
ImGuiWindow* window = g.Windows[i];
|
|
ImGuiWindow* window = g.Windows[i];
|
|
if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
|
|
if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
|
|
continue;
|
|
continue;
|
|
- AddWindowToSortedBuffer(&g.WindowsSortBuffer, window);
|
|
|
|
|
|
+ AddWindowToSortBuffer(&g.WindowsSortBuffer, window);
|
|
}
|
|
}
|
|
|
|
|
|
IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size); // we done something wrong
|
|
IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size); // we done something wrong
|
|
@@ -4391,7 +4398,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|
if (ImLengthSqr(settings->Size) > 0.00001f)
|
|
if (ImLengthSqr(settings->Size) > 0.00001f)
|
|
size = ImFloor(settings->Size);
|
|
size = ImFloor(settings->Size);
|
|
}
|
|
}
|
|
- window->Size = window->SizeFull = window->SizeFullAtLastBegin = size;
|
|
|
|
|
|
+ window->Size = window->SizeFull = window->SizeFullAtLastBegin = ImFloor(size);
|
|
window->DC.CursorMaxPos = window->Pos; // So first call to CalcSizeContents() doesn't return crazy values
|
|
window->DC.CursorMaxPos = window->Pos; // So first call to CalcSizeContents() doesn't return crazy values
|
|
|
|
|
|
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
|
|
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
|
|
@@ -4408,8 +4415,9 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|
window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0);
|
|
window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ g.WindowsFocusOrder.push_back(window);
|
|
if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus)
|
|
if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus)
|
|
- g.Windows.insert(g.Windows.begin(), window); // Quite slow but rare and only once
|
|
|
|
|
|
+ g.Windows.push_front(window); // Quite slow but rare and only once
|
|
else
|
|
else
|
|
g.Windows.push_back(window);
|
|
g.Windows.push_back(window);
|
|
return window;
|
|
return window;
|
|
@@ -5450,7 +5458,21 @@ void ImGui::End()
|
|
SetCurrentViewport(g.CurrentWindow, g.CurrentWindow->Viewport);
|
|
SetCurrentViewport(g.CurrentWindow, g.CurrentWindow->Viewport);
|
|
}
|
|
}
|
|
|
|
|
|
-void ImGui::BringWindowToFront(ImGuiWindow* window)
|
|
|
|
|
|
+void ImGui::BringWindowToFocusFront(ImGuiWindow* window)
|
|
|
|
+{
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
+ if (g.WindowsFocusOrder.back() == window)
|
|
|
|
+ return;
|
|
|
|
+ for (int i = g.WindowsFocusOrder.Size - 2; i >= 0; i--) // We can ignore the front most window
|
|
|
|
+ if (g.WindowsFocusOrder[i] == window)
|
|
|
|
+ {
|
|
|
|
+ memmove(&g.WindowsFocusOrder[i], &g.WindowsFocusOrder[i + 1], (size_t)(g.WindowsFocusOrder.Size - i - 1) * sizeof(ImGuiWindow*));
|
|
|
|
+ g.WindowsFocusOrder[g.WindowsFocusOrder.Size - 1] = window;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ImGui::BringWindowToDisplayFront(ImGuiWindow* window)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiWindow* current_front_window = g.Windows.back();
|
|
ImGuiWindow* current_front_window = g.Windows.back();
|
|
@@ -5459,13 +5481,13 @@ void ImGui::BringWindowToFront(ImGuiWindow* window)
|
|
for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the front most window
|
|
for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the front most window
|
|
if (g.Windows[i] == window)
|
|
if (g.Windows[i] == window)
|
|
{
|
|
{
|
|
- g.Windows.erase(g.Windows.Data + i);
|
|
|
|
- g.Windows.push_back(window);
|
|
|
|
|
|
+ memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*));
|
|
|
|
+ g.Windows[g.Windows.Size - 1] = window;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void ImGui::BringWindowToBack(ImGuiWindow* window)
|
|
|
|
|
|
+void ImGui::BringWindowToDisplayBack(ImGuiWindow* window)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
if (g.Windows[0] == window)
|
|
if (g.Windows[0] == window)
|
|
@@ -5510,20 +5532,24 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|
ClearActiveID();
|
|
ClearActiveID();
|
|
|
|
|
|
// Bring to front
|
|
// Bring to front
|
|
|
|
+ BringWindowToFocusFront(window);
|
|
if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus))
|
|
if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus))
|
|
- BringWindowToFront(window);
|
|
|
|
|
|
+ BringWindowToDisplayFront(window);
|
|
}
|
|
}
|
|
|
|
|
|
-void ImGui::FocusFrontMostActiveWindowIgnoringOne(ImGuiWindow* ignore_window)
|
|
|
|
|
|
+void ImGui::FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- for (int i = g.Windows.Size - 1; i >= 0; i--)
|
|
|
|
- if (g.Windows[i] != ignore_window && g.Windows[i]->WasActive && !(g.Windows[i]->Flags & ImGuiWindowFlags_ChildWindow))
|
|
|
|
|
|
+ for (int i = g.WindowsFocusOrder.Size - 1; i >= 0; i--)
|
|
|
|
+ {
|
|
|
|
+ ImGuiWindow* window = g.WindowsFocusOrder[i];
|
|
|
|
+ if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow))
|
|
{
|
|
{
|
|
- ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(g.Windows[i]);
|
|
|
|
|
|
+ ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window);
|
|
FocusWindow(focus_window);
|
|
FocusWindow(focus_window);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void ImGui::PushItemWidth(float item_width)
|
|
void ImGui::PushItemWidth(float item_width)
|
|
@@ -5984,7 +6010,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
|
|
if (size.x > 0.0f)
|
|
if (size.x > 0.0f)
|
|
{
|
|
{
|
|
window->AutoFitFramesX = 0;
|
|
window->AutoFitFramesX = 0;
|
|
- window->SizeFull.x = size.x;
|
|
|
|
|
|
+ window->SizeFull.x = ImFloor(size.x);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -5994,7 +6020,7 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
|
|
if (size.y > 0.0f)
|
|
if (size.y > 0.0f)
|
|
{
|
|
{
|
|
window->AutoFitFramesY = 0;
|
|
window->AutoFitFramesY = 0;
|
|
- window->SizeFull.y = size.y;
|
|
|
|
|
|
+ window->SizeFull.y = ImFloor(size.y);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -8438,11 +8464,11 @@ static float ImGui::NavUpdatePageUpPageDown(int allowed_dir_flags)
|
|
return 0.0f;
|
|
return 0.0f;
|
|
}
|
|
}
|
|
|
|
|
|
-static int FindWindowIndex(ImGuiWindow* window) // FIXME-OPT O(N)
|
|
|
|
|
|
+static int FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- for (int i = g.Windows.Size-1; i >= 0; i--)
|
|
|
|
- if (g.Windows[i] == window)
|
|
|
|
|
|
+ for (int i = g.WindowsFocusOrder.Size-1; i >= 0; i--)
|
|
|
|
+ if (g.WindowsFocusOrder[i] == window)
|
|
return i;
|
|
return i;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -8450,9 +8476,9 @@ static int FindWindowIndex(ImGuiWindow* window) // FIXME-OPT O(N)
|
|
static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N)
|
|
static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- for (int i = i_start; i >= 0 && i < g.Windows.Size && i != i_stop; i += dir)
|
|
|
|
- if (ImGui::IsWindowNavFocusable(g.Windows[i]))
|
|
|
|
- return g.Windows[i];
|
|
|
|
|
|
+ for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir)
|
|
|
|
+ if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i]))
|
|
|
|
+ return g.WindowsFocusOrder[i];
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -8463,10 +8489,10 @@ static void NavUpdateWindowingHighlightWindow(int focus_change_dir)
|
|
if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal)
|
|
if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal)
|
|
return;
|
|
return;
|
|
|
|
|
|
- const int i_current = FindWindowIndex(g.NavWindowingTarget);
|
|
|
|
|
|
+ const int i_current = FindWindowFocusIndex(g.NavWindowingTarget);
|
|
ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir);
|
|
ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir);
|
|
if (!window_target)
|
|
if (!window_target)
|
|
- window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.Windows.Size - 1) : 0, i_current, focus_change_dir);
|
|
|
|
|
|
+ window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir);
|
|
if (window_target) // Don't reset windowing target if there's a single window in the list
|
|
if (window_target) // Don't reset windowing target if there's a single window in the list
|
|
g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target;
|
|
g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target;
|
|
g.NavWindowingToggleLayer = false;
|
|
g.NavWindowingToggleLayer = false;
|
|
@@ -8498,7 +8524,7 @@ static void ImGui::NavUpdateWindowing()
|
|
bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
|
|
bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
|
|
bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
|
|
bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
|
|
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
|
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
|
- if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.Windows.Size - 1, -INT_MAX, -1))
|
|
|
|
|
|
+ if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
|
|
{
|
|
{
|
|
g.NavWindowingTarget = g.NavWindowingTargetAnim = window;
|
|
g.NavWindowingTarget = g.NavWindowingTargetAnim = window;
|
|
g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
|
|
g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
|
|
@@ -8631,9 +8657,9 @@ void ImGui::NavUpdateWindowingList()
|
|
SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
|
SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
|
PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
|
|
PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
|
|
Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
|
|
Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
|
|
- for (int n = g.Windows.Size - 1; n >= 0; n--)
|
|
|
|
|
|
+ for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
|
|
{
|
|
{
|
|
- ImGuiWindow* window = g.Windows[n];
|
|
|
|
|
|
+ ImGuiWindow* window = g.WindowsFocusOrder[n];
|
|
if (!IsWindowNavFocusable(window))
|
|
if (!IsWindowNavFocusable(window))
|
|
continue;
|
|
continue;
|
|
const char* label = window->Name;
|
|
const char* label = window->Name;
|