Fix TabBar corner radius and generalize Debugger hack

This commit is contained in:
Logan Detrick 2025-06-11 01:50:23 -07:00
parent 09ed9d4a93
commit 78045df591
4 changed files with 11 additions and 30 deletions

View file

@ -65,9 +65,11 @@ EditorDebuggerNode::EditorDebuggerNode() {
singleton = this; singleton = this;
} }
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT)); Ref<StyleBox> bottom_panel_margins = EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles));
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_top", -bottom_panel_margins->get_margin(SIDE_TOP));
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM)); 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 = memnew(TabContainer);
tabs->set_tabs_visible(false); 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))); 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)); Ref<StyleBox> bottom_panel_margins = EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles));
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_top", -bottom_panel_margins->get_margin(SIDE_TOP));
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM)); 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(); remote_scene_tree->update_icon_max_width();
} break; } break;

View file

@ -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_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)); 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(); _update_renderer_color();
} }

View file

@ -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].button->set_pressed_no_signal(i == p_idx);
items[i].control->set_visible(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_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
center_split->set_collapsed(false); 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); callable_mp(button_scroll, &ScrollContainer::ensure_control_visible).call_deferred(items[p_idx].button);
} else { } 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].button->set_pressed_no_signal(false);
items[p_idx].control->set_visible(false); items[p_idx].control->set_visible(false);
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);

View file

@ -1141,7 +1141,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
Ref<StyleBoxFlat> style_tab_focus = p_config.button_style_focus->duplicate(); Ref<StyleBoxFlat> style_tab_focus = p_config.button_style_focus->duplicate();
Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius * EDSCALE); Ref<StyleBoxFlat> 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_LEFT, 0);
style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0); style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background); p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background);
@ -2525,18 +2525,6 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
Ref<StyleBoxFlat> debugger_panel_style = p_config.content_panel_style->duplicate(); Ref<StyleBoxFlat> debugger_panel_style = p_config.content_panel_style->duplicate();
debugger_panel_style->set_border_width(SIDE_BOTTOM, 0); debugger_panel_style->set_border_width(SIDE_BOTTOM, 0);
p_theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), debugger_panel_style); 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<StyleBoxFlat> 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. // Resource and node editors.