Fixed Combo() label not included in declared size (fix #149, relate to #145)

This commit is contained in:
ocornut 2015-03-02 16:04:36 +00:00
parent f4458f7571
commit cfe6dac5a3

View File

@ -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 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); 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)) if (!ItemAdd(frame_bb, &id))
return false; 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 float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f);
const bool hovered = IsHovered(frame_bb, id); const bool hovered = IsHovered(frame_bb, id);
@ -8748,6 +8748,10 @@ void ImGui::ShowTestWindow(bool* opened)
// SliderFloat // SliderFloat
static float f0=1.0f, f1=2.0f, f2=3.0f; static float f0=1.0f, f1=2.0f, f2=3.0f;
ImGui::PushItemWidth(80); 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::SliderFloat("X", &f0, 0.0f,5.0f);
ImGui::SameLine(); ImGui::SameLine();
ImGui::SliderFloat("Y", &f1, 0.0f,5.0f); ImGui::SliderFloat("Y", &f1, 0.0f,5.0f);