Skip to content

Commit 58f7bd9

Browse files
committed
Remove remaining style hacks
1 parent 2efa006 commit 58f7bd9

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

editor/editor_node.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ void EditorNode::_update_theme(bool p_skip_creation) {
666666
}
667667

668668
editor_main_screen->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles)));
669+
bottom_panel->_theme_changed();
669670
distraction_free->set_button_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons)));
670671
distraction_free->add_theme_style_override(SceneStringName(pressed), theme->get_stylebox(CoreStringName(normal), "FlatMenuButton"));
671672

editor/gui/editor_bottom_panel.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
#include "scene/gui/button.h"
4343
#include "scene/gui/split_container.h"
4444

45-
void EditorBottomPanel::_update_margins() {
46-
TabContainer::_update_margins();
47-
get_tab_bar()->set_offset(SIDE_RIGHT, get_tab_bar()->get_offset(SIDE_RIGHT) - bottom_hbox->get_size().x);
48-
}
49-
5045
void EditorBottomPanel::_notification(int p_what) {
5146
switch (p_what) {
5247
case NOTIFICATION_THEME_CHANGED: {
@@ -60,8 +55,25 @@ void EditorBottomPanel::_on_tab_changed(int p_idx) {
6055
callable_mp(this, &EditorBottomPanel::_repaint).call_deferred();
6156
}
6257

58+
void EditorBottomPanel::_theme_changed() {
59+
Ref<StyleBox> bottom_tabbar_style = get_theme_stylebox("tabbar_background", "BottomPanel")->duplicate();
60+
bottom_tabbar_style->set_content_margin(SIDE_RIGHT, bottom_hbox->get_minimum_size().x + bottom_tabbar_style->get_content_margin(SIDE_LEFT));
61+
add_theme_style_override("tabbar_background", bottom_tabbar_style);
62+
63+
if (get_current_tab() == -1) {
64+
// Hide panel when not showing anything.
65+
remove_theme_style_override(SceneStringName(panel));
66+
} else {
67+
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
68+
}
69+
}
70+
6371
void EditorBottomPanel::_repaint() {
6472
bool panel_collapsed = get_current_tab() == -1;
73+
if (panel_collapsed == (get_previous_tab() == -1)) {
74+
return;
75+
}
76+
6577
SplitContainer *center_split = Object::cast_to<SplitContainer>(get_parent());
6678
ERR_FAIL_NULL(center_split);
6779

@@ -74,12 +86,7 @@ void EditorBottomPanel::_repaint() {
7486
EditorNode::get_top_split()->set_visible(panel_collapsed);
7587
}
7688

77-
if (panel_collapsed) {
78-
// Hide panel when not showing anything.
79-
remove_theme_style_override(SceneStringName(panel));
80-
} else {
81-
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
82-
}
89+
_theme_changed();
8390
}
8491

8592
void EditorBottomPanel::save_layout_to_config(Ref<ConfigFile> p_config_file, const String &p_section) const {
@@ -194,7 +201,6 @@ void EditorBottomPanel::_on_button_visibility_changed(Button *p_button, Control
194201
EditorBottomPanel::EditorBottomPanel() {
195202
get_tab_bar()->connect(SceneStringName(gui_input), callable_mp(EditorDockManager::get_singleton(), &EditorDockManager::_dock_container_gui_input).bind(this));
196203
get_tab_bar()->connect("tab_changed", callable_mp(this, &EditorBottomPanel::_on_tab_changed));
197-
set_custom_minimum_size(Size2(400 * EDSCALE, 0));
198204
set_tabs_position(TabPosition::POSITION_BOTTOM);
199205
set_deselect_enabled(true);
200206

editor/gui/editor_bottom_panel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class EditorBottomPanel : public TabContainer {
6060
protected:
6161
void _notification(int p_what);
6262

63-
virtual void _update_margins() override;
6463
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
6564

6665
public:
@@ -74,6 +73,7 @@ class EditorBottomPanel : public TabContainer {
7473
void hide_bottom_panel();
7574
void toggle_last_opened_bottom_panel();
7675
void set_expanded(bool p_expanded);
76+
void _theme_changed();
7777

7878
EditorBottomPanel();
7979
~EditorBottomPanel();

editor/themes/editor_theme_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
19711971

19721972
// Bottom panel.
19731973
Ref<StyleBoxFlat> style_bottom_panel = p_config.content_panel_style->duplicate();
1974-
style_bottom_panel->set_border_width_all(0);
1974+
style_bottom_panel->set_border_width(SIDE_BOTTOM, 0);
19751975
style_bottom_panel->set_corner_radius_all(p_config.corner_radius * EDSCALE);
19761976
style_bottom_panel->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
19771977
style_bottom_panel->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);

scene/gui/tab_container.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class TabContainer : public Container {
106106
void _repaint();
107107
void _refresh_tab_indices();
108108
void _refresh_tab_names();
109+
void _update_margins();
109110
void _on_mouse_exited();
110111
void _on_tab_changed(int p_tab);
111112
void _on_tab_clicked(int p_tab);
@@ -130,8 +131,6 @@ class TabContainer : public Container {
130131
virtual void remove_child_notify(Node *p_child) override;
131132
static void _bind_methods();
132133

133-
virtual void _update_margins();
134-
135134
public:
136135
virtual bool accessibility_override_tree_hierarchy() const override { return true; }
137136

0 commit comments

Comments
 (0)