Skip to content

Commit 5889413

Browse files
committed
Merge pull request #107395 from lodetrick/bottom-panel-margin-fixes
Fix TabContainer Editor theming and remove Debugger style hacks
2 parents 40dde2a + 78045df commit 5889413

File tree

4 files changed

+11
-30
lines changed

4 files changed

+11
-30
lines changed

editor/debugger/editor_debugger_node.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ EditorDebuggerNode::EditorDebuggerNode() {
6565
singleton = this;
6666
}
6767

68-
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT));
69-
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT));
70-
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM));
68+
Ref<StyleBox> bottom_panel_margins = EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles));
69+
add_theme_constant_override("margin_top", -bottom_panel_margins->get_margin(SIDE_TOP));
70+
add_theme_constant_override("margin_left", -bottom_panel_margins->get_margin(SIDE_LEFT));
71+
add_theme_constant_override("margin_right", -bottom_panel_margins->get_margin(SIDE_RIGHT));
72+
add_theme_constant_override("margin_bottom", -bottom_panel_margins->get_margin(SIDE_BOTTOM));
7173

7274
tabs = memnew(TabContainer);
7375
tabs->set_tabs_visible(false);
@@ -331,9 +333,11 @@ void EditorDebuggerNode::_notification(int p_what) {
331333
tabs->add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles)));
332334
}
333335

334-
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT));
335-
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT));
336-
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM));
336+
Ref<StyleBox> bottom_panel_margins = EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles));
337+
add_theme_constant_override("margin_top", -bottom_panel_margins->get_margin(SIDE_TOP));
338+
add_theme_constant_override("margin_left", -bottom_panel_margins->get_margin(SIDE_LEFT));
339+
add_theme_constant_override("margin_right", -bottom_panel_margins->get_margin(SIDE_RIGHT));
340+
add_theme_constant_override("margin_bottom", -bottom_panel_margins->get_margin(SIDE_BOTTOM));
337341

338342
remote_scene_tree->update_icon_max_width();
339343
} break;

editor/editor_node.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,6 @@ void EditorNode::_update_theme(bool p_skip_creation) {
683683
help_menu->set_item_icon(help_menu->get_item_index(HELP_ABOUT), _get_editor_theme_native_menu_icon(SNAME("Godot"), global_menu, dark_mode));
684684
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));
685685

686-
if (EditorDebuggerNode::get_singleton()->is_visible()) {
687-
bottom_panel->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles)));
688-
}
689-
690686
_update_renderer_color();
691687
}
692688

editor/gui/editor_bottom_panel.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,6 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore
128128
items[i].button->set_pressed_no_signal(i == p_idx);
129129
items[i].control->set_visible(i == p_idx);
130130
}
131-
if (EditorDebuggerNode::get_singleton() == items[p_idx].control) {
132-
// This is the debug panel which uses tabs, so the top section should be smaller.
133-
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles)));
134-
} else {
135-
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
136-
}
137131

138132
center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
139133
center_split->set_collapsed(false);
@@ -145,7 +139,6 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore
145139
}
146140
callable_mp(this, &EditorBottomPanel::_ensure_control_visible).call_deferred(items[p_idx].button->get_instance_id());
147141
} else {
148-
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
149142
items[p_idx].button->set_pressed_no_signal(false);
150143
items[p_idx].control->set_visible(false);
151144
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);

editor/themes/editor_theme_manager.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
11471147

11481148
Ref<StyleBoxFlat> style_tab_focus = p_config.button_style_focus->duplicate();
11491149

1150-
Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius * EDSCALE);
1150+
Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius);
11511151
style_tabbar_background->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
11521152
style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
11531153
p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background);
@@ -2553,18 +2553,6 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
25532553
Ref<StyleBoxFlat> debugger_panel_style = p_config.content_panel_style->duplicate();
25542554
debugger_panel_style->set_border_width(SIDE_BOTTOM, 0);
25552555
p_theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), debugger_panel_style);
2556-
2557-
// This pattern of get_font()->get_height(get_font_size()) is used quite a lot and is very verbose.
2558-
// FIXME: Introduce Theme::get_font_height() / Control::get_theme_font_height() / Window::get_theme_font_height().
2559-
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")));
2560-
const int offset_i2 = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height;
2561-
const int offset_i3 = p_theme->get_stylebox(SceneStringName(panel), SNAME("TabContainer"))->get_content_margin(SIDE_TOP);
2562-
const int invisible_top_offset = offset_i1 + offset_i2 + offset_i3;
2563-
2564-
Ref<StyleBoxFlat> invisible_top_panel_style = p_config.content_panel_style->duplicate();
2565-
invisible_top_panel_style->set_expand_margin(SIDE_TOP, -invisible_top_offset);
2566-
invisible_top_panel_style->set_content_margin(SIDE_TOP, 0);
2567-
p_theme->set_stylebox("BottomPanelDebuggerOverride", EditorStringName(EditorStyles), invisible_top_panel_style);
25682556
}
25692557

25702558
// Resource and node editors.

0 commit comments

Comments
 (0)