24 using namespace ImGui;
26 ImGuiStyle& style = GetStyle();
27 ImGuiWindow* window = GetCurrentWindow();
28 if (window->SkipItems)
31 ImGuiID
id = window->GetID(label);
34 if (headerCustomContent)
36 SetNextItemAllowOverlap();
37 ImVec2 prevCursor = GetCursorScreenPos();
38 btnWidth = ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - headerCustomContent() - style.FramePadding.x;
40 SetCursorScreenPos(prevCursor);
43 bool* p_open = GetStateStorage()->GetBoolRef(
id,
true);
45 std::string btn_id = std::string(
"##EECollapsingHeaderBtn_") + label;
46 bool clicked = Button(btn_id.c_str(), ImVec2(btnWidth, 0.0f));
50 ImVec2 r_min = GetItemRectMin();
51 ImVec2 r_max = GetItemRectMax();
52 float btn_height = r_max.y - r_min.y;
54 float arrow_size = 7.0f;
55 ImVec2 arrow_pos = ImVec2(
56 r_min.x + arrow_size * 0.5f,
57 r_min.y + style.FramePadding.y
60 float icon_size = icon ? btn_height - style.FramePadding.y * 2 : 0.0f;
61 icon_size = ImMin(icon_size, 32.0f);
63 float icon_y_offset = (btn_height - icon_size) * 0.5f;
64 ImVec2 icon_pos = ImVec2(
65 r_min.x + style.FramePadding.x + arrow_size * 2 + style.ItemInnerSpacing.x,
66 r_min.y + icon_y_offset
69 ImVec2 text_pos = ImVec2(
70 r_min.x + style.FramePadding.x + arrow_size * 2 + 2 * style.ItemInnerSpacing.x + icon_size,
71 r_min.y + (btn_height - GetFontSize()) * 0.5f
74 ImDrawList* dl = window->DrawList;
77 RenderArrow(dl, arrow_pos, GetColorU32(ImGuiCol_Text),
78 *p_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f);
85 icon_pos + ImVec2(icon_size, icon_size),
86 ImVec2(0, 0), ImVec2(1, 1),
87 GetColorU32(ImGuiCol_Text)
91 dl->AddText(GetFont(), GetFontSize(), text_pos, GetColorU32(ImGuiCol_Text), label);