From 1fade351595af3553678c8b954bf279084964683 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 7 Dec 2023 14:01:53 +0100 Subject: [PATCH] DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: Fixed incorrect pushes into ItemWidth stack when number of components is 1. [#7095] --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 772583e33..a94f8f69b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -42,6 +42,8 @@ HOW TO UPDATE? Breaking changes: +- DragScalarN, SliderScalarN, InputScalarN: Fixed incorrect pushes into ItemWidth + stack when number of components is 1. [#7095] [@Nahor] - imgui_freetype: commented out ImGuiFreeType::BuildFontAtlas() obsoleted in 1.81. Prefer using #define IMGUI_ENABLE_FREETYPE or see commented code for manual calls. - Removed CalcListClipping() marked obsolete in 1.86. (#3841) diff --git a/imgui.cpp b/imgui.cpp index 71c8569f1..84bc9d376 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9864,7 +9864,8 @@ void ImGui::PushMultiItemsWidths(int components, float w_full) const float w_item_one = ImMax(1.0f, IM_TRUNC((w_full - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components)); const float w_item_last = ImMax(1.0f, IM_TRUNC(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components - 1))); window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); // Backup current width - window->DC.ItemWidthStack.push_back(w_item_last); + if (components > 1) + window->DC.ItemWidthStack.push_back(w_item_last); for (int i = 0; i < components - 2; i++) window->DC.ItemWidthStack.push_back(w_item_one); window->DC.ItemWidth = (components == 1) ? w_item_last : w_item_one;