Fixed clipped ImGui::Combo not registering its size properly (was flickering when scrolling with combo on the edge of clipping region)

This commit is contained in:
ocornut 2014-12-26 12:38:13 +00:00
parent 90351298d1
commit 34728394ec

View File

@ -4935,17 +4935,17 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
const ImGuiID id = window->GetID(label); const ImGuiID id = window->GetID(label);
const ImVec2 text_size = CalcTextSize(label); const ImVec2 text_size = CalcTextSize(label);
const float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f);
const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(window->DC.ItemWidth.back(), text_size.y) + style.FramePadding*2.0f); const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(window->DC.ItemWidth.back(), text_size.y) + style.FramePadding*2.0f);
const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + text_size.x,0));
ItemSize(frame_bb);
if (ClipAdvance(frame_bb)) if (ClipAdvance(frame_bb))
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 bool hovered = (g.HoveredWindow == window) && (g.HoveredId == 0) && IsMouseHoveringBox(bb); const bool hovered = (g.HoveredWindow == window) && (g.HoveredId == 0) && IsMouseHoveringBox(bb);
bool value_changed = false; bool value_changed = false;
ItemSize(frame_bb);
RenderFrame(frame_bb.Min, frame_bb.Max, window->Color(ImGuiCol_FrameBg)); RenderFrame(frame_bb.Min, frame_bb.Max, window->Color(ImGuiCol_FrameBg));
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, window->Color(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button)); RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, window->Color(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button));
RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true); RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);