From a3f03933516ee2a9c7e5cdcf1eb0e1fa4373195e Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 2 Feb 2021 13:06:51 +0100 Subject: [PATCH] Menus: Fixed an issue with child-menu auto-sizing (issue introduced by 6af92b0) (#3779) --- docs/CHANGELOG.txt | 5 +++-- imgui.cpp | 1 + imgui.h | 2 +- imgui_widgets.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 60208735..b6f18788 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -50,12 +50,13 @@ Other Changes: close button in the window. (#3731) - SliderInt: Fixed click/drag when v_min==v_max from setting the value to zero. (#3774) [@erwincoumans] Would also repro with DragFloat() when using ImGuiSliderFlags_Logarithmic with v_min==v_max. -- imgui_freetype: Facilitated using FreeType integration: [@Xipiryon, @ocornut] +- Menus: Fixed an issue with child-menu auto sizing (issue introduced in 1.80 on 2021/01/25) (#3779) +- Fonts: imgui_freetype: Facilitated using FreeType integration: [@Xipiryon, @ocornut] - Use '#define IMGUI_ENABLE_FREETYPE' in imconfig.h should make it work with no other modifications other than compiling misc/freetype/imgui_freetype.cpp and linking with FreeType. - Use '#define IMGUI_ENABLE_STB_TRUETYPE' if you somehow need the stb_truetype rasterizer to be compiled in along with the FreeType one, otherwise it is enabled by default. -- imgui_freetype: Added support for colored glyphs as supported by Freetype 2.10+ (for .ttf using CPAL/COLR +- Fonts: imgui_freetype: Added support for colored glyphs as supported by Freetype 2.10+ (for .ttf using CPAL/COLR tables only). Enable the ImGuiFreeTypeBuilderFlags_LoadColor on a given font. Atlas always output directly as RGBA8 in this situation. Likely to make sense with IMGUI_USE_WCHAR32. (#3369) [@pshurgal] - Fonts: Fixed CalcTextSize() width rounding so it behaves more like a ceil. This is in order for text wrapping diff --git a/imgui.cpp b/imgui.cpp index e41ee39d..58e6966f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6576,6 +6576,7 @@ void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) ImVec2 offset = window->Pos - old_pos; window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. + window->DC.IdealMaxPos += offset; window->DC.CursorStartPos += offset; } diff --git a/imgui.h b/imgui.h index a241cfb6..3fc57c45 100644 --- a/imgui.h +++ b/imgui.h @@ -59,7 +59,7 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) #define IMGUI_VERSION "1.81 WIP" -#define IMGUI_VERSION_NUM 18002 +#define IMGUI_VERSION_NUM 18003 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_HAS_TABLE diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index d159188c..2daf213a 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -6758,7 +6758,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) if (menu_is_open) { - SetNextWindowPos(popup_pos, ImGuiCond_Always); + SetNextWindowPos(popup_pos, ImGuiCond_Always); // Note: this is super misleading! The value will serve as reference for FindBestWindowPosForPopup(), not actual pos. menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) } else