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