Skip to content

Commit 100002a

Browse files
committed
Fix TabBar corner radius and generalize Debugger hack
1 parent 09ed9d4 commit 100002a

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
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);
@@ -332,9 +334,11 @@ void EditorDebuggerNode::_notification(int p_what) {
332334
tabs->add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles)));
333335
}
334336

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

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

editor/gui/editor_bottom_panel.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore
119119
items[i].button->set_pressed_no_signal(i == p_idx);
120120
items[i].control->set_visible(i == p_idx);
121121
}
122-
if (EditorDebuggerNode::get_singleton() == items[p_idx].control) {
123-
// This is the debug panel which uses tabs, so the top section should be smaller.
124-
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles)));
125-
} else {
126-
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
127-
}
128122

129123
center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
130124
center_split->set_collapsed(false);
@@ -136,7 +130,6 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx, bool p_ignore
136130
}
137131
callable_mp(button_scroll, &ScrollContainer::ensure_control_visible).call_deferred(items[p_idx].button);
138132
} else {
139-
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
140133
items[p_idx].button->set_pressed_no_signal(false);
141134
items[p_idx].control->set_visible(false);
142135
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
@@ -1141,7 +1141,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
11411141

11421142
Ref<StyleBoxFlat> style_tab_focus = p_config.button_style_focus->duplicate();
11431143

1144-
Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius * EDSCALE);
1144+
Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius);
11451145
style_tabbar_background->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
11461146
style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
11471147
p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background);
@@ -2525,18 +2525,6 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
25252525
Ref<StyleBoxFlat> debugger_panel_style = p_config.content_panel_style->duplicate();
25262526
debugger_panel_style->set_border_width(SIDE_BOTTOM, 0);
25272527
p_theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), debugger_panel_style);
2528-
2529-
// This pattern of get_font()->get_height(get_font_size()) is used quite a lot and is very verbose.
2530-
// FIXME: Introduce Theme::get_font_height() / Control::get_theme_font_height() / Window::get_theme_font_height().
2531-
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")));
2532-
const int offset_i2 = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height;
2533-
const int offset_i3 = p_theme->get_stylebox(SceneStringName(panel), SNAME("TabContainer"))->get_content_margin(SIDE_TOP);
2534-
const int invisible_top_offset = offset_i1 + offset_i2 + offset_i3;
2535-
2536-
Ref<StyleBoxFlat> invisible_top_panel_style = p_config.content_panel_style->duplicate();
2537-
invisible_top_panel_style->set_expand_margin(SIDE_TOP, -invisible_top_offset);
2538-
invisible_top_panel_style->set_content_margin(SIDE_TOP, 0);
2539-
p_theme->set_stylebox("BottomPanelDebuggerOverride", EditorStringName(EditorStyles), invisible_top_panel_style);
25402528
}
25412529

25422530
// Resource and node editors.

0 commit comments

Comments
 (0)