Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/docks/editor_dock.h
21102 views
1
/**************************************************************************/
2
/* editor_dock.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
#include "core/io/config_file.h"
34
#include "scene/gui/margin_container.h"
35
36
class DockTabContainer;
37
class Shortcut;
38
class WindowWrapper;
39
40
class EditorDock : public MarginContainer {
41
GDCLASS(EditorDock, MarginContainer);
42
43
public:
44
enum DockLayout {
45
DOCK_LAYOUT_VERTICAL = 1,
46
DOCK_LAYOUT_HORIZONTAL = 2,
47
DOCK_LAYOUT_FLOATING = 4,
48
DOCK_LAYOUT_ALL = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_HORIZONTAL | DOCK_LAYOUT_FLOATING,
49
};
50
51
enum DockSlot {
52
DOCK_SLOT_NONE = -1,
53
DOCK_SLOT_LEFT_UL,
54
DOCK_SLOT_LEFT_BL,
55
DOCK_SLOT_LEFT_UR,
56
DOCK_SLOT_LEFT_BR,
57
DOCK_SLOT_RIGHT_UL,
58
DOCK_SLOT_RIGHT_BL,
59
DOCK_SLOT_RIGHT_UR,
60
DOCK_SLOT_RIGHT_BR,
61
DOCK_SLOT_BOTTOM,
62
DOCK_SLOT_MAX
63
};
64
65
private:
66
friend class EditorDockManager;
67
friend class DockContextPopup;
68
friend class DockShortcutHandler;
69
70
String title;
71
String layout_key;
72
StringName icon_name;
73
Ref<Texture2D> dock_icon;
74
bool force_show_icon = false;
75
Color title_color = Color(0, 0, 0, 0);
76
Ref<Shortcut> shortcut;
77
DockSlot default_slot = DOCK_SLOT_NONE;
78
bool global = true;
79
bool transient = false;
80
bool closable = false;
81
82
DockLayout current_layout;
83
BitField<DockLayout> available_layouts = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_FLOATING;
84
85
bool is_open = false;
86
bool enabled = true;
87
int previous_tab_index = -1;
88
WindowWrapper *dock_window = nullptr;
89
DockTabContainer *parent_dock_container = nullptr;
90
int dock_slot_index = DOCK_SLOT_NONE;
91
92
void _set_default_slot_bind(DockSlot p_slot);
93
DockSlot _get_default_slot_bind() const { return default_slot; }
94
95
void _emit_changed();
96
97
protected:
98
void _notification(int p_what);
99
static void _bind_methods();
100
101
GDVIRTUAL1(_update_layout, int)
102
GDVIRTUAL2C(_save_layout_to_config, Ref<ConfigFile>, const String &)
103
GDVIRTUAL2(_load_layout_from_config, Ref<ConfigFile>, const String &)
104
105
public:
106
void open();
107
void make_visible();
108
void make_floating();
109
void close();
110
111
void set_title(const String &p_title);
112
String get_title() const { return title; }
113
114
void set_layout_key(const String &p_key) { layout_key = p_key; }
115
String get_layout_key() const { return layout_key; }
116
117
void set_global(bool p_global);
118
bool is_global() const { return global; }
119
120
void set_transient(bool p_transient) { transient = p_transient; }
121
bool is_transient() const { return transient; }
122
123
void set_closable(bool p_closable) { closable = p_closable; }
124
bool is_closable() const { return closable; }
125
126
void set_icon_name(const StringName &p_name);
127
StringName get_icon_name() const { return icon_name; }
128
129
void set_dock_icon(const Ref<Texture2D> &p_icon);
130
Ref<Texture2D> get_dock_icon() const { return dock_icon; }
131
132
void set_force_show_icon(bool p_force);
133
bool get_force_show_icon() const { return force_show_icon; }
134
135
void set_title_color(const Color &p_color);
136
Color get_title_color() const { return title_color; }
137
138
void set_dock_shortcut(const Ref<Shortcut> &p_shortcut);
139
Ref<Shortcut> get_dock_shortcut() const;
140
141
void set_default_slot(DockSlot p_slot);
142
DockSlot get_default_slot() const { return default_slot; }
143
144
void set_available_layouts(BitField<DockLayout> p_layouts) { available_layouts = p_layouts; }
145
BitField<DockLayout> get_available_layouts() const { return available_layouts; }
146
147
String get_display_title() const;
148
String get_effective_layout_key() const;
149
150
DockTabContainer *get_parent_container() const { return parent_dock_container; }
151
void set_tab_index(int p_index, bool p_set_current);
152
void update_tab_style();
153
Ref<Texture2D> get_effective_icon(const Callable &p_icon_fetch);
154
155
virtual void update_layout(DockLayout p_layout) { GDVIRTUAL_CALL(_update_layout, p_layout); }
156
DockLayout get_current_layout() const { return current_layout; }
157
158
virtual void save_layout_to_config(Ref<ConfigFile> &p_layout, const String &p_section) const { GDVIRTUAL_CALL(_save_layout_to_config, p_layout, p_section); }
159
virtual void load_layout_from_config(const Ref<ConfigFile> &p_layout, const String &p_section) { GDVIRTUAL_CALL(_load_layout_from_config, p_layout, p_section); }
160
};
161
162
VARIANT_BITFIELD_CAST(EditorDock::DockLayout);
163
VARIANT_ENUM_CAST(EditorDock::DockSlot);
164
165