66 const DockNode* selected, ImDrawList* dl) {
67 if (dl ==
nullptr || tree.
root ==
nullptr)
70 const ImU32 cell_bg = ImGui::GetColorU32(ImGuiCol_FrameBg);
71 const ImU32 cell_border = ImGui::GetColorU32(ImGuiCol_Border);
72 const ImU32 split_gutter = cell_border;
73 const ImU32 text_color = ImGui::GetColorU32(ImGuiCol_Text);
82 const ImRect& rect = it->second;
85 const bool children_expanded =
86 is_split && node->child_a !=
nullptr && node->child_b !=
nullptr &&
87 layout.
node_rects.count(node->child_a.get()) > 0 &&
88 layout.
node_rects.count(node->child_b.get()) > 0;
90 if (!is_split || !children_expanded) {
91 dl->AddRectFilled(rect.Min, rect.Max, cell_bg);
92 dl->AddRect(rect.Min, rect.Max, cell_border);
96 const int idx = std::clamp(node->active_tab_index, 0,
97 static_cast<int>(node->panels.size()) - 1);
98 label = node->panels[idx].display_name;
99 }
else if (is_split) {
100 label =
"(collapsed split)";
103 if (!label.empty() && rect.GetWidth() > 40.0f &&
104 rect.GetHeight() > 20.0f) {
105 dl->AddText(ImVec2(rect.Min.x + 6.0f, rect.Min.y + 6.0f), text_color,
111 const ImRect& a_rect = layout.
node_rects.at(node->child_a.get());
112 if (IsHorizontalSplit(node->split_direction)) {
113 dl->AddLine(ImVec2(a_rect.Max.x, rect.Min.y),
114 ImVec2(a_rect.Max.x, rect.Max.y), split_gutter);
116 dl->AddLine(ImVec2(rect.Min.x, a_rect.Max.y),
117 ImVec2(rect.Max.x, a_rect.Max.y), split_gutter);
119 draw(node->child_a.get());
120 draw(node->child_b.get());
123 draw(tree.
root.get());
125 if (selected !=
nullptr) {
126 const auto it = layout.
node_rects.find(selected);
128 dl->AddRect(it->second.Min, it->second.Max, selection, 0.0f, 0, 2.5f);