Combo: Right-most button stays highlight when popup is open.

docking
ocornut 9 years ago
parent c71aae08f3
commit 7c9fa59329

@ -8048,10 +8048,12 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f); const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
const bool hovered = IsHovered(frame_bb, id); const bool hovered = IsHovered(frame_bb, id);
bool popup_opened = IsPopupOpen(id);
bool popup_opened_now = false;
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f)); const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_opened || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
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);
if (*current_item >= 0 && *current_item < items_count) if (*current_item >= 0 && *current_item < items_count)
@ -8064,7 +8066,6 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
if (label_size.x > 0) if (label_size.x > 0)
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
bool menu_toggled = false;
if (hovered) if (hovered)
{ {
SetHoveredID(id); SetHoveredID(id);
@ -8078,8 +8079,8 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
else else
{ {
FocusWindow(window); FocusWindow(window);
ImGui::OpenPopup(label); OpenPopup(label);
menu_toggled = true; popup_opened = popup_opened_now = true;
} }
} }
} }
@ -8116,7 +8117,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
value_changed = true; value_changed = true;
*current_item = i; *current_item = i;
} }
if (item_selected && menu_toggled) if (item_selected && popup_opened_now)
ImGui::SetScrollHere(); ImGui::SetScrollHere();
ImGui::PopID(); ImGui::PopID();
} }

Loading…
Cancel
Save