Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/docks/dock_tab_container.h
20934 views
1
/**************************************************************************/
2
/* dock_tab_container.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.h"
34
#include "scene/gui/tab_container.h"
35
36
class ConfigFile;
37
class DockContextPopup;
38
class DockTabContainer;
39
class EditorDockManager;
40
class StyleBoxFlat;
41
42
class EditorDockDragHint : public Control {
43
GDCLASS(EditorDockDragHint, Control);
44
45
DockTabContainer *dock_container = nullptr;
46
TabBar *drop_tabbar = nullptr;
47
48
Color valid_drop_color;
49
Ref<StyleBoxFlat> dock_drop_highlight;
50
bool can_drop_dock = false;
51
bool mouse_inside = false;
52
bool mouse_inside_tabbar = false;
53
54
void _drag_move_tab(int p_from_index, int p_to_index);
55
void _drag_move_tab_from(TabBar *p_from_tabbar, int p_from_index, int p_to_index);
56
57
protected:
58
virtual void gui_input(const Ref<InputEvent> &p_event) override;
59
60
void _notification(int p_what);
61
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
62
virtual void drop_data(const Point2 &p_point, const Variant &p_data) override;
63
64
public:
65
void set_slot(DockTabContainer *p_slot);
66
67
EditorDockDragHint();
68
};
69
70
class DockTabContainer : public TabContainer {
71
GDCLASS(DockTabContainer, TabContainer);
72
73
EditorDockDragHint *drag_hint = nullptr;
74
75
void _pre_popup();
76
void _tab_rmb_clicked(int p_tab_idx);
77
78
protected:
79
DockContextPopup *dock_context_popup = nullptr;
80
81
void _notification(int p_what);
82
83
public:
84
enum class TabStyle {
85
TEXT_ONLY,
86
ICON_ONLY,
87
TEXT_AND_ICON,
88
};
89
90
EditorDock::DockSlot dock_slot = EditorDock::DOCK_SLOT_NONE;
91
EditorDock::DockLayout layout = EditorDock::DOCK_LAYOUT_VERTICAL;
92
93
static String get_config_key(int p_idx) { return "dock_" + itos(p_idx + 1); }
94
95
virtual void dock_closed(EditorDock *p_dock) {}
96
virtual void dock_focused(EditorDock *p_dock, bool p_was_visible) {}
97
virtual void update_visibility();
98
virtual TabStyle get_tab_style() const;
99
virtual bool can_switch_dock() const;
100
101
// There is no equivalent load method, because loading needs to handle floating and closing.
102
void save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section);
103
virtual void load_selected_tab(int p_idx);
104
105
// This method should only be called by EditorDock.
106
void move_dock_index(EditorDock *p_dock, int p_to_index, bool p_set_current);
107
108
void set_dock_context_popup(DockContextPopup *p_popup);
109
EditorDock *get_dock(int p_idx) const;
110
void show_drag_hint();
111
112
DockTabContainer(EditorDock::DockSlot p_slot);
113
};
114
115
class SideDockTabContainer : public DockTabContainer {
116
GDCLASS(SideDockTabContainer, DockTabContainer);
117
118
public:
119
SideDockTabContainer(EditorDock::DockSlot p_slot);
120
};
121
122