Added a shortcut and button to quickly collapse / close the bottom panel (CTRL-B).

This commit is contained in:
Relintai 2023-09-09 14:03:10 +02:00
parent 36f9e5186b
commit ab82a74b04
3 changed files with 71 additions and 3 deletions

View File

@ -627,6 +627,7 @@ void EditorNode::_notification(int p_what) {
scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons"));
bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons"));
bottom_panel_collapse->set_icon(gui_base->get_theme_icon("CollapseBottomDock", "EditorIcons"));
// clear_button->set_icon(gui_base->get_theme_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property
dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
@ -4113,7 +4114,7 @@ Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_f
String class_name = p_class;
while (script.is_valid()) {
class_name = ScriptServer::get_global_class_name(script->get_path());
class_name = ScriptServer::get_global_class_name(script->get_path());
String current_icon_path = ed.script_class_get_icon_path(class_name);
icon = _load_custom_class_icon(current_icon_path);
if (icon.is_valid()) {
@ -5184,6 +5185,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
top_split->hide();
}
bottom_panel_raise->show();
bottom_panel_collapse->show();
} else {
bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer"));
@ -5192,6 +5194,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
center_split->set_collapsed(true);
bottom_panel_raise->hide();
bottom_panel_collapse->hide();
if (bottom_panel_raise->is_pressed()) {
top_split->show();
}
@ -5649,6 +5652,15 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) {
top_split->set_visible(!p_pressed);
}
void EditorNode::_bottom_panel_collapse_pressed() {
top_split->set_visible(true);
for (int i = 0; i < bottom_panel_items.size(); i++) {
bottom_panel_items[i].button->set_pressed(false);
bottom_panel_items[i].control->set_visible(false);
}
}
void EditorNode::_update_video_driver_color() {
// TODO: Probably should de-hardcode this and add to editor settings.
if (video_driver->get_text() == "GLES2") {
@ -5786,6 +5798,7 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_resources_reimported"), &EditorNode::_resources_reimported);
ClassDB::bind_method(D_METHOD("_bottom_panel_raise_toggled"), &EditorNode::_bottom_panel_raise_toggled);
ClassDB::bind_method(D_METHOD("_bottom_panel_collapse_pressed"), &EditorNode::_bottom_panel_collapse_pressed);
ClassDB::bind_method(D_METHOD("_on_plugin_ready"), &EditorNode::_on_plugin_ready);
@ -6883,11 +6896,16 @@ EditorNode::EditorNode() {
Control *h_spacer = memnew(Control);
bottom_panel_hb->add_child(h_spacer);
bottom_panel_collapse = memnew(ToolButton);
bottom_panel_collapse->set_icon(gui_base->get_theme_icon("CollapseBottomDock", "EditorIcons"));
bottom_panel_collapse->set_shortcut(ED_SHORTCUT("editor/bottom_panel_collapse", TTR("Collapse Bottom Panel"), KEY_MASK_CTRL | KEY_B));
bottom_panel_hb->add_child(bottom_panel_collapse);
bottom_panel_collapse->hide();
bottom_panel_collapse->connect("pressed", this, "_bottom_panel_collapse_pressed");
bottom_panel_raise = memnew(ToolButton);
bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons"));
bottom_panel_raise->set_shortcut(ED_SHORTCUT("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KEY_MASK_SHIFT | KEY_F12));
bottom_panel_hb->add_child(bottom_panel_raise);
bottom_panel_raise->hide();
bottom_panel_raise->set_toggle_mode(true);

View File

@ -710,6 +710,7 @@ private:
VBoxContainer *bottom_panel_vb;
LinkButton *version_btn;
ToolButton *bottom_panel_raise;
ToolButton *bottom_panel_collapse;
enum FileChangedActions {
FILE_CHANGED_ACTION_ASK = 0,
@ -730,6 +731,7 @@ private:
OptionButton *remember_disk_changed;
void _bottom_panel_raise_toggled(bool);
void _bottom_panel_collapse_pressed();
EditorInterface *editor_interface;

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="16"
viewBox="0 0 16 16"
width="16"
version="1.1"
id="svg3"
sodipodi:docname="icon_collapse_bottom_dock.svg"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs3" />
<sodipodi:namedview
id="namedview3"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="51.1875"
inkscape:cx="7.990232"
inkscape:cy="8"
inkscape:window-width="1920"
inkscape:window-height="1023"
inkscape:window-x="3840"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg3" />
<g
fill="#e0e0e0"
id="g3"
transform="rotate(180,8.0602361,7.2456305)">
<path
d="M 4.2130251,4.516057 0.6774912,8.0515909 H 3.2131761 V 13.025308 H 5.2130155 V 8.0515909 H 7.7487004 L 4.2131665,4.516057 Z"
id="path1" />
<path
d="M 11.907306,4.6119359 8.3717718,8.1474698 h 2.5356852 v 4.9737172 h 1.999839 V 8.1474698 h 2.535685 L 11.907447,4.6119359 Z"
id="path2" />
<path
d="m 1.288136,1.370074 h 14 v 1.830509 h -14 z"
id="path3" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB