The Collapse button also functions as a Dock Menu button.
| 844 | |
| 845 | // The Collapse button also functions as a Dock Menu button. |
| 846 | bool 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 | |
| 875 | ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis) |
| 876 | { |
nothing calls this directly
no test coverage detected