31
31
#include " editor_bottom_panel.h"
32
32
33
33
#include " editor/debugger/editor_debugger_node.h"
34
- #include " editor/editor_about.h"
35
34
#include " editor/editor_command_palette.h"
36
35
#include " editor/editor_node.h"
37
36
#include " editor/editor_string_names.h"
38
- #include " editor/engine_update_label.h"
39
37
#include " editor/gui/editor_toaster.h"
40
38
#include " editor/gui/editor_version_button.h"
41
39
#include " editor/themes/editor_scale.h"
42
40
#include " scene/gui/box_container.h"
43
41
#include " scene/gui/button.h"
42
+ #include " scene/gui/split_container.h"
44
43
45
44
void EditorBottomPanel::_notification (int p_what) {
46
45
switch (p_what) {
47
46
case NOTIFICATION_THEME_CHANGED: {
47
+ pin_button->set_button_icon (get_editor_theme_icon (SNAME (" Pin" )));
48
48
expand_button->set_button_icon (get_editor_theme_icon (SNAME (" ExpandBottomDock" )));
49
49
} break ;
50
50
}
51
51
}
52
52
53
- void EditorBottomPanel::_switch_by_control (bool p_visible, Control *p_control) {
53
+ void EditorBottomPanel::_switch_by_control (bool p_visible, Control *p_control, bool p_ignore_lock ) {
54
54
for (int i = 0 ; i < items.size (); i++) {
55
55
if (items[i].control == p_control) {
56
- _switch_to_item (p_visible, i);
56
+ _switch_to_item (p_visible, i, p_ignore_lock );
57
57
return ;
58
58
}
59
59
}
60
60
}
61
61
62
- void EditorBottomPanel::_switch_to_item (bool p_visible, int p_idx) {
62
+ void EditorBottomPanel::_switch_to_item (bool p_visible, int p_idx, bool p_ignore_lock ) {
63
63
ERR_FAIL_INDEX (p_idx, items.size ());
64
64
65
65
if (items[p_idx].control ->is_visible () == p_visible) {
@@ -70,6 +70,10 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx) {
70
70
ERR_FAIL_NULL (center_split);
71
71
72
72
if (p_visible) {
73
+ if (!p_ignore_lock && lock_panel_switching && pin_button->is_visible ()) {
74
+ return ;
75
+ }
76
+
73
77
for (int i = 0 ; i < items.size (); i++) {
74
78
items[i].button ->set_pressed_no_signal (i == p_idx);
75
79
items[i].control ->set_visible (i == p_idx);
@@ -80,18 +84,23 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx) {
80
84
} else {
81
85
add_theme_style_override (SceneStringName (panel), get_theme_stylebox (SNAME (" BottomPanel" ), EditorStringName (EditorStyles)));
82
86
}
87
+
83
88
center_split->set_dragger_visibility (SplitContainer::DRAGGER_VISIBLE);
84
89
center_split->set_collapsed (false );
90
+ pin_button->show ();
91
+
92
+ expand_button->show ();
85
93
if (expand_button->is_pressed ()) {
86
94
EditorNode::get_top_split ()->hide ();
87
95
}
88
- expand_button->show ();
89
96
} else {
90
97
add_theme_style_override (SceneStringName (panel), get_theme_stylebox (SNAME (" BottomPanel" ), EditorStringName (EditorStyles)));
91
98
items[p_idx].button ->set_pressed_no_signal (false );
92
99
items[p_idx].control ->set_visible (false );
93
100
center_split->set_dragger_visibility (SplitContainer::DRAGGER_HIDDEN);
94
101
center_split->set_collapsed (true );
102
+ pin_button->hide ();
103
+
95
104
expand_button->hide ();
96
105
if (expand_button->is_pressed ()) {
97
106
EditorNode::get_top_split ()->show ();
@@ -101,13 +110,17 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx) {
101
110
last_opened_control = items[p_idx].control ;
102
111
}
103
112
113
+ void EditorBottomPanel::_pin_button_toggled (bool p_pressed) {
114
+ lock_panel_switching = p_pressed;
115
+ }
116
+
104
117
void EditorBottomPanel::_expand_button_toggled (bool p_pressed) {
105
118
EditorNode::get_top_split ()->set_visible (!p_pressed);
106
119
}
107
120
108
121
bool EditorBottomPanel::_button_drag_hover (const Vector2 &, const Variant &, Button *p_button, Control *p_control) {
109
122
if (!p_button->is_pressed ()) {
110
- _switch_by_control (true , p_control);
123
+ _switch_by_control (true , p_control, true );
111
124
}
112
125
return false ;
113
126
}
@@ -149,7 +162,7 @@ void EditorBottomPanel::load_layout_from_config(Ref<ConfigFile> p_config_file, c
149
162
Button *EditorBottomPanel::add_item (String p_text, Control *p_item, const Ref<Shortcut> &p_shortcut, bool p_at_front) {
150
163
Button *tb = memnew (Button );
151
164
tb->set_theme_type_variation (" BottomPanelButton" );
152
- tb->connect (SceneStringName (toggled), callable_mp (this , &EditorBottomPanel::_switch_by_control).bind (p_item));
165
+ tb->connect (SceneStringName (toggled), callable_mp (this , &EditorBottomPanel::_switch_by_control).bind (p_item, true ));
153
166
tb->set_drag_forwarding (Callable (), callable_mp (this , &EditorBottomPanel::_button_drag_hover).bind (tb, p_item), Callable ());
154
167
tb->set_text (p_text);
155
168
tb->set_shortcut (p_shortcut);
@@ -231,10 +244,10 @@ void EditorBottomPanel::toggle_last_opened_bottom_panel() {
231
244
// Select by control instead of index, so that the last bottom panel is opened correctly
232
245
// if it's been reordered since.
233
246
if (last_opened_control) {
234
- _switch_by_control (!last_opened_control->is_visible (), last_opened_control);
247
+ _switch_by_control (!last_opened_control->is_visible (), last_opened_control, true );
235
248
} else {
236
249
// Open the first panel in the list if no panel was opened this session.
237
- _switch_to_item (true , 0 );
250
+ _switch_to_item (true , 0 , true );
238
251
}
239
252
}
240
253
@@ -263,10 +276,17 @@ EditorBottomPanel::EditorBottomPanel() {
263
276
Control *h_spacer = memnew (Control);
264
277
bottom_hbox->add_child (h_spacer);
265
278
279
+ pin_button = memnew (Button );
280
+ bottom_hbox->add_child (pin_button);
281
+ pin_button->hide ();
282
+ pin_button->set_theme_type_variation (" FlatMenuButton" );
283
+ pin_button->set_toggle_mode (true );
284
+ pin_button->set_tooltip_text (TTR (" Pin Bottom Panel Switching" ));
285
+ pin_button->connect (SceneStringName (toggled), callable_mp (this , &EditorBottomPanel::_pin_button_toggled));
286
+
266
287
expand_button = memnew (Button );
267
288
bottom_hbox->add_child (expand_button);
268
289
expand_button->hide ();
269
- expand_button->set_flat (false );
270
290
expand_button->set_theme_type_variation (" FlatMenuButton" );
271
291
expand_button->set_toggle_mode (true );
272
292
expand_button->set_shortcut (ED_SHORTCUT_AND_COMMAND (" editor/bottom_panel_expand" , TTR (" Expand Bottom Panel" ), KeyModifierMask::SHIFT | Key::F12));
0 commit comments