editor_main_screen.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**************************************************************************/
  2. /* editor_main_screen.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. #pragma once
  31. #include "scene/gui/panel_container.h"
  32. class Button;
  33. class ConfigFile;
  34. class EditorPlugin;
  35. class HBoxContainer;
  36. class VBoxContainer;
  37. class EditorMainScreen : public PanelContainer {
  38. GDCLASS(EditorMainScreen, PanelContainer);
  39. public:
  40. enum EditorTable {
  41. EDITOR_2D = 0,
  42. EDITOR_3D,
  43. EDITOR_SCRIPT,
  44. EDITOR_GAME,
  45. EDITOR_ASSETLIB,
  46. };
  47. private:
  48. VBoxContainer *main_screen_vbox = nullptr;
  49. EditorPlugin *selected_plugin = nullptr;
  50. HBoxContainer *button_hb = nullptr;
  51. Vector<Button *> buttons;
  52. Vector<EditorPlugin *> editor_table;
  53. HashMap<String, EditorPlugin *> main_editor_plugins;
  54. int _get_current_main_editor() const;
  55. protected:
  56. void _notification(int p_what);
  57. public:
  58. void set_button_container(HBoxContainer *p_button_hb);
  59. void save_layout_to_config(Ref<ConfigFile> p_config_file, const String &p_section) const;
  60. void load_layout_from_config(Ref<ConfigFile> p_config_file, const String &p_section);
  61. void set_button_enabled(int p_index, bool p_enabled);
  62. bool is_button_enabled(int p_index) const;
  63. void select_next();
  64. void select_prev();
  65. void select_by_name(const String &p_name);
  66. void select(int p_index);
  67. int get_selected_index() const;
  68. int get_plugin_index(EditorPlugin *p_editor) const;
  69. EditorPlugin *get_selected_plugin() const;
  70. EditorPlugin *get_plugin_by_name(const String &p_plugin_name) const;
  71. bool can_auto_switch_screens() const;
  72. VBoxContainer *get_control() const;
  73. void add_main_plugin(EditorPlugin *p_editor);
  74. void remove_main_plugin(EditorPlugin *p_editor);
  75. EditorMainScreen();
  76. };