From 3dcf323c35a20914930f6068002e3d4c4815bb87 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 16 Sep 2019 19:03:20 +0200 Subject: [PATCH] Columns: Separator: Fixed a bug where non-visible separators within columns would alter the next row position differently than visible ones. Fixed rounding issues also leading to change of ScrollMax depending on visible items (in particular negative coordinate would be rounded differently) --- docs/CHANGELOG.txt | 2 ++ imgui_demo.cpp | 2 +- imgui_widgets.cpp | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 5bc49ac7e..6e487ae5c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -45,6 +45,8 @@ Other Changes: (before 1.71 tab bars fed the sum of current width which created feedback loops in certain situations). - TabBar: improved shrinking for large number of tabs to avoid leaving extraneous space on the right side. Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right. +- Columns, Separator: Fixed a bug where non-visible separators within columns would alter the next row position + differently than visible ones. - SliderScalar: Improved assert when using U32 or U64 types with a large v_max value. (#2765) [@loicmouton] - DragInt, DragFloat, DragScalar: Using (v_min > v_max) allows locking any edit to the value. - DragScalar: Fixed dragging of unsigned values on ARM cpu. (#2780) [@dBagrat] diff --git a/imgui_demo.cpp b/imgui_demo.cpp index d5bc96c56..fd1d85a3d 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1451,7 +1451,7 @@ static void ShowDemoWindowWidgets() ImGui::PushID("set2"); static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f }; const int rows = 3; - const ImVec2 small_slider_size(18, (160.0f-(rows-1)*spacing)/rows); + const ImVec2 small_slider_size(18, (float)(int)((160.0f - (rows - 1) * spacing) / rows)); for (int nx = 0; nx < 4; nx++) { if (nx > 0) ImGui::SameLine(); diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e3441ac0d..35ce1436e 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1261,7 +1261,10 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags) if (!ItemAdd(bb, 0)) { if (columns) + { PopColumnsBackground(); + columns->LineMinY = window->DC.CursorPos.y; + } return; } @@ -5624,7 +5627,7 @@ bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_item // We include ItemSpacing.y so that a list sized for the exact number of items doesn't make a scrollbar appears. We could also enforce that by passing a flag to BeginChild(). ImVec2 size; size.x = 0.0f; - size.y = GetTextLineHeightWithSpacing() * height_in_items_f + style.FramePadding.y * 2.0f; + size.y = ImFloor(GetTextLineHeightWithSpacing() * height_in_items_f + style.FramePadding.y * 2.0f); return ListBoxHeader(label, size); }