Merge pull request #119586 from LeavingPython33/fold_categories_in_profiler

Add ability to fold categories in Profiler
This commit is contained in:
Thaddeus Crews
2026-06-23 14:49:09 -05:00
2 changed files with 21 additions and 1 deletions
+19 -1
View File
@@ -188,6 +188,20 @@ void EditorProfiler::_item_edited() {
_update_plot();
}
void EditorProfiler::_item_collapsed(TreeItem *p_item) {
if (!p_item) {
return;
}
StringName signature = p_item->get_metadata(0);
bool collapsed = p_item->is_collapsed();
if (collapsed) {
collapsed_categories.insert(signature);
} else {
collapsed_categories.erase(signature);
}
}
void EditorProfiler::_update_plot() {
const int w = MAX(1, graph->get_size().width); // Clamp to 1 to prevent from crashing when profiler is autostarted.
const int h = MAX(1, graph->get_size().height);
@@ -364,6 +378,10 @@ void EditorProfiler::_update_frame() {
category->set_auto_translate_mode(0, AUTO_TRANSLATE_MODE_DISABLED);
category->set_text(1, _get_time_as_text(m, m.categories[i].total_time, 1));
if (collapsed_categories.has(m.categories[i].signature)) {
category->set_collapsed(true);
}
if (plot_sigs.has(m.categories[i].signature)) {
category->set_checked(0, true);
category->set_custom_color(0, _get_color_from_signature(m.categories[i].signature));
@@ -757,7 +775,6 @@ EditorProfiler::EditorProfiler() {
variables = memnew(Tree);
variables->set_custom_minimum_size(Size2(320, 0) * EDSCALE);
variables->set_hide_folding(true);
h_split->add_child(variables);
variables->set_hide_root(true);
variables->set_columns(3);
@@ -776,6 +793,7 @@ EditorProfiler::EditorProfiler() {
variables->set_column_custom_minimum_width(2, 50 * EDSCALE);
variables->set_theme_type_variation("TreeSecondary");
variables->connect("item_edited", callable_mp(this, &EditorProfiler::_item_edited));
variables->connect("item_collapsed", callable_mp(this, &EditorProfiler::_item_collapsed));
graph = memnew(TextureRect);
graph->set_custom_minimum_size(Size2(250 * EDSCALE, 0));
+2
View File
@@ -111,6 +111,7 @@ private:
HSplitContainer *h_split = nullptr;
HashSet<StringName> plot_sigs;
HashSet<StringName> collapsed_categories;
OptionButton *display_mode = nullptr;
OptionButton *display_time = nullptr;
@@ -147,6 +148,7 @@ private:
void _make_metric_ptrs(Metric &m);
void _item_edited();
void _item_collapsed(TreeItem *p_item);
void _update_plot();