From cfe6dac5a3498eaa150b6d3682b8afdb6549dc48 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 2 Mar 2015 16:04:36 +0000 Subject: [PATCH] Fixed Combo() label not included in declared size (fix #149, relate to #145) --- imgui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 602184ef..7652d7c8 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5888,11 +5888,11 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi const ImVec2 text_size = CalcTextSize(label, NULL, true); const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, text_size.y) + style.FramePadding*2.0f); - ItemSize(frame_bb); + const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + text_size.x,0)); + ItemSize(bb); if (!ItemAdd(frame_bb, &id)) return false; - const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + text_size.x,0)); const float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f); const bool hovered = IsHovered(frame_bb, id); @@ -8748,6 +8748,10 @@ void ImGui::ShowTestWindow(bool* opened) // SliderFloat static float f0=1.0f, f1=2.0f, f2=3.0f; ImGui::PushItemWidth(80); + const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" }; + static int item = -1; + ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); + ImGui::SameLine(); ImGui::SliderFloat("X", &f0, 0.0f,5.0f); ImGui::SameLine(); ImGui::SliderFloat("Y", &f1, 0.0f,5.0f);