From 9a2b598ec1eeadd316650bc3081c735d0b6e15a4 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Apr 2024 10:18:49 +0900 Subject: [PATCH] ListBox: Fixed text-baseline offset when using SameLine()+Text() after a labeled ListBox(). Visible in demo->basic->listbox --- docs/CHANGELOG.txt | 1 + imgui_demo.cpp | 2 ++ imgui_widgets.cpp | 1 + 3 files changed, 4 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4d783dc03..45339c010 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -73,6 +73,7 @@ Other changes: it would generally manifest when fast moving the mouse bottom to top in a sub-menu. (#7325, #7287, #7063) - ProgressBar: Fixed passing fraction==NaN from leading to a crash. (#7451) +- ListBox: Fixed text-baseline offset when using SameLine()+Text() after a labeled ListBox(). - Style: Added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHeadersAngle for consistency. (#7411) [@cfillion] - DrawList: Added AddConcavePolyFilled(), PathFillConcave() concave filling. (#760) [@thedmd] diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 7297d5e7c..ad0be025a 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1289,6 +1289,7 @@ static void ShowDemoWindowWidgets() } ImGui::EndListBox(); } + ImGui::SameLine(); HelpMarker("Here we are sharing selection state between both boxes."); // Custom size: use all width, 5 items tall ImGui::Text("Full-width:"); @@ -1823,6 +1824,7 @@ static void ShowDemoWindowWidgets() static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr)); ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0, 80.0f)); + //ImGui::SameLine(); HelpMarker("Consider using ImPlot instead!"); // Fill an array of contiguous float values to plot // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index f1ffbf0f5..c8ac26625 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -6930,6 +6930,7 @@ bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg) ImVec2 label_pos = ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y); RenderText(label_pos, label); window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, label_pos + label_size); + AlignTextToFramePadding(); } BeginChild(id, frame_bb.GetSize(), ImGuiChildFlags_FrameStyle);