Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/scene/editor_scene_tabs.h
9896 views
1
/**************************************************************************/
2
/* editor_scene_tabs.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 "scene/gui/margin_container.h"
34
35
class Button;
36
class HBoxContainer;
37
class Panel;
38
class PanelContainer;
39
class PopupMenu;
40
class TabBar;
41
class TextureRect;
42
43
class EditorSceneTabs : public MarginContainer {
44
GDCLASS(EditorSceneTabs, MarginContainer);
45
46
inline static EditorSceneTabs *singleton = nullptr;
47
48
public:
49
enum {
50
SCENE_SHOW_IN_FILESYSTEM = 1000, // Prevents conflicts with EditorNode options.
51
SCENE_RUN,
52
SCENE_CLOSE_OTHERS,
53
SCENE_CLOSE_RIGHT,
54
SCENE_CLOSE_ALL,
55
};
56
57
private:
58
PanelContainer *tabbar_panel = nullptr;
59
HBoxContainer *tabbar_container = nullptr;
60
61
TabBar *scene_tabs = nullptr;
62
PopupMenu *scene_tabs_context_menu = nullptr;
63
Button *scene_tab_add = nullptr;
64
Control *scene_tab_add_ph = nullptr;
65
66
Panel *tab_preview_panel = nullptr;
67
TextureRect *tab_preview = nullptr;
68
69
int last_hovered_tab = -1;
70
71
void _scene_tab_changed(int p_tab);
72
void _scene_tab_script_edited(int p_tab);
73
void _scene_tab_closed(int p_tab);
74
void _scene_tab_hovered(int p_tab);
75
void _scene_tab_exit();
76
void _scene_tab_input(const Ref<InputEvent> &p_input);
77
void _scene_tabs_resized();
78
79
void _update_tab_titles();
80
void _reposition_active_tab(int p_to_index);
81
void _update_context_menu();
82
void _custom_menu_option(int p_option);
83
84
void _tab_preview_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
85
86
void _global_menu_scene(const Variant &p_tag);
87
void _global_menu_new_window(const Variant &p_tag);
88
89
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
90
91
protected:
92
void _notification(int p_what);
93
virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override;
94
static void _bind_methods();
95
96
public:
97
static EditorSceneTabs *get_singleton() { return singleton; }
98
99
void add_extra_button(Button *p_button);
100
101
void set_current_tab(int p_tab);
102
int get_current_tab() const;
103
104
void update_scene_tabs();
105
106
EditorSceneTabs();
107
};
108
109