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