Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/docks/editor_dock.h
11322 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 "editor/docks/editor_dock_manager.h"
34
#include "editor/plugins/editor_plugin.h"
35
#include "scene/gui/margin_container.h"
36
37
class ConfigFile;
38
class Shortcut;
39
class WindowWrapper;
40
41
class EditorDock : public MarginContainer {
42
GDCLASS(EditorDock, MarginContainer);
43
44
public:
45
enum DockLayout {
46
DOCK_LAYOUT_VERTICAL = 1,
47
DOCK_LAYOUT_HORIZONTAL = 2,
48
};
49
50
private:
51
friend class EditorDockManager;
52
friend class DockContextPopup;
53
54
String title;
55
String layout_key;
56
StringName icon_name;
57
Ref<Texture2D> dock_icon;
58
Ref<Shortcut> shortcut;
59
EditorDockManager::DockSlot default_slot = EditorDockManager::DOCK_SLOT_NONE;
60
61
BitField<DockLayout> available_layouts = DOCK_LAYOUT_VERTICAL;
62
63
bool open = false;
64
bool enabled = true;
65
bool at_bottom = false;
66
int previous_tab_index = -1;
67
bool previous_at_bottom = false;
68
WindowWrapper *dock_window = nullptr;
69
int dock_slot_index = EditorDockManager::DOCK_SLOT_NONE;
70
71
void _set_default_slot_bind(EditorPlugin::DockSlot p_slot);
72
EditorPlugin::DockSlot _get_default_slot_bind() const { return (EditorPlugin::DockSlot)default_slot; }
73
74
protected:
75
static void _bind_methods();
76
77
GDVIRTUAL1(_update_layout, int)
78
GDVIRTUAL2C(_save_layout_to_config, Ref<ConfigFile>, const String &)
79
GDVIRTUAL2(_load_layout_from_config, Ref<ConfigFile>, const String &)
80
81
public:
82
EditorDock();
83
84
void set_title(const String &p_title);
85
String get_title() const { return title; }
86
87
void set_layout_key(const String &p_key) { layout_key = p_key; }
88
String get_layout_key() const { return layout_key; }
89
90
void set_icon_name(const StringName &p_name);
91
StringName get_icon_name() const { return icon_name; }
92
93
void set_dock_icon(const Ref<Texture2D> &p_icon);
94
Ref<Texture2D> get_dock_icon() const { return dock_icon; }
95
96
void set_dock_shortcut(const Ref<Shortcut> &p_shortcut) { shortcut = p_shortcut; }
97
Ref<Shortcut> get_dock_shortcut() const { return shortcut; }
98
99
void set_default_slot(EditorDockManager::DockSlot p_slot);
100
EditorDockManager::DockSlot get_default_slot() const { return default_slot; }
101
102
void set_available_layouts(BitField<DockLayout> p_layouts) { available_layouts = p_layouts; }
103
BitField<DockLayout> get_available_layouts() const { return available_layouts; }
104
105
String get_display_title() const;
106
String get_effective_layout_key() const;
107
108
virtual void update_layout(DockLayout p_layout) { GDVIRTUAL_CALL(_update_layout, p_layout); }
109
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); }
110
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); }
111
};
112
113
VARIANT_BITFIELD_CAST(EditorDock::DockLayout);
114
115