MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / CloseButton

Method CloseButton

lib/imgui/imgui_widgets.cpp:752–780  ·  view source on GitHub ↗

Button to close a window

Source from the content-addressed store, hash-verified

750
751// Button to close a window
752bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)//, float size)
753{
754 ImGuiContext& g = *GImGui;
755 ImGuiWindow* window = g.CurrentWindow;
756
757 // We intentionally allow interaction when clipped so that a mechanical Alt,Right,Validate sequence close a window.
758 // (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible).
759 const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f);
760 bool is_clipped = !ItemAdd(bb, id);
761
762 bool hovered, held;
763 bool pressed = ButtonBehavior(bb, id, &hovered, &held);
764 if (is_clipped)
765 return pressed;
766
767 // Render
768 ImU32 col = GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered);
769 ImVec2 center = bb.GetCenter();
770 if (hovered)
771 window->DrawList->AddCircleFilled(center, ImMax(2.0f, g.FontSize * 0.5f + 1.0f), col, 12);
772
773 float cross_extent = g.FontSize * 0.5f * 0.7071f - 1.0f;
774 ImU32 cross_col = GetColorU32(ImGuiCol_Text);
775 center -= ImVec2(0.5f, 0.5f);
776 window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), cross_col, 1.0f);
777 window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), cross_col, 1.0f);
778
779 return pressed;
780}
781
782bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
783{

Callers

nothing calls this directly

Calls 4

ImVec2Class · 0.85
ImMaxFunction · 0.85
AddCircleFilledMethod · 0.80
AddLineMethod · 0.80

Tested by

no test coverage detected