editor_scene_tabs.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #ifndef EDITOR_SCENE_TABS_H
  31. #define EDITOR_SCENE_TABS_H
  32. #include "scene/gui/margin_container.h"
  33. class Button;
  34. class HBoxContainer;
  35. class Panel;
  36. class PanelContainer;
  37. class PopupMenu;
  38. class TabBar;
  39. class TextureRect;
  40. class EditorSceneTabs : public MarginContainer {
  41. GDCLASS(EditorSceneTabs, MarginContainer);
  42. inline static EditorSceneTabs *singleton = nullptr;
  43. public:
  44. enum {
  45. SCENE_SHOW_IN_FILESYSTEM = 3000, // Prevents conflicts with EditorNode options.
  46. SCENE_RUN,
  47. SCENE_CLOSE_OTHERS,
  48. SCENE_CLOSE_RIGHT,
  49. SCENE_CLOSE_ALL,
  50. };
  51. private:
  52. PanelContainer *tabbar_panel = nullptr;
  53. HBoxContainer *tabbar_container = nullptr;
  54. TabBar *scene_tabs = nullptr;
  55. PopupMenu *scene_tabs_context_menu = nullptr;
  56. Button *scene_tab_add = nullptr;
  57. Control *scene_tab_add_ph = nullptr;
  58. Panel *tab_preview_panel = nullptr;
  59. TextureRect *tab_preview = nullptr;
  60. int last_hovered_tab = -1;
  61. void _scene_tab_changed(int p_tab);
  62. void _scene_tab_script_edited(int p_tab);
  63. void _scene_tab_closed(int p_tab);
  64. void _scene_tab_hovered(int p_tab);
  65. void _scene_tab_exit();
  66. void _scene_tab_input(const Ref<InputEvent> &p_input);
  67. void _scene_tabs_resized();
  68. void _update_tab_titles();
  69. void _reposition_active_tab(int p_to_index);
  70. void _update_context_menu();
  71. void _custom_menu_option(int p_option);
  72. void _tab_preview_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
  73. void _global_menu_scene(const Variant &p_tag);
  74. void _global_menu_new_window(const Variant &p_tag);
  75. virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
  76. protected:
  77. void _notification(int p_what);
  78. virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override;
  79. static void _bind_methods();
  80. public:
  81. static EditorSceneTabs *get_singleton() { return singleton; }
  82. void add_extra_button(Button *p_button);
  83. void set_current_tab(int p_tab);
  84. int get_current_tab() const;
  85. void update_scene_tabs();
  86. EditorSceneTabs();
  87. };
  88. #endif // EDITOR_SCENE_TABS_H