0.2.0-dev Download ZIP
117 lines ·4.4 KB Raw
| 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_SAVE_SCENE = 1000, // Prevents conflicts with EditorNode options. |
| 52 | SCENE_SAVE_AS_SCENE, |
| 53 | SCENE_SHOW_IN_FILESYSTEM, |
| 54 | SCENE_RUN, |
| 55 | SCENE_SET_AS_MAIN_SCENE, |
| 56 | SCENE_CLOSE, |
| 57 | SCENE_CLOSE_OTHERS, |
| 58 | SCENE_CLOSE_RIGHT, |
| 59 | }; |
| 60 | |
| 61 | private: |
| 62 | PanelContainer *tabbar_panel = nullptr; |
| 63 | HBoxContainer *tabbar_container = nullptr; |
| 64 | |
| 65 | TabBar *scene_tabs = nullptr; |
| 66 | PopupMenu *scene_tabs_context_menu = nullptr; |
| 67 | MenuButton *scene_list = nullptr; |
| 68 | Button *scene_tab_add = nullptr; |
| 69 | Control *scene_tab_add_ph = nullptr; |
| 70 | |
| 71 | Panel *tab_preview_panel = nullptr; |
| 72 | TextureRect *tab_preview = nullptr; |
| 73 | |
| 74 | int last_hovered_tab = -1; |
| 75 | |
| 76 | void _scene_tab_changed(int p_tab); |
| 77 | void _scene_tab_script_edited(int p_tab); |
| 78 | void _scene_tab_closed(int p_tab); |
| 79 | void _scene_tab_hovered(int p_tab); |
| 80 | void _scene_tab_exit(); |
| 81 | void _scene_tab_input(const Ref<InputEvent> &p_input); |
| 82 | void _scene_tabs_resized(); |
| 83 | |
| 84 | void _update_tab_titles(); |
| 85 | void _reposition_active_tab(int p_to_index); |
| 86 | void _update_context_menu(int p_index); |
| 87 | void _custom_menu_option(int p_option); |
| 88 | void _update_scene_list(); |
| 89 | |
| 90 | void _tab_preview_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, int p_tab); |
| 91 | static Dictionary _get_context_data(int p_current_tab); |
| 92 | |
| 93 | void _global_menu_scene(const Variant &p_tag); |
| 94 | void _global_menu_new_window(const Variant &p_tag); |
| 95 | |
| 96 | void _project_settings_changed(); |
| 97 | |
| 98 | virtual void shortcut_input(const Ref<InputEvent> &p_event) override; |
| 99 | |
| 100 | protected: |
| 101 | void _notification(int p_what); |
| 102 | virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override; |
| 103 | static void _bind_methods(); |
| 104 | |
| 105 | public: |
| 106 | static EditorSceneTabs *get_singleton() { return singleton; } |
| 107 | |
| 108 | void add_extra_button(Button *p_button); |
| 109 | |
| 110 | void set_current_tab(int p_tab); |
| 111 | int get_current_tab() const; |
| 112 | int get_option_tab() const; |
| 113 | |
| 114 | void update_scene_tabs(); |
| 115 | |
| 116 | EditorSceneTabs(); |
| 117 | }; |