MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / CollapseButton

Method CollapseButton

imgui_tiny_app/imgui/imgui_widgets.cpp:938–968  ·  view source on GitHub ↗

The Collapse button also functions as a Dock Menu button.

Source from the content-addressed store, hash-verified

936
937// The Collapse button also functions as a Dock Menu button.
938bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node)
939{
940 ImGuiContext& g = *GImGui;
941 ImGuiWindow* window = g.CurrentWindow;
942
943 ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize));
944 bool is_clipped = !ItemAdd(bb, id);
945 bool hovered, held;
946 bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None);
947 if (is_clipped)
948 return pressed;
949
950 // Render
951 //bool is_dock_menu = (window->DockNodeAsHost && !window->Collapsed);
952 ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
953 ImU32 text_col = GetColorU32(ImGuiCol_Text);
954 if (hovered || held)
955 window->DrawList->AddRectFilled(bb.Min, bb.Max, bg_col);
956 RenderNavCursor(bb, id, ImGuiNavRenderCursorFlags_Compact);
957
958 if (dock_node)
959 RenderArrowDockMenu(window->DrawList, bb.Min, g.FontSize, text_col);
960 else
961 RenderArrow(window->DrawList, bb.Min, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
962
963 // Switch to moving the window after mouse is moved beyond the initial drag threshold
964 if (IsItemActive() && IsMouseDragging(0))
965 StartMouseMovingWindowOrNode(window, dock_node, true); // Undock from window/collapse menu button
966
967 return pressed;
968}
969
970ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis)
971{

Callers

nothing calls this directly

Calls 2

ImVec2Function · 0.85
AddRectFilledMethod · 0.80

Tested by

no test coverage detected