From 95bd1577d6938f9303096f9ca3cab866fe027f44 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 9 Apr 2026 12:53:20 +0200 Subject: [PATCH] Windows: Child windows with only ImGuiChildFlags_AutoResizeY flag keep using the proportional default ItemWidth. (#9355) + Removed Tooltip flag check, it's from 8c4fcf1359 (!) where AlwaysAutoReszie was added after Tooltip. Nowadays Tooltips sets ImGuiChildFlags_AlwaysAutoResize. --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 13 +++++++++---- imgui.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f90950541..ace3c72a5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -55,6 +55,8 @@ Other Changes: - Fixed a single-axis auto-resizing feedback loop issue with nested containers and varying scrollbar visibility. (#9352) - Detect and report error when calling End() instead of EndPopup() on a popup. (#9351) + - Child windows with only ImGuiChildFlags_AutoResizeY flag keep using the proportional + default ItemWidth. (#9355) - Fonts: - imgui_freetype: add FreeType headers & compiled version in 'About Dear ImGui' details. - Clipper: diff --git a/imgui.cpp b/imgui.cpp index 5beb0fbb0..d0823ad38 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6436,7 +6436,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I window_flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar; window_flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag if (child_flags & (ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_AlwaysAutoResize)) - window_flags |= ImGuiWindowFlags_AlwaysAutoResize; + window_flags |= ImGuiWindowFlags_AlwaysAutoResize; // FIXME: Would be sane to not make single-axis flag set this. (#9355) if ((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0) window_flags |= ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings; @@ -8035,9 +8035,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->DC.LayoutType = ImGuiLayoutType_Vertical; window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical; - // Default item width. Make it proportional to window size if window manually resizes - const bool is_resizable_window = (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize)); - if (is_resizable_window) + // Default item width. Make it proportional to window size if window can be manually resized. + // (we cannot use AutoFitFramesX/AutoFitFramesY which is a temporary state) + bool is_resizable_width; + if (flags & ImGuiWindowFlags_ChildWindow) + is_resizable_width = (window->Size.x > 0.0f) && !(window->ChildFlags & (ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AlwaysAutoResize)); + else + is_resizable_width = (window->Size.x > 0.0f) && !(flags & ImGuiWindowFlags_AlwaysAutoResize); + if (is_resizable_width) window->DC.ItemWidthDefault = ImTrunc(window->Size.x * 0.65f); else window->DC.ItemWidthDefault = ImTrunc(g.FontSize * 16.0f); diff --git a/imgui.h b/imgui.h index 35adb2dc1..75277db87 100644 --- a/imgui.h +++ b/imgui.h @@ -30,7 +30,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.92.8 WIP" -#define IMGUI_VERSION_NUM 19271 +#define IMGUI_VERSION_NUM 19272 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198