From 78045df591c24c41159d336af28f4179695e7d98 Mon Sep 17 00:00:00 2001 From: Logan Detrick Date: Wed, 11 Jun 2025 01:50:23 -0700 Subject: [PATCH] Fix TabBar corner radius and generalize Debugger hack --- editor/debugger/editor_debugger_node.cpp | 16 ++++++++++------ editor/editor_node.cpp | 4 ---- editor/gui/editor_bottom_panel.cpp | 7 ------- editor/themes/editor_theme_manager.cpp | 14 +------------- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index ccf9463ebd5..3d947201e6a 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -65,9 +65,11 @@ EditorDebuggerNode::EditorDebuggerNode() { singleton = this; } - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT)); - add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM)); + Ref bottom_panel_margins = EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)); + add_theme_constant_override("margin_top", -bottom_panel_margins->get_margin(SIDE_TOP)); + add_theme_constant_override("margin_left", -bottom_panel_margins->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -bottom_panel_margins->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_bottom", -bottom_panel_margins->get_margin(SIDE_BOTTOM)); tabs = memnew(TabContainer); tabs->set_tabs_visible(false); @@ -332,9 +334,11 @@ void EditorDebuggerNode::_notification(int p_what) { tabs->add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles))); } - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT)); - add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM)); + Ref bottom_panel_margins = EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)); + add_theme_constant_override("margin_top", -bottom_panel_margins->get_margin(SIDE_TOP)); + add_theme_constant_override("margin_left", -bottom_panel_margins->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -bottom_panel_margins->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_bottom", -bottom_panel_margins->get_margin(SIDE_BOTTOM)); remote_scene_tree->update_icon_max_width(); } break; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index e7b74b79e1d..a88161be7a8 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -631,10 +631,6 @@ void EditorNode::_update_theme(bool p_skip_creation) { help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), _get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode)); help_menu->set_item_icon(help_menu->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), _get_editor_theme_native_menu_icon(SNAME("Heart"), global_menu, dark_mode)); - if (EditorDebuggerNode::get_singleton()->is_visible()) { - bottom_panel->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))); - } - _update_renderer_color(); } diff --git a/editor/gui/editor_bottom_panel.cpp b/editor/gui/editor_bottom_panel.cpp index fab41e1c862..0d97c695c12 100644 --- a/editor/gui/editor_bottom_panel.cpp +++ b/editor/gui/editor_bottom_panel.cpp @@ -119,12 +119,6 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore items[i].button->set_pressed_no_signal(i == p_idx); items[i].control->set_visible(i == p_idx); } - if (EditorDebuggerNode::get_singleton() == items[p_idx].control) { - // This is the debug panel which uses tabs, so the top section should be smaller. - add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))); - } else { - add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); - } center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); @@ -136,7 +130,6 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore } callable_mp(button_scroll, &ScrollContainer::ensure_control_visible).call_deferred(items[p_idx].button); } else { - add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); items[p_idx].button->set_pressed_no_signal(false); items[p_idx].control->set_visible(false); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp index 0a4c7bed52d..9c847906c3c 100644 --- a/editor/themes/editor_theme_manager.cpp +++ b/editor/themes/editor_theme_manager.cpp @@ -1141,7 +1141,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref &p_the Ref style_tab_focus = p_config.button_style_focus->duplicate(); - Ref style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius * EDSCALE); + Ref style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius); style_tabbar_background->set_corner_radius(CORNER_BOTTOM_LEFT, 0); style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0); p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background); @@ -2525,18 +2525,6 @@ void EditorThemeManager::_populate_editor_styles(const Ref &p_theme Ref debugger_panel_style = p_config.content_panel_style->duplicate(); debugger_panel_style->set_border_width(SIDE_BOTTOM, 0); p_theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), debugger_panel_style); - - // This pattern of get_font()->get_height(get_font_size()) is used quite a lot and is very verbose. - // FIXME: Introduce Theme::get_font_height() / Control::get_theme_font_height() / Window::get_theme_font_height(). - const int offset_i1 = p_theme->get_font(SNAME("tab_selected"), SNAME("TabContainer"))->get_height(p_theme->get_font_size(SNAME("tab_selected"), SNAME("TabContainer"))); - const int offset_i2 = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height; - const int offset_i3 = p_theme->get_stylebox(SceneStringName(panel), SNAME("TabContainer"))->get_content_margin(SIDE_TOP); - const int invisible_top_offset = offset_i1 + offset_i2 + offset_i3; - - Ref invisible_top_panel_style = p_config.content_panel_style->duplicate(); - invisible_top_panel_style->set_expand_margin(SIDE_TOP, -invisible_top_offset); - invisible_top_panel_style->set_content_margin(SIDE_TOP, 0); - p_theme->set_stylebox("BottomPanelDebuggerOverride", EditorStringName(EditorStyles), invisible_top_panel_style); } // Resource and node editors.