MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / CollapseButton

Method CollapseButton

extern/imgui/imgui_widgets.cpp:846–873  ·  view source on GitHub ↗

The Collapse button also functions as a Dock Menu button.

Source from the content-addressed store, hash-verified

844
845// The Collapse button also functions as a Dock Menu button.
846bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node)
847{
848 ImGuiContext& g = *GImGui;
849 ImGuiWindow* window = g.CurrentWindow;
850
851 ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f);
852 ItemAdd(bb, id);
853 bool hovered, held;
854 bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None);
855
856 // Render
857 //bool is_dock_menu = (window->DockNodeAsHost && !window->Collapsed);
858 ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
859 ImU32 text_col = GetColorU32(ImGuiCol_Text);
860 if (hovered || held)
861 window->DrawList->AddCircleFilled(bb.GetCenter() + ImVec2(0,-0.5f), g.FontSize * 0.5f + 1.0f, bg_col, 12);
862
863 if (dock_node)
864 RenderArrowDockMenu(window->DrawList, bb.Min + g.Style.FramePadding, g.FontSize, text_col);
865 else
866 RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
867
868 // Switch to moving the window after mouse is moved beyond the initial drag threshold
869 if (IsItemActive() && IsMouseDragging(0))
870 StartMouseMovingWindowOrNode(window, dock_node, true);
871
872 return pressed;
873}
874
875ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis)
876{

Callers

nothing calls this directly

Calls 3

ImVec2Function · 0.85
AddCircleFilledMethod · 0.80
GetCenterMethod · 0.80

Tested by

no test coverage detected