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