From b5de7da80dedf7cd800b12acb5c5110935d8bd83 Mon Sep 17 00:00:00 2001 From: arkology <43543909+arkology@users.noreply.github.com> Date: Sat, 8 Feb 2025 12:42:54 +0300 Subject: [PATCH] Use `FlowContainer` for `EditorNetworkProfiler` bar (cherry picked from commit c7ef85a92fcf283e95438c86210118c94ed47de7) --- .../editor/editor_network_profiler.cpp | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/multiplayer/editor/editor_network_profiler.cpp b/modules/multiplayer/editor/editor_network_profiler.cpp index 1f9444ed72b..5a2611added 100644 --- a/modules/multiplayer/editor/editor_network_profiler.cpp +++ b/modules/multiplayer/editor/editor_network_profiler.cpp @@ -35,6 +35,7 @@ #include "editor/gui/editor_run_bar.h" #include "editor/themes/editor_scale.h" #include "scene/gui/check_box.h" +#include "scene/gui/flow_container.h" void EditorNetworkProfiler::_bind_methods() { ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable"))); @@ -297,30 +298,37 @@ bool EditorNetworkProfiler::is_profiling() { } EditorNetworkProfiler::EditorNetworkProfiler() { - HBoxContainer *hb = memnew(HBoxContainer); - hb->add_theme_constant_override("separation", 8 * EDSCALE); - add_child(hb); + FlowContainer *container = memnew(FlowContainer); + container->add_theme_constant_override(SNAME("h_separation"), 8 * EDSCALE); + container->add_theme_constant_override(SNAME("v_separation"), 2 * EDSCALE); + add_child(container); activate = memnew(Button); activate->set_toggle_mode(true); activate->set_text(TTR("Start")); activate->set_disabled(true); activate->connect(SceneStringName(pressed), callable_mp(this, &EditorNetworkProfiler::_activate_pressed)); - hb->add_child(activate); + container->add_child(activate); clear_button = memnew(Button); clear_button->set_text(TTR("Clear")); clear_button->set_disabled(true); clear_button->connect(SceneStringName(pressed), callable_mp(this, &EditorNetworkProfiler::_clear_pressed)); - hb->add_child(clear_button); + container->add_child(clear_button); CheckBox *autostart_checkbox = memnew(CheckBox); autostart_checkbox->set_text(TTR("Autostart")); autostart_checkbox->set_pressed(EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_network_profiler", false)); autostart_checkbox->connect(SceneStringName(toggled), callable_mp(this, &EditorNetworkProfiler::_autostart_toggled)); - hb->add_child(autostart_checkbox); + container->add_child(autostart_checkbox); - hb->add_spacer(); + Control *c = memnew(Control); + c->set_h_size_flags(SIZE_EXPAND_FILL); + container->add_child(c); + + HBoxContainer *hb = memnew(HBoxContainer); + hb->add_theme_constant_override(SNAME("separation"), 8 * EDSCALE); + container->add_child(hb); Label *lb = memnew(Label); // TRANSLATORS: This is the label for the network profiler's incoming bandwidth. @@ -359,7 +367,7 @@ EditorNetworkProfiler::EditorNetworkProfiler() { // RPC counters_display = memnew(Tree); - counters_display->set_custom_minimum_size(Size2(320, 0) * EDSCALE); + counters_display->set_custom_minimum_size(Size2(280, 0) * EDSCALE); counters_display->set_v_size_flags(SIZE_EXPAND_FILL); counters_display->set_h_size_flags(SIZE_EXPAND_FILL); counters_display->set_hide_folding(true); @@ -382,7 +390,7 @@ EditorNetworkProfiler::EditorNetworkProfiler() { // Replication replication_display = memnew(Tree); - replication_display->set_custom_minimum_size(Size2(320, 0) * EDSCALE); + replication_display->set_custom_minimum_size(Size2(280, 0) * EDSCALE); replication_display->set_v_size_flags(SIZE_EXPAND_FILL); replication_display->set_h_size_flags(SIZE_EXPAND_FILL); replication_display->set_hide_folding(true);