52 const std::string& exclude_panel_id) {
53 std::vector<PanelPaletteEntry> out;
59 if (!exclude_panel_id.empty() && entry.
panel_id == exclude_panel_id) {
63 entry.
icon = panel->GetIcon();
64 entry.
category = panel->GetEditorCategory();
65 out.push_back(std::move(entry));
67 std::sort(out.begin(), out.end(),
69 if (a.category != b.category)
70 return a.category < b.category;
71 return a.display_name < b.display_name;
78 if (query !=
nullptr) {
79 ImGui::SetNextItemWidth(-FLT_MIN);
80 ImGui::InputTextWithHint(
"##layout_designer_palette_query",
"Search panels",
83 const std::string q = query !=
nullptr ? *query : std::string();
85 ImGui::TextDisabled(tr(
"Drag panels onto the canvas to place them."));
89 std::string current_category;
90 bool category_open =
false;
91 int rendered_in_category = 0;
93 auto close_current_category = [&]() {
94 if (category_open && rendered_in_category == 0) {
95 ImGui::TextDisabled(tr(
" (no matches)"));
97 category_open =
false;
98 rendered_in_category = 0;
105 if (entry.category != current_category) {
106 close_current_category();
107 current_category = entry.category;
108 const std::string header =
109 entry.category.empty() ?
"(uncategorized)" : entry.category;
110 category_open = ImGui::CollapsingHeader(header.c_str(),
111 ImGuiTreeNodeFlags_DefaultOpen);
116 ImGui::PushID(entry.panel_id.c_str());
117 const std::string label = entry.icon.empty()
119 : entry.icon +
" " + entry.display_name;
120 ImGui::TextUnformatted(label.c_str());
122 if (ImGui::IsItemHovered() && !entry.panel_id.empty()) {
123 ImGui::SetTooltip(tr(
"Drag onto the canvas to add this panel.\n%s"),
124 entry.panel_id.c_str());
127 ++rendered_in_category;
129 close_current_category();
Base interface for all logical window content components.
std::vector< WindowContent * > GetAll()
Get all registered panels.