mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Combo: Right-most button stays highlight when popup is open.
This commit is contained in:
parent
c71aae08f3
commit
7c9fa59329
11
imgui.cpp
11
imgui.cpp
@ -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 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));
|
||||
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);
|
||||
|
||||
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)
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
||||
bool menu_toggled = false;
|
||||
if (hovered)
|
||||
{
|
||||
SetHoveredID(id);
|
||||
@ -8078,8 +8079,8 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
else
|
||||
{
|
||||
FocusWindow(window);
|
||||
ImGui::OpenPopup(label);
|
||||
menu_toggled = true;
|
||||
OpenPopup(label);
|
||||
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;
|
||||
*current_item = i;
|
||||
}
|
||||
if (item_selected && menu_toggled)
|
||||
if (item_selected && popup_opened_now)
|
||||
ImGui::SetScrollHere();
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user