Skip to content

Commit 0fa6c9a

Browse files
committed
Make bottom panel into available dock slot
1 parent 86e750c commit 0fa6c9a

23 files changed

+459
-336
lines changed

doc/classes/EditorDock.xml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
</method>
6464
</methods>
6565
<members>
66-
<member name="available_layouts" type="int" setter="set_available_layouts" getter="get_available_layouts" enum="EditorDock.DockLayout" is_bitfield="true" default="1">
67-
The available layouts for this dock, as a bitmask.
68-
If you want to make all layouts available, use [code]available_layouts = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_HORIZONTAL[/code].
66+
<member name="available_layouts" type="int" setter="set_available_layouts" getter="get_available_layouts" enum="EditorDock.DockLayout" is_bitfield="true" default="5">
67+
The available layouts for this dock, as a bitmask. By default, the dock allows vertical and floating layouts.
68+
If you want to make all layouts available, use [code]available_layouts = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_HORIZONTAL | DOCK_LAYOUT_FLOATING[/code].
6969
</member>
7070
<member name="clip_contents" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" />
7171
<member name="default_slot" type="int" setter="set_default_slot" getter="get_default_slot" enum="EditorPlugin.DockSlot" default="-1">
@@ -78,6 +78,12 @@
7878
<member name="dock_shortcut" type="Shortcut" setter="set_dock_shortcut" getter="get_dock_shortcut">
7979
The shortcut used to open the dock. This property can only be set before this dock is added via [method EditorPlugin.add_dock].
8080
</member>
81+
<member name="global" type="bool" setter="set_global" getter="is_global" default="true">
82+
If [code]true[/code], the dock appears in the Editor &gt; Editor Docks menu and can be closed.
83+
</member>
84+
<member name="hidden" type="bool" setter="set_hidden" getter="is_hidden" default="false">
85+
If [code]true[/code], the dock's tab will be hidden. If [member global] is [code]true[/code], the dock will not appear in the dock menu.
86+
</member>
8187
<member name="icon_name" type="StringName" setter="set_icon_name" getter="get_icon_name" default="&amp;&quot;&quot;">
8288
The icon for the dock, as a name from the [code]EditorIcons[/code] theme type in the editor theme. You can find the list of available icons [url=https://godot-editor-icons.github.io/]here[/url].
8389
</member>
@@ -87,14 +93,19 @@
8793
<member name="title" type="String" setter="set_title" getter="get_title" default="&quot;&quot;">
8894
The title of the dock's tab. If empty, the dock's [member Node.name] will be used. If the name is auto-generated (contains [code]@[/code]), the first child's name will be used instead.
8995
</member>
96+
<member name="title_color" type="Color" setter="set_title_color" getter="get_title_color" default="Color(0, 0, 0, 0)">
97+
Color of the dock tab's title. If transparent, default color will be used.
98+
</member>
9099
</members>
91100
<constants>
92101
<constant name="DOCK_LAYOUT_VERTICAL" value="1" enum="DockLayout" is_bitfield="true">
93102
Allows placing the dock in the vertical dock slots on either side of the editor.
94-
[b]Note:[/b] Currently this flag has no effect because the bottom panel is not a proper dock slot. This means that the dock can always be vertical.
95103
</constant>
96104
<constant name="DOCK_LAYOUT_HORIZONTAL" value="2" enum="DockLayout" is_bitfield="true">
97-
Allows placing the dock in the editor's bottom panel. Implement [method _update_layout] to handle changing layouts.
105+
Allows placing the dock in the editor's bottom panel.
106+
</constant>
107+
<constant name="DOCK_LAYOUT_FLOATING" value="4" enum="DockLayout" is_bitfield="true">
108+
Allows making the dock float (open in a separate window).
98109
</constant>
99110
</constants>
100111
</class>

doc/classes/EditorPlugin.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@
424424
[b]Note:[/b] A plugin instance can belong only to a single context menu slot.
425425
</description>
426426
</method>
427-
<method name="add_control_to_bottom_panel">
427+
<method name="add_control_to_bottom_panel" deprecated="Use [method add_dock] instead, with [member EditorDock.default_slot] set to [constant DOCK_SLOT_BOTTOM].">
428428
<return type="Button" />
429429
<param index="0" name="control" type="Control" />
430430
<param index="1" name="title" type="String" />
@@ -662,7 +662,7 @@
662662
Removes the specified context menu plugin.
663663
</description>
664664
</method>
665-
<method name="remove_control_from_bottom_panel">
665+
<method name="remove_control_from_bottom_panel" deprecated="Use [method remove_dock] instead.">
666666
<return type="void" />
667667
<param index="0" name="control" type="Control" />
668668
<description>
@@ -910,7 +910,10 @@
910910
<constant name="DOCK_SLOT_RIGHT_BR" value="7" enum="DockSlot">
911911
Dock slot, right side, bottom-right (empty in default layout).
912912
</constant>
913-
<constant name="DOCK_SLOT_MAX" value="8" enum="DockSlot">
913+
<constant name="DOCK_SLOT_BOTTOM" value="8" enum="DockSlot">
914+
Bottom panel.
915+
</constant>
916+
<constant name="DOCK_SLOT_MAX" value="9" enum="DockSlot">
914917
Represents the size of the [enum DockSlot] enum.
915918
</constant>
916919
<constant name="AFTER_GUI_INPUT_PASS" value="0" enum="AfterGUIInput">

editor/debugger/editor_debugger_node.cpp

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

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));
73-
7468
tabs = memnew(TabContainer);
7569
tabs->set_tabs_visible(false);
7670
tabs->connect("tab_changed", callable_mp(this, &EditorDebuggerNode::_debugger_changed));
@@ -333,12 +327,6 @@ void EditorDebuggerNode::_notification(int p_what) {
333327
tabs->add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles)));
334328
}
335329

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));
341-
342330
remote_scene_tree->update_icon_max_width();
343331
} break;
344332

@@ -444,30 +432,28 @@ void EditorDebuggerNode::_update_errors() {
444432
last_error_count = error_count;
445433
last_warning_count = warning_count;
446434

447-
// TODO: Replace logic when EditorDock class is merged to be more flexible.
448-
TabContainer *parent = Object::cast_to<TabContainer>(get_parent());
435+
// TODO: Replace this hack once EditorDebuggerNode is converted to a dock.
436+
EditorDock *parent = Object::cast_to<EditorDock>(get_parent());
449437
if (!parent) {
450438
return;
451439
}
452440

453-
int idx = parent->get_tab_idx_from_control(this);
454-
455441
if (error_count == 0 && warning_count == 0) {
456442
set_name(TTR("Debugger"));
457-
parent->set_tab_icon(idx, Ref<Texture2D>());
458-
parent->get_tab_bar()->set_font_color_override_all(idx, Color(0, 0, 0, 0));
443+
parent->set_dock_icon(Ref<Texture2D>());
444+
parent->set_title_color(Color(0, 0, 0, 0));
459445
} else {
460446
set_name(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
461447
if (error_count >= 1 && warning_count >= 1) {
462-
parent->set_tab_icon(idx, get_editor_theme_icon(SNAME("ErrorWarning")));
448+
parent->set_dock_icon(get_editor_theme_icon(SNAME("ErrorWarning")));
463449
// Use error color to represent the highest level of severity reported.
464-
parent->get_tab_bar()->set_font_color_override_all(idx, get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
450+
parent->set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
465451
} else if (error_count >= 1) {
466-
parent->set_tab_icon(idx, get_editor_theme_icon(SNAME("Error")));
467-
parent->get_tab_bar()->set_font_color_override_all(idx, get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
452+
parent->set_dock_icon(get_editor_theme_icon(SNAME("Error")));
453+
parent->set_title_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
468454
} else {
469-
parent->set_tab_icon(idx, get_editor_theme_icon(SNAME("Warning")));
470-
parent->get_tab_bar()->set_font_color_override_all(idx, get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
455+
parent->set_dock_icon(get_editor_theme_icon(SNAME("Warning")));
456+
parent->set_title_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
471457
}
472458
}
473459
}

editor/docks/dock_constants.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**************************************************************************/
2+
/* dock_constants.h */
3+
/**************************************************************************/
4+
/* This file is part of: */
5+
/* GODOT ENGINE */
6+
/* https://godotengine.org */
7+
/**************************************************************************/
8+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10+
/* */
11+
/* Permission is hereby granted, free of charge, to any person obtaining */
12+
/* a copy of this software and associated documentation files (the */
13+
/* "Software"), to deal in the Software without restriction, including */
14+
/* without limitation the rights to use, copy, modify, merge, publish, */
15+
/* distribute, sublicense, and/or sell copies of the Software, and to */
16+
/* permit persons to whom the Software is furnished to do so, subject to */
17+
/* the following conditions: */
18+
/* */
19+
/* The above copyright notice and this permission notice shall be */
20+
/* included in all copies or substantial portions of the Software. */
21+
/* */
22+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29+
/**************************************************************************/
30+
31+
#pragma once
32+
33+
namespace DockConstants {
34+
35+
enum DockSlot {
36+
DOCK_SLOT_NONE = -1,
37+
DOCK_SLOT_LEFT_UL,
38+
DOCK_SLOT_LEFT_BL,
39+
DOCK_SLOT_LEFT_UR,
40+
DOCK_SLOT_LEFT_BR,
41+
DOCK_SLOT_RIGHT_UL,
42+
DOCK_SLOT_RIGHT_BL,
43+
DOCK_SLOT_RIGHT_UR,
44+
DOCK_SLOT_RIGHT_BR,
45+
DOCK_SLOT_BOTTOM,
46+
DOCK_SLOT_MAX
47+
};
48+
49+
enum DockLayout {
50+
DOCK_LAYOUT_VERTICAL = 1,
51+
DOCK_LAYOUT_HORIZONTAL = 2,
52+
DOCK_LAYOUT_FLOATING = 4,
53+
};
54+
55+
}; //namespace DockConstants

editor/docks/editor_dock.cpp

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
void EditorDock::_set_default_slot_bind(EditorPlugin::DockSlot p_slot) {
3737
ERR_FAIL_COND(p_slot < EditorPlugin::DOCK_SLOT_NONE || p_slot >= EditorPlugin::DOCK_SLOT_MAX);
38-
default_slot = (EditorDockManager::DockSlot)p_slot;
38+
default_slot = (DockConstants::DockSlot)p_slot;
3939
}
4040

4141
void EditorDock::_bind_methods() {
@@ -47,6 +47,14 @@ void EditorDock::_bind_methods() {
4747
ClassDB::bind_method(D_METHOD("get_layout_key"), &EditorDock::get_layout_key);
4848
ADD_PROPERTY(PropertyInfo(Variant::STRING, "layout_key"), "set_layout_key", "get_layout_key");
4949

50+
ClassDB::bind_method(D_METHOD("set_global", "global"), &EditorDock::set_global);
51+
ClassDB::bind_method(D_METHOD("is_global"), &EditorDock::is_global);
52+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "global"), "set_global", "is_global");
53+
54+
ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorDock::set_hidden);
55+
ClassDB::bind_method(D_METHOD("is_hidden"), &EditorDock::is_hidden);
56+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hidden"), "set_hidden", "is_hidden");
57+
5058
ClassDB::bind_method(D_METHOD("set_icon_name", "icon_name"), &EditorDock::set_icon_name);
5159
ClassDB::bind_method(D_METHOD("get_icon_name"), &EditorDock::get_icon_name);
5260
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "icon_name"), "set_icon_name", "get_icon_name");
@@ -55,6 +63,10 @@ void EditorDock::_bind_methods() {
5563
ClassDB::bind_method(D_METHOD("get_dock_icon"), &EditorDock::get_dock_icon);
5664
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "dock_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_dock_icon", "get_dock_icon");
5765

66+
ClassDB::bind_method(D_METHOD("set_title_color", "color"), &EditorDock::set_title_color);
67+
ClassDB::bind_method(D_METHOD("get_title_color"), &EditorDock::get_title_color);
68+
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "title_color"), "set_title_color", "get_title_color");
69+
5870
ClassDB::bind_method(D_METHOD("set_dock_shortcut", "shortcut"), &EditorDock::set_dock_shortcut);
5971
ClassDB::bind_method(D_METHOD("get_dock_shortcut"), &EditorDock::get_dock_shortcut);
6072
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "dock_shortcut", PROPERTY_HINT_RESOURCE_TYPE, "ShortCut"), "set_dock_shortcut", "get_dock_shortcut");
@@ -69,6 +81,7 @@ void EditorDock::_bind_methods() {
6981

7082
BIND_BITFIELD_FLAG(DOCK_LAYOUT_VERTICAL);
7183
BIND_BITFIELD_FLAG(DOCK_LAYOUT_HORIZONTAL);
84+
BIND_BITFIELD_FLAG(DOCK_LAYOUT_FLOATING);
7285

7386
GDVIRTUAL_BIND(_update_layout, "layout");
7487
GDVIRTUAL_BIND(_save_layout_to_config, "config", "section");
@@ -88,6 +101,24 @@ void EditorDock::set_title(const String &p_title) {
88101
emit_signal("tab_style_changed");
89102
}
90103

104+
void EditorDock::set_global(bool p_global) {
105+
if (global == p_global) {
106+
return;
107+
}
108+
global = p_global;
109+
if (is_inside_tree()) {
110+
EditorDockManager::get_singleton()->update_docks_menu();
111+
}
112+
}
113+
114+
void EditorDock::set_hidden(bool p_hidden) {
115+
if (hidden == p_hidden) {
116+
return;
117+
}
118+
hidden = p_hidden;
119+
emit_signal("tab_style_changed");
120+
}
121+
91122
void EditorDock::set_icon_name(const StringName &p_name) {
92123
if (icon_name == p_name) {
93124
return;
@@ -104,8 +135,23 @@ void EditorDock::set_dock_icon(const Ref<Texture2D> &p_icon) {
104135
emit_signal("tab_style_changed");
105136
}
106137

107-
void EditorDock::set_default_slot(EditorDockManager::DockSlot p_slot) {
108-
ERR_FAIL_INDEX(p_slot, EditorDockManager::DOCK_SLOT_MAX);
138+
void EditorDock::set_title_color(const Color &p_color) {
139+
if (title_color == p_color) {
140+
return;
141+
}
142+
title_color = p_color;
143+
emit_signal("tab_style_changed");
144+
}
145+
146+
void EditorDock::set_dock_shortcut(const Ref<Shortcut> &p_shortcut) {
147+
shortcut = p_shortcut;
148+
if (global && is_inside_tree()) {
149+
EditorDockManager::get_singleton()->update_docks_menu();
150+
}
151+
}
152+
153+
void EditorDock::set_default_slot(DockConstants::DockSlot p_slot) {
154+
ERR_FAIL_INDEX(p_slot, DockConstants::DOCK_SLOT_MAX);
109155
default_slot = p_slot;
110156
}
111157

editor/docks/editor_dock.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ class EditorDock : public MarginContainer {
4343

4444
public:
4545
enum DockLayout {
46-
DOCK_LAYOUT_VERTICAL = 1,
47-
DOCK_LAYOUT_HORIZONTAL = 2,
46+
DOCK_LAYOUT_VERTICAL = DockConstants::DOCK_LAYOUT_VERTICAL,
47+
DOCK_LAYOUT_HORIZONTAL = DockConstants::DOCK_LAYOUT_HORIZONTAL,
48+
DOCK_LAYOUT_FLOATING = DockConstants::DOCK_LAYOUT_FLOATING,
49+
DOCK_LAYOUT_ALL = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_HORIZONTAL | DOCK_LAYOUT_FLOATING,
4850
};
4951

5052
private:
@@ -55,18 +57,19 @@ class EditorDock : public MarginContainer {
5557
String layout_key;
5658
StringName icon_name;
5759
Ref<Texture2D> dock_icon;
60+
Color title_color = Color(0, 0, 0, 0);
5861
Ref<Shortcut> shortcut;
59-
EditorDockManager::DockSlot default_slot = EditorDockManager::DOCK_SLOT_NONE;
62+
DockConstants::DockSlot default_slot = DockConstants::DOCK_SLOT_NONE;
63+
bool global = true;
6064

61-
BitField<DockLayout> available_layouts = DOCK_LAYOUT_VERTICAL;
65+
BitField<DockLayout> available_layouts = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_FLOATING;
6266

6367
bool open = false;
68+
bool hidden = false;
6469
bool enabled = true;
65-
bool at_bottom = false;
6670
int previous_tab_index = -1;
67-
bool previous_at_bottom = false;
6871
WindowWrapper *dock_window = nullptr;
69-
int dock_slot_index = EditorDockManager::DOCK_SLOT_NONE;
72+
int dock_slot_index = DockConstants::DOCK_SLOT_NONE;
7073

7174
void _set_default_slot_bind(EditorPlugin::DockSlot p_slot);
7275
EditorPlugin::DockSlot _get_default_slot_bind() const { return (EditorPlugin::DockSlot)default_slot; }
@@ -87,17 +90,26 @@ class EditorDock : public MarginContainer {
8790
void set_layout_key(const String &p_key) { layout_key = p_key; }
8891
String get_layout_key() const { return layout_key; }
8992

93+
void set_global(bool p_global);
94+
bool is_global() const { return global; }
95+
96+
void set_hidden(bool p_hidden);
97+
bool is_hidden() const { return hidden; }
98+
9099
void set_icon_name(const StringName &p_name);
91100
StringName get_icon_name() const { return icon_name; }
92101

93102
void set_dock_icon(const Ref<Texture2D> &p_icon);
94103
Ref<Texture2D> get_dock_icon() const { return dock_icon; }
95104

96-
void set_dock_shortcut(const Ref<Shortcut> &p_shortcut) { shortcut = p_shortcut; }
105+
void set_title_color(const Color &p_color);
106+
Color get_title_color() const { return title_color; }
107+
108+
void set_dock_shortcut(const Ref<Shortcut> &p_shortcut);
97109
Ref<Shortcut> get_dock_shortcut() const { return shortcut; }
98110

99-
void set_default_slot(EditorDockManager::DockSlot p_slot);
100-
EditorDockManager::DockSlot get_default_slot() const { return default_slot; }
111+
void set_default_slot(DockConstants::DockSlot p_slot);
112+
DockConstants::DockSlot get_default_slot() const { return default_slot; }
101113

102114
void set_available_layouts(BitField<DockLayout> p_layouts) { available_layouts = p_layouts; }
103115
BitField<DockLayout> get_available_layouts() const { return available_layouts; }

0 commit comments

Comments
 (0)