forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheditor_dock_manager.h
142 lines (115 loc) · 5.25 KB
/
editor_dock_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**************************************************************************/
/* editor_dock_manager.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef EDITOR_DOCK_MANAGER_H
#define EDITOR_DOCK_MANAGER_H
#include "scene/gui/split_container.h"
class Button;
class ConfigFile;
class Control;
class PopupPanel;
class TabContainer;
class WindowWrapper;
class DockSplitContainer : public SplitContainer {
GDCLASS(DockSplitContainer, SplitContainer);
private:
bool is_updating = false;
protected:
void _update_visibility();
virtual void add_child_notify(Node *p_child) override;
virtual void remove_child_notify(Node *p_child) override;
};
class EditorDockManager : public Object {
GDCLASS(EditorDockManager, Object);
public:
enum DockSlot {
DOCK_SLOT_LEFT_UL,
DOCK_SLOT_LEFT_BL,
DOCK_SLOT_LEFT_UR,
DOCK_SLOT_LEFT_BR,
DOCK_SLOT_RIGHT_UL,
DOCK_SLOT_RIGHT_BL,
DOCK_SLOT_RIGHT_UR,
DOCK_SLOT_RIGHT_BR,
DOCK_SLOT_MAX
};
private:
static EditorDockManager *singleton;
// To access splits easily by index.
Vector<DockSplitContainer *> vsplits;
Vector<DockSplitContainer *> hsplits;
Vector<WindowWrapper *> floating_docks;
Vector<Control *> bottom_docks;
TabContainer *dock_slot[DOCK_SLOT_MAX];
bool docks_visible = true;
PopupPanel *dock_select_popup = nullptr;
Button *dock_float = nullptr;
Button *dock_to_bottom = nullptr;
Button *dock_tab_move_left = nullptr;
Button *dock_tab_move_right = nullptr;
Control *dock_select = nullptr;
Rect2 dock_select_rect[DOCK_SLOT_MAX];
int dock_select_rect_over_idx = -1;
int dock_popup_selected_idx = -1;
int dock_bottom_selected_idx = -1;
void _dock_select_popup_theme_changed();
void _dock_popup_exit();
void _dock_pre_popup(int p_dock_slot);
void _dock_move_left();
void _dock_move_right();
void _dock_select_input(const Ref<InputEvent> &p_input);
void _dock_select_draw();
void _dock_split_dragged(int p_offset);
void _dock_tab_changed(int p_tab);
void _edit_current();
void _dock_floating_close_request(WindowWrapper *p_wrapper);
void _dock_make_selected_float();
void _dock_make_float(Control *p_control, int p_slot_index, bool p_show_window = true);
void _restore_floating_dock(const Dictionary &p_dock_dump, Control *p_wrapper, int p_slot_index);
void _dock_move_selected_to_bottom();
protected:
static void _bind_methods();
public:
static EditorDockManager *get_singleton() { return singleton; }
void add_vsplit(DockSplitContainer *p_split);
void add_hsplit(DockSplitContainer *p_split);
void register_dock_slot(DockSlot p_dock_slot, TabContainer *p_tab_container);
int get_vsplit_count() const;
void save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) const;
void load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section);
void update_dock_slots_visibility(bool p_keep_selected_tabs = false);
void bottom_dock_show_placement_popup(const Rect2i &p_position, Control *p_dock);
void close_all_floating_docks();
void set_docks_visible(bool p_show);
bool are_docks_visible() const;
void add_control_to_dock(DockSlot p_slot, Control *p_control, const String &p_name = "", const Ref<Shortcut> &p_shortcut = nullptr);
void remove_control_from_dock(Control *p_control);
EditorDockManager();
};
#endif // EDITOR_DOCK_MANAGER_H