From da9172693474c7d71d289de3abf9eb12ad2d3d17 Mon Sep 17 00:00:00 2001 From: Giganzo <158825920+Giganzo@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:02:25 +0100 Subject: [PATCH] Fix bottom panel sizing with multiple options --- editor/gui/editor_bottom_panel.cpp | 145 ++++++++++++++++++++++++++++- editor/gui/editor_bottom_panel.h | 18 ++++ 2 files changed, 158 insertions(+), 5 deletions(-) diff --git a/editor/gui/editor_bottom_panel.cpp b/editor/gui/editor_bottom_panel.cpp index 3cc1e37be06a..ca2365787c82 100644 --- a/editor/gui/editor_bottom_panel.cpp +++ b/editor/gui/editor_bottom_panel.cpp @@ -37,15 +37,27 @@ #include "editor/gui/editor_toaster.h" #include "editor/gui/editor_version_button.h" #include "editor/themes/editor_scale.h" +#include "editor/themes/editor_theme_manager.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" +#include "scene/gui/menu_button.h" #include "scene/gui/split_container.h" +#include "scene/resources/style_box_flat.h" void EditorBottomPanel::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { pin_button->set_button_icon(get_editor_theme_icon(SNAME("Pin"))); expand_button->set_button_icon(get_editor_theme_icon(SNAME("ExpandBottomDock"))); + button_menu_btn->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl"))); + + if (get_theme_color(SNAME("base_color"), EditorStringName(Editor)) != Color(0, 0, 0)) { + stylebox_shadow_left->set_border_color(get_theme_color(SNAME("dark_color_1")) * Color(1, 1, 1, EditorThemeManager::is_dark_theme() ? 0.4 : 0.3)); + stylebox_shadow_right->set_border_color(get_theme_color(SNAME("dark_color_1")) * Color(1, 1, 1, EditorThemeManager::is_dark_theme() ? 0.4 : 0.3)); + } else { + stylebox_shadow_left->set_border_color(Color(0.3, 0.3, 0.3, 0.45)); + stylebox_shadow_right->set_border_color(Color(0.3, 0.3, 0.3, 0.45)); + } } break; } } @@ -53,7 +65,7 @@ void EditorBottomPanel::_notification(int p_what) { void EditorBottomPanel::_switch_by_control(bool p_visible, Control *p_control, bool p_ignore_lock) { for (int i = 0; i < items.size(); i++) { if (items[i].control == p_control) { - _switch_to_item(p_visible, i, p_ignore_lock); + callable_mp(this, &EditorBottomPanel::_switch_to_item).call_deferred(p_visible, i, p_ignore_lock); return; } } @@ -62,7 +74,12 @@ void EditorBottomPanel::_switch_by_control(bool p_visible, Control *p_control, b void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore_lock) { ERR_FAIL_INDEX(p_idx, items.size()); + if (get_tree()->is_connected("process_frame", callable_mp(this, &EditorBottomPanel::_focus_pressed_button))) { + get_tree()->disconnect("process_frame", callable_mp(this, &EditorBottomPanel::_focus_pressed_button)); + } + if (items[p_idx].control->is_visible() == p_visible) { + get_tree()->connect("process_frame", callable_mp(this, &EditorBottomPanel::_focus_pressed_button).bind(items[p_idx].button->get_instance_id()), CONNECT_ONE_SHOT); return; } @@ -84,7 +101,7 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore } else { add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); } - + get_tree()->connect("process_frame", callable_mp(this, &EditorBottomPanel::_focus_pressed_button).bind(items[p_idx].button->get_instance_id()), CONNECT_ONE_SHOT); center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); pin_button->show(); @@ -125,6 +142,78 @@ bool EditorBottomPanel::_button_drag_hover(const Vector2 &, const Variant &, But return false; } +void EditorBottomPanel::_focus_pressed_button(ObjectID btn_id) { + Object *btn_instance = ObjectDB::get_instance(btn_id); + if (!btn_instance) { + return; + } + button_sc->ensure_control_visible(Object::cast_to