theme_editor_plugin.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*************************************************************************/
  2. /* theme_editor_plugin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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 THEME_EDITOR_PLUGIN_H
  31. #define THEME_EDITOR_PLUGIN_H
  32. #include "scene/gui/check_box.h"
  33. #include "scene/gui/file_dialog.h"
  34. #include "scene/gui/margin_container.h"
  35. #include "scene/gui/option_button.h"
  36. #include "scene/gui/scroll_container.h"
  37. #include "scene/gui/texture_rect.h"
  38. #include "scene/resources/theme.h"
  39. #include "editor/editor_node.h"
  40. class ThemeEditor : public VBoxContainer {
  41. GDCLASS(ThemeEditor, VBoxContainer);
  42. Panel *main_panel;
  43. MarginContainer *main_container;
  44. Ref<Theme> theme;
  45. EditorFileDialog *file_dialog;
  46. double time_left;
  47. MenuButton *theme_menu;
  48. ConfirmationDialog *add_del_dialog;
  49. HBoxContainer *type_hbc;
  50. MenuButton *type_menu;
  51. LineEdit *type_edit;
  52. HBoxContainer *name_hbc;
  53. MenuButton *name_menu;
  54. LineEdit *name_edit;
  55. OptionButton *type_select;
  56. Label *type_select_label;
  57. Label *name_select_label;
  58. enum PopupMode {
  59. POPUP_ADD,
  60. POPUP_CLASS_ADD,
  61. POPUP_REMOVE,
  62. POPUP_CLASS_REMOVE,
  63. POPUP_CREATE_EMPTY,
  64. POPUP_CREATE_EDITOR_EMPTY,
  65. POPUP_IMPORT_EDITOR_THEME
  66. };
  67. int popup_mode;
  68. Tree *test_tree;
  69. void _save_template_cbk(String fname);
  70. void _dialog_cbk();
  71. void _type_menu_cbk(int p_option);
  72. void _name_menu_about_to_show();
  73. void _name_menu_cbk(int p_option);
  74. void _theme_menu_cbk(int p_option);
  75. void _propagate_redraw(Control *p_at);
  76. void _refresh_interval();
  77. protected:
  78. void _notification(int p_what);
  79. static void _bind_methods();
  80. public:
  81. void edit(const Ref<Theme> &p_theme);
  82. ThemeEditor();
  83. };
  84. class ThemeEditorPlugin : public EditorPlugin {
  85. GDCLASS(ThemeEditorPlugin, EditorPlugin);
  86. ThemeEditor *theme_editor;
  87. EditorNode *editor;
  88. Button *button;
  89. public:
  90. virtual String get_name() const { return "Theme"; }
  91. bool has_main_screen() const { return false; }
  92. virtual void edit(Object *p_node);
  93. virtual bool handles(Object *p_node) const;
  94. virtual void make_visible(bool p_visible);
  95. ThemeEditorPlugin(EditorNode *p_node);
  96. };
  97. #endif // THEME_EDITOR_PLUGIN_H