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