Skip to content

Commit f45e708

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

21 files changed

+315
-277
lines changed

doc/classes/EditorDock.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
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">
66+
<member name="available_layouts" type="int" setter="set_available_layouts" getter="get_available_layouts" enum="EditorDock.DockLayout" is_bitfield="true" default="5">
6767
The available layouts for this dock, as a bitmask.
6868
If you want to make all layouts available, use [code]available_layouts = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_HORIZONTAL[/code].
6969
</member>
@@ -91,10 +91,12 @@
9191
<constants>
9292
<constant name="DOCK_LAYOUT_VERTICAL" value="1" enum="DockLayout" is_bitfield="true">
9393
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.
9594
</constant>
9695
<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.
96+
Allows placing the dock in the editor's bottom panel.
97+
</constant>
98+
<constant name="DOCK_LAYOUT_FLOATING" value="4" enum="DockLayout" is_bitfield="true">
99+
Allows making the dock float (open in a separate window).
98100
</constant>
99101
</constants>
100102
</class>

doc/classes/EditorPlugin.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 0 additions & 6 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));

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: 20 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() {
@@ -69,6 +69,7 @@ void EditorDock::_bind_methods() {
6969

7070
BIND_BITFIELD_FLAG(DOCK_LAYOUT_VERTICAL);
7171
BIND_BITFIELD_FLAG(DOCK_LAYOUT_HORIZONTAL);
72+
BIND_BITFIELD_FLAG(DOCK_LAYOUT_FLOATING);
7273

7374
GDVIRTUAL_BIND(_update_layout, "layout");
7475
GDVIRTUAL_BIND(_save_layout_to_config, "config", "section");
@@ -104,11 +105,27 @@ void EditorDock::set_dock_icon(const Ref<Texture2D> &p_icon) {
104105
emit_signal("tab_style_changed");
105106
}
106107

107-
void EditorDock::set_default_slot(EditorDockManager::DockSlot p_slot) {
108-
ERR_FAIL_INDEX(p_slot, EditorDockManager::DOCK_SLOT_MAX);
108+
void EditorDock::set_default_slot(DockConstants::DockSlot p_slot) {
109+
ERR_FAIL_INDEX(p_slot, DockConstants::DOCK_SLOT_MAX);
109110
default_slot = p_slot;
110111
}
111112

113+
void EditorDock::set_global(bool p_global) {
114+
if (global == p_global) {
115+
return;
116+
}
117+
global = p_global;
118+
// TODO: update dock menu
119+
}
120+
121+
void EditorDock::set_hidden(bool p_hidden) {
122+
if (hidden == p_hidden) {
123+
return;
124+
}
125+
hidden = p_hidden;
126+
emit_signal("tab_style_changed");
127+
}
128+
112129
String EditorDock::get_display_title() const {
113130
if (!title.is_empty()) {
114131
return title;

editor/docks/editor_dock.h

Lines changed: 14 additions & 9 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:
@@ -56,17 +58,17 @@ class EditorDock : public MarginContainer {
5658
StringName icon_name;
5759
Ref<Texture2D> dock_icon;
5860
Ref<Shortcut> shortcut;
59-
EditorDockManager::DockSlot default_slot = EditorDockManager::DOCK_SLOT_NONE;
61+
DockConstants::DockSlot default_slot = DockConstants::DOCK_SLOT_NONE;
62+
bool global = true;
6063

61-
BitField<DockLayout> available_layouts = DOCK_LAYOUT_VERTICAL;
64+
BitField<DockLayout> available_layouts = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_FLOATING;
6265

6366
bool open = false;
67+
bool hidden = false;
6468
bool enabled = true;
65-
bool at_bottom = false;
6669
int previous_tab_index = -1;
67-
bool previous_at_bottom = false;
6870
WindowWrapper *dock_window = nullptr;
69-
int dock_slot_index = EditorDockManager::DOCK_SLOT_NONE;
71+
int dock_slot_index = DockConstants::DOCK_SLOT_NONE;
7072

7173
void _set_default_slot_bind(EditorPlugin::DockSlot p_slot);
7274
EditorPlugin::DockSlot _get_default_slot_bind() const { return (EditorPlugin::DockSlot)default_slot; }
@@ -96,12 +98,15 @@ class EditorDock : public MarginContainer {
9698
void set_dock_shortcut(const Ref<Shortcut> &p_shortcut) { shortcut = p_shortcut; }
9799
Ref<Shortcut> get_dock_shortcut() const { return shortcut; }
98100

99-
void set_default_slot(EditorDockManager::DockSlot p_slot);
100-
EditorDockManager::DockSlot get_default_slot() const { return default_slot; }
101+
void set_default_slot(DockConstants::DockSlot p_slot);
102+
DockConstants::DockSlot get_default_slot() const { return default_slot; }
101103

102104
void set_available_layouts(BitField<DockLayout> p_layouts) { available_layouts = p_layouts; }
103105
BitField<DockLayout> get_available_layouts() const { return available_layouts; }
104106

107+
void set_global(bool p_global);
108+
void set_hidden(bool p_hidden);
109+
105110
String get_display_title() const;
106111
String get_effective_layout_key() const;
107112

0 commit comments

Comments
 (0)