From 2bc5d17ac39d8d0d10af4eba8c23eacb5cc81b84 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 20 Jul 2023 10:31:39 +0200 Subject: [PATCH] Tables: fixed calculation of multi-instance shared decoration/scrollbar width of scrolling tables. (#5920, #6619) Avoid width variation when resizing down a table hosting a child window. + shallow tweak to GetContentRegionMax(). --- docs/CHANGELOG.txt | 3 +++ imgui.cpp | 7 ++++--- imgui.h | 2 +- imgui_tables.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 19487269..0ec6be5e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -64,6 +64,9 @@ Other changes: - InputText: Fixed a case where deactivation frame would write to underlying buffer or call CallbackResize although unnecessary, in a frame where the return value was false. +- Tables: fixed calculation of multi-instance shared decoration/scrollbar width of + scrolling tables, to avoid flickering width variation when resizing down a table + hosting a child window. (#5920, #6619) - Scrollbar: layout needs to take account of window border size, so a border size will slightly reduce scrollbar size. Generally we tried to make it that window border size has no incidence on layout but this can't work with thick borders. (#2522) diff --git a/imgui.cpp b/imgui.cpp index 48230d3c..3e464de4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6738,6 +6738,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // [LEGACY] Content Region // FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it. + // Unless explicit content size is specified by user, this currently represent the region leading to no scrolling. // Used by: // - Mouse wheel scrolling + many other things window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x + window->DecoOuterSizeX1; @@ -9773,10 +9774,10 @@ ImVec2 ImGui::GetContentRegionMax() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; - ImVec2 mx = window->ContentRegionRect.Max - window->Pos; + ImVec2 mx = window->ContentRegionRect.Max; if (window->DC.CurrentColumns || g.CurrentTable) - mx.x = window->WorkRect.Max.x - window->Pos.x; - return mx; + mx.x = window->WorkRect.Max.x; + return mx - window->Pos; } // [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features. diff --git a/imgui.h b/imgui.h index 579af98a..dcdfc38e 100644 --- a/imgui.h +++ b/imgui.h @@ -26,7 +26,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.89.8 WIP" -#define IMGUI_VERSION_NUM 18973 +#define IMGUI_VERSION_NUM 18974 #define IMGUI_HAS_TABLE /* diff --git a/imgui_tables.cpp b/imgui_tables.cpp index a076a9be..12032545 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -410,7 +410,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG table->HasScrollbarYPrev = table->HasScrollbarYCurr; table->HasScrollbarYCurr = false; } - table->HasScrollbarYCurr |= (table->InnerWindow->ScrollMax.y > 0.0f); + table->HasScrollbarYCurr |= table->InnerWindow->ScrollbarY; } else {