mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 07:36:35 +00:00
CollapseButton: handle clipping better + align circle like in docking branch.
Amend 6c3697f6
This commit is contained in:
parent
040e818d72
commit
b41811a68c
@ -809,7 +809,7 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)
|
||||
bb_interact.Expand(ImFloor(bb_interact.GetSize() * -0.25f));
|
||||
|
||||
// Tweak 2: We intentionally allow interaction when clipped so that a mechanical Alt,Right,Activate sequence can always close a window.
|
||||
// (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible).
|
||||
// (this isn't the common behavior of buttons, but it doesn't affect the user because navigation tends to keep items visible in scrolling layer).
|
||||
bool is_clipped = !ItemAdd(bb_interact, id);
|
||||
|
||||
bool hovered, held;
|
||||
@ -839,15 +839,17 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f);
|
||||
ItemAdd(bb, id);
|
||||
bool is_clipped = !ItemAdd(bb, id);
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None);
|
||||
if (is_clipped)
|
||||
return pressed;
|
||||
|
||||
// Render
|
||||
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
||||
if (hovered || held)
|
||||
window->DrawList->AddCircleFilled(bb.GetCenter()/*+ ImVec2(0.0f, -0.5f)*/, g.FontSize * 0.5f + 1.0f, bg_col);
|
||||
window->DrawList->AddCircleFilled(bb.GetCenter() + ImVec2(0.0f, -0.5f), g.FontSize * 0.5f + 1.0f, bg_col);
|
||||
RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
||||
|
||||
// Switch to moving the window after mouse is moved beyond the initial drag threshold
|
||||
|
Loading…
Reference in New Issue
Block a user