From 0573513d6df54fc7cff93a640dc8bb05b05b949d Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 28 Feb 2024 17:09:20 +0100 Subject: [PATCH] Windows: Scrollbar visibility decision uses current size when both size and contents size are submitted by API. (#7252) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 6 ++++++ imgui.h | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 48ccc0cf3..3468c0a1d 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -41,6 +41,8 @@ HOW TO UPDATE? Other changes: +- Windows: Scrollbar visibility decision uses current size when both size and contents + size are submitted by API. (#7252) - Menus, Popups: Fixed an issue where sibling menu popups re-opening in successive frames would erroneously close the window. While it is technically a popup issue it would generally manifest when fast moving the mouse bottom to top in a sub-menu. diff --git a/imgui.cpp b/imgui.cpp index 6a14012c3..45d551ab9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6610,8 +6610,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x); window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y; + // Depending on condition we use previous or current window size to compare against contents size to decide if a scrollbar should be visible. + // Those flags will be altered further down in the function depending on more conditions. bool use_current_size_for_scrollbar_x = window_just_created; bool use_current_size_for_scrollbar_y = window_just_created; + if (window_size_x_set_by_api && window->ContentSizeExplicit.x != 0.0f) + use_current_size_for_scrollbar_x = true; + if (window_size_y_set_by_api && window->ContentSizeExplicit.y != 0.0f) // #7252 + use_current_size_for_scrollbar_y = true; // Collapse window by double-clicking on title bar // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing diff --git a/imgui.h b/imgui.h index 307834fff..cd707b40f 100644 --- a/imgui.h +++ b/imgui.h @@ -24,7 +24,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.90.5 WIP" -#define IMGUI_VERSION_NUM 19042 +#define IMGUI_VERSION_NUM 19043 #define IMGUI_HAS_TABLE /*