| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  theme_editor_plugin.cpp                                              */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							| 
									
										
										
										
											2017-08-27 14:16:55 +02:00
										 |  |  | /*                      https://godotengine.org                          */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2019-01-01 12:53:14 +01:00
										 |  |  | /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md)    */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the       */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including   */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,   */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to    */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to */ | 
					
						
							|  |  |  | /* the following conditions:                                             */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be        */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.       */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #include "theme_editor_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 18:13:45 +02:00
										 |  |  | #include "core/os/file_access.h"
 | 
					
						
							|  |  |  | #include "core/version.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ThemeEditor::edit(const Ref<Theme> &p_theme) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	theme = p_theme; | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	main_panel->set_theme(p_theme); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	main_container->set_theme(p_theme); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | void ThemeEditor::_propagate_redraw(Control *p_at) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	p_at->notification(NOTIFICATION_THEME_CHANGED); | 
					
						
							|  |  |  | 	p_at->minimum_size_changed(); | 
					
						
							|  |  |  | 	p_at->update(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (int i = 0; i < p_at->get_child_count(); i++) { | 
					
						
							| 
									
										
										
										
											2017-08-24 22:58:51 +02:00
										 |  |  | 		Control *a = Object::cast_to<Control>(p_at->get_child(i)); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 		if (a) | 
					
						
							|  |  |  | 			_propagate_redraw(a); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditor::_refresh_interval() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	_propagate_redraw(main_panel); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	_propagate_redraw(main_container); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditor::_type_menu_cbk(int p_option) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	type_edit->set_text(type_menu->get_popup()->get_item_text(p_option)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditor::_name_menu_about_to_show() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	String fromtype = type_edit->get_text(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	List<StringName> names; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	if (popup_mode == POPUP_ADD) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		switch (type_select->get_selected()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			case 0: Theme::get_default()->get_icon_list(fromtype, &names); break; | 
					
						
							|  |  |  | 			case 1: Theme::get_default()->get_stylebox_list(fromtype, &names); break; | 
					
						
							|  |  |  | 			case 2: Theme::get_default()->get_font_list(fromtype, &names); break; | 
					
						
							|  |  |  | 			case 3: Theme::get_default()->get_color_list(fromtype, &names); break; | 
					
						
							|  |  |  | 			case 4: Theme::get_default()->get_constant_list(fromtype, &names); break; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (popup_mode == POPUP_REMOVE) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		theme->get_icon_list(fromtype, &names); | 
					
						
							|  |  |  | 		theme->get_stylebox_list(fromtype, &names); | 
					
						
							|  |  |  | 		theme->get_font_list(fromtype, &names); | 
					
						
							|  |  |  | 		theme->get_color_list(fromtype, &names); | 
					
						
							|  |  |  | 		theme->get_constant_list(fromtype, &names); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	name_menu->get_popup()->clear(); | 
					
						
							| 
									
										
										
										
											2019-04-23 20:21:31 -03:00
										 |  |  | 	name_menu->get_popup()->set_size(Size2()); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		name_menu->get_popup()->add_item(E->get()); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditor::_name_menu_cbk(int p_option) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	name_edit->set_text(name_menu->get_popup()->get_item_text(p_option)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct _TECategory { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct RefItem { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Ref<T> item; | 
					
						
							|  |  |  | 		StringName name; | 
					
						
							| 
									
										
										
										
											2017-08-07 17:17:31 +07:00
										 |  |  | 		bool operator<(const RefItem<T> &p) const { return item->get_instance_id() < p.item->get_instance_id(); } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	template <class T> | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct Item { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		T item; | 
					
						
							|  |  |  | 		String name; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		bool operator<(const Item<T> &p) const { return name < p.name; } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Set<RefItem<StyleBox> > stylebox_items; | 
					
						
							|  |  |  | 	Set<RefItem<Font> > font_items; | 
					
						
							|  |  |  | 	Set<RefItem<Texture> > icon_items; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Set<Item<Color> > color_items; | 
					
						
							|  |  |  | 	Set<Item<int> > constant_items; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditor::_save_template_cbk(String fname) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	String filename = file_dialog->get_current_path(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	Map<String, _TECategory> categories; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	// Fill types.
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	List<StringName> type_list; | 
					
						
							|  |  |  | 	Theme::get_default()->get_type_list(&type_list); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (List<StringName>::Element *E = type_list.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 		categories.insert(E->get(), _TECategory()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	// Fill default theme.
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		_TECategory &tc = E->get(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		List<StringName> stylebox_list; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Theme::get_default()->get_stylebox_list(E->key(), &stylebox_list); | 
					
						
							|  |  |  | 		for (List<StringName>::Element *F = stylebox_list.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			_TECategory::RefItem<StyleBox> it; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			it.name = F->get(); | 
					
						
							|  |  |  | 			it.item = Theme::get_default()->get_stylebox(F->get(), E->key()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			tc.stylebox_items.insert(it); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		List<StringName> font_list; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Theme::get_default()->get_font_list(E->key(), &font_list); | 
					
						
							|  |  |  | 		for (List<StringName>::Element *F = font_list.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			_TECategory::RefItem<Font> it; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			it.name = F->get(); | 
					
						
							|  |  |  | 			it.item = Theme::get_default()->get_font(F->get(), E->key()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			tc.font_items.insert(it); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		List<StringName> icon_list; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Theme::get_default()->get_icon_list(E->key(), &icon_list); | 
					
						
							|  |  |  | 		for (List<StringName>::Element *F = icon_list.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			_TECategory::RefItem<Texture> it; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			it.name = F->get(); | 
					
						
							|  |  |  | 			it.item = Theme::get_default()->get_icon(F->get(), E->key()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			tc.icon_items.insert(it); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		List<StringName> color_list; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Theme::get_default()->get_color_list(E->key(), &color_list); | 
					
						
							|  |  |  | 		for (List<StringName>::Element *F = color_list.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			_TECategory::Item<Color> it; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			it.name = F->get(); | 
					
						
							|  |  |  | 			it.item = Theme::get_default()->get_color(F->get(), E->key()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			tc.color_items.insert(it); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		List<StringName> constant_list; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Theme::get_default()->get_constant_list(E->key(), &constant_list); | 
					
						
							|  |  |  | 		for (List<StringName>::Element *F = constant_list.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			_TECategory::Item<int> it; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			it.name = F->get(); | 
					
						
							|  |  |  | 			it.item = Theme::get_default()->get_constant(F->get(), E->key()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			tc.constant_items.insert(it); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	FileAccess *file = FileAccess::open(filename, FileAccess::WRITE); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	if (!file) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		ERR_EXPLAIN(TTR("Can't save theme to file:") + " " + filename); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	file->store_line("; ******************* "); | 
					
						
							|  |  |  | 	file->store_line("; Template Theme File "); | 
					
						
							|  |  |  | 	file->store_line("; ******************* "); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Theme Syntax: "); | 
					
						
							|  |  |  | 	file->store_line("; ------------- "); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Must be placed in section [theme]"); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = [value] "); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; [value] examples:"); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = 6 ; numeric constant. "); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = #FF00FF ; HTML color "); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = #55FF00FF ; HTML color with alpha 55."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = icon(image.png) ; icon in a png file (relative to theme file)."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = font(font.xres) ; font in a resource (relative to theme file)."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = sbox(stylebox.xres) ; stylebox in a resource (relative to theme file)."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = sboxf(2,#FF00FF) ; flat stylebox with margin 2."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = sboxf(2,#FF00FF,#FFFFFF) ; flat stylebox with margin 2 and border."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = sboxf(2,#FF00FF,#FFFFFF,#000000) ; flat stylebox with margin 2, light & dark borders."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = sboxt(base.png,2,2,2,2) ; textured stylebox with 3x3 stretch and stretch margins."); | 
					
						
							|  |  |  | 	file->store_line(";   -Additionally, 4 extra integers can be added to sboxf and sboxt to specify custom padding of contents:"); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = sboxt(base.png,2,2,2,2,5,4,2,4) ;"); | 
					
						
							|  |  |  | 	file->store_line(";   -Order for all is always left, top, right, bottom."); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Special values:"); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = default ; use the value in the default theme (must exist there)."); | 
					
						
							|  |  |  | 	file->store_line("; Type.item = @somebutton_color ; reference to a library value previously defined."); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Library Syntax: "); | 
					
						
							|  |  |  | 	file->store_line("; --------------- "); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Must be placed in section [library], but usage is optional."); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; item = [value] ; same as Theme, but assign to library."); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; examples:"); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; [library]"); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; default_button_color = #FF00FF"); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; [theme]"); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; Button.color = @default_button_color ; used reference."); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line("; ******************* "); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							| 
									
										
											  
											
												Refactor version macros and fix related bugs
The previous logic with VERSION_MKSTRING was a bit unwieldy, so there were
several places hardcoding their own variant of the version string, potentially
with bugs (e.g. forgetting the patch number when defined).
The new logic defines:
- VERSION_BRANCH, the main 'major.minor' version (e.g. 3.1)
- VERSION_NUMBER, which can be 'major.minor' or 'major.minor.patch',
  depending on whether the latter is defined (e.g. 3.1.4)
- VERSION_FULL_CONFIG, which contains the version status (e.g. stable)
  and the module-specific suffix (e.g. mono)
- VERSION_FULL_BUILD, same as above but with build/reference name
  (e.g. official, custom_build, mageia, etc.)
  Note: Slight change here, as the previous format had the build name
  *before* the module-specific suffix; now it's after
- VERSION_FULL_NAME, same as before, so VERSION_FULL_BUILD prefixed
  with "Godot v" for readability
Bugs fixed thanks to that:
- Export templates version matching now properly takes VERSION_PATCH
  into account by relying on VERSION_FULL_CONFIG.
- ClassDB hash no longer takes the build name into account, but limits
  itself to VERSION_FULL_CONFIG (build name is cosmetic, not relevant
  for the API hash).
- Docs XML no longer hardcode the VERSION_STATUS, this was annoying.
- Small cleanup in Windows .rc file thanks to new macros.
											
										 
											2018-02-23 19:48:49 +01:00
										 |  |  | 	file->store_line("; Template Generated Using: " + String(VERSION_FULL_BUILD)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	file->store_line(";    "); | 
					
						
							|  |  |  | 	file->store_line("; "); | 
					
						
							|  |  |  | 	file->store_line(""); | 
					
						
							|  |  |  | 	file->store_line("[library]"); | 
					
						
							|  |  |  | 	file->store_line(""); | 
					
						
							|  |  |  | 	file->store_line("; place library stuff here"); | 
					
						
							|  |  |  | 	file->store_line(""); | 
					
						
							|  |  |  | 	file->store_line("[theme]"); | 
					
						
							|  |  |  | 	file->store_line(""); | 
					
						
							|  |  |  | 	file->store_line(""); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	// Write default theme.
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		_TECategory &tc = E->get(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		String underline = "; "; | 
					
						
							|  |  |  | 		for (int i = 0; i < E->key().length(); i++) | 
					
						
							|  |  |  | 			underline += "*"; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		file->store_line(""); | 
					
						
							|  |  |  | 		file->store_line(underline); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		file->store_line("; " + E->key()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		file->store_line(underline); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (tc.stylebox_items.size()) | 
					
						
							|  |  |  | 			file->store_line("\n; StyleBox Items:\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (Set<_TECategory::RefItem<StyleBox> >::Element *F = tc.stylebox_items.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			file->store_line(E->key() + "." + F->get().name + " = default"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (tc.font_items.size()) | 
					
						
							|  |  |  | 			file->store_line("\n; Font Items:\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (Set<_TECategory::RefItem<Font> >::Element *F = tc.font_items.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			file->store_line(E->key() + "." + F->get().name + " = default"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (tc.icon_items.size()) | 
					
						
							|  |  |  | 			file->store_line("\n; Icon Items:\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (Set<_TECategory::RefItem<Texture> >::Element *F = tc.icon_items.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			file->store_line(E->key() + "." + F->get().name + " = default"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (tc.color_items.size()) | 
					
						
							|  |  |  | 			file->store_line("\n; Color Items:\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (Set<_TECategory::Item<Color> >::Element *F = tc.color_items.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			file->store_line(E->key() + "." + F->get().name + " = default"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (tc.constant_items.size()) | 
					
						
							|  |  |  | 			file->store_line("\n; Constant Items:\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (Set<_TECategory::Item<int> >::Element *F = tc.constant_items.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			file->store_line(E->key() + "." + F->get().name + " = default"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	file->close(); | 
					
						
							|  |  |  | 	memdelete(file); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditor::_dialog_cbk() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	switch (popup_mode) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		case POPUP_ADD: { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			switch (type_select->get_selected()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture>()); break; | 
					
						
							|  |  |  | 				case 1: theme->set_stylebox(name_edit->get_text(), type_edit->get_text(), Ref<StyleBox>()); break; | 
					
						
							|  |  |  | 				case 2: theme->set_font(name_edit->get_text(), type_edit->get_text(), Ref<Font>()); break; | 
					
						
							|  |  |  | 				case 3: theme->set_color(name_edit->get_text(), type_edit->get_text(), Color()); break; | 
					
						
							|  |  |  | 				case 4: theme->set_constant(name_edit->get_text(), type_edit->get_text(), 0); break; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} break; | 
					
						
							|  |  |  | 		case POPUP_CLASS_ADD: { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			StringName fromtype = type_edit->get_text(); | 
					
						
							|  |  |  | 			List<StringName> names; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_icon_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->set_icon(E->get(), fromtype, Ref<Texture>()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_stylebox_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->set_stylebox(E->get(), fromtype, Ref<StyleBox>()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_font_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->set_font(E->get(), fromtype, Ref<Font>()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_color_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->set_color(E->get(), fromtype, Theme::get_default()->get_color(E->get(), fromtype)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_constant_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->set_constant(E->get(), fromtype, Theme::get_default()->get_constant(E->get(), fromtype)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} break; | 
					
						
							|  |  |  | 		case POPUP_REMOVE: { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			switch (type_select->get_selected()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				case 0: theme->clear_icon(name_edit->get_text(), type_edit->get_text()); break; | 
					
						
							|  |  |  | 				case 1: theme->clear_stylebox(name_edit->get_text(), type_edit->get_text()); break; | 
					
						
							|  |  |  | 				case 2: theme->clear_font(name_edit->get_text(), type_edit->get_text()); break; | 
					
						
							|  |  |  | 				case 3: theme->clear_color(name_edit->get_text(), type_edit->get_text()); break; | 
					
						
							|  |  |  | 				case 4: theme->clear_constant(name_edit->get_text(), type_edit->get_text()); break; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-21 15:29:25 +02:00
										 |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 		case POPUP_CLASS_REMOVE: { | 
					
						
							|  |  |  | 			StringName fromtype = type_edit->get_text(); | 
					
						
							|  |  |  | 			List<StringName> names; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_icon_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->clear_icon(E->get(), fromtype); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_stylebox_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->clear_stylebox(E->get(), fromtype); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_font_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->clear_font(E->get(), fromtype); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_color_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->clear_color(E->get(), fromtype); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				names.clear(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				Theme::get_default()->get_constant_list(fromtype, &names); | 
					
						
							|  |  |  | 				for (List<StringName>::Element *E = names.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->clear_constant(E->get(), fromtype); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditor::_theme_menu_cbk(int p_option) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-07 11:51:08 +08:00
										 |  |  | 	if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		bool import = (p_option == POPUP_IMPORT_EDITOR_THEME); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Ref<Theme> base_theme; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		if (p_option == POPUP_CREATE_EMPTY) { | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 			base_theme = Theme::get_default(); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			base_theme = EditorNode::get_singleton()->get_theme_base()->get_theme(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			List<StringName> types; | 
					
						
							|  |  |  | 			base_theme->get_type_list(&types); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			for (List<StringName>::Element *T = types.front(); T; T = T->next()) { | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 				StringName type = T->get(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				List<StringName> icons; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				base_theme->get_icon_list(type, &icons); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				for (List<StringName>::Element *E = icons.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2017-11-07 11:51:08 +08:00
										 |  |  | 					theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture>()); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				List<StringName> shaders; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				base_theme->get_shader_list(type, &shaders); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				for (List<StringName>::Element *E = shaders.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2017-11-07 11:51:08 +08:00
										 |  |  | 					theme->set_shader(E->get(), type, import ? base_theme->get_shader(E->get(), type) : Ref<Shader>()); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				List<StringName> styleboxs; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				base_theme->get_stylebox_list(type, &styleboxs); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				for (List<StringName>::Element *E = styleboxs.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2017-11-07 11:51:08 +08:00
										 |  |  | 					theme->set_stylebox(E->get(), type, import ? base_theme->get_stylebox(E->get(), type) : Ref<StyleBox>()); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				List<StringName> fonts; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				base_theme->get_font_list(type, &fonts); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				for (List<StringName>::Element *E = fonts.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 					theme->set_font(E->get(), type, Ref<Font>()); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				List<StringName> colors; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				base_theme->get_color_list(type, &colors); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				for (List<StringName>::Element *E = colors.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2017-11-07 11:51:08 +08:00
										 |  |  | 					theme->set_color(E->get(), type, import ? base_theme->get_color(E->get(), type) : Color()); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				List<StringName> constants; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				base_theme->get_constant_list(type, &constants); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2017-11-07 11:51:08 +08:00
										 |  |  | 					theme->set_constant(E->get(), type, base_theme->get_constant(E->get(), type)); | 
					
						
							| 
									
										
										
										
											2016-06-17 01:13:23 -03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<Theme> base_theme; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	name_select_label->show(); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	name_hbc->show(); | 
					
						
							|  |  |  | 	type_select_label->show(); | 
					
						
							|  |  |  | 	type_select->show(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	if (p_option == POPUP_ADD) { // Add.
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 		add_del_dialog->set_title(TTR("Add Item")); | 
					
						
							|  |  |  | 		add_del_dialog->get_ok()->set_text(TTR("Add")); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		base_theme = Theme::get_default(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	} else if (p_option == POPUP_CLASS_ADD) { // Add.
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 		add_del_dialog->set_title(TTR("Add All Items")); | 
					
						
							|  |  |  | 		add_del_dialog->get_ok()->set_text(TTR("Add All")); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		base_theme = Theme::get_default(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		name_select_label->hide(); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 		name_hbc->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		type_select_label->hide(); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 		type_select->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_option == POPUP_REMOVE) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 		add_del_dialog->set_title(TTR("Remove Item")); | 
					
						
							|  |  |  | 		add_del_dialog->get_ok()->set_text(TTR("Remove")); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		base_theme = theme; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_option == POPUP_CLASS_REMOVE) { | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 22:25:14 +02:00
										 |  |  | 		add_del_dialog->set_title(TTR("Remove All Items")); | 
					
						
							|  |  |  | 		add_del_dialog->get_ok()->set_text(TTR("Remove All")); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		base_theme = Theme::get_default(); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		name_select_label->hide(); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 		name_hbc->hide(); | 
					
						
							| 
									
										
										
										
											2016-04-21 11:58:53 +10:00
										 |  |  | 		type_select_label->hide(); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 		type_select->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	popup_mode = p_option; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ERR_FAIL_COND(theme.is_null()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	List<StringName> types; | 
					
						
							|  |  |  | 	base_theme->get_type_list(&types); | 
					
						
							| 
									
										
										
										
											2016-06-20 11:33:51 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-14 18:03:38 +01:00
										 |  |  | 	type_menu->get_popup()->clear(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	if (p_option == 0 || p_option == 1) { // Add.
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		List<StringName> new_types; | 
					
						
							|  |  |  | 		theme->get_type_list(&new_types); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		for (List<StringName>::Element *F = new_types.front(); F; F = F->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			bool found = false; | 
					
						
							|  |  |  | 			for (List<StringName>::Element *E = types.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 				if (E->get() == F->get()) { | 
					
						
							|  |  |  | 					found = true; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (!found) | 
					
						
							|  |  |  | 				types.push_back(F->get()); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-20 11:33:51 -03:00
										 |  |  | 	types.sort_custom<StringName::AlphCompare>(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (List<StringName>::Element *E = types.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		type_menu->get_popup()->add_item(E->get()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | void ThemeEditor::_notification(int p_what) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	switch (p_what) { | 
					
						
							|  |  |  | 		case NOTIFICATION_PROCESS: { | 
					
						
							|  |  |  | 			time_left -= get_process_delta_time(); | 
					
						
							|  |  |  | 			if (time_left < 0) { | 
					
						
							|  |  |  | 				time_left = 1.5; | 
					
						
							|  |  |  | 				_refresh_interval(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} break; | 
					
						
							|  |  |  | 		case NOTIFICATION_THEME_CHANGED: { | 
					
						
							|  |  |  | 			theme_menu->set_icon(get_icon("Theme", "EditorIcons")); | 
					
						
							|  |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | void ThemeEditor::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ClassDB::bind_method("_type_menu_cbk", &ThemeEditor::_type_menu_cbk); | 
					
						
							|  |  |  | 	ClassDB::bind_method("_name_menu_about_to_show", &ThemeEditor::_name_menu_about_to_show); | 
					
						
							|  |  |  | 	ClassDB::bind_method("_name_menu_cbk", &ThemeEditor::_name_menu_cbk); | 
					
						
							|  |  |  | 	ClassDB::bind_method("_theme_menu_cbk", &ThemeEditor::_theme_menu_cbk); | 
					
						
							|  |  |  | 	ClassDB::bind_method("_dialog_cbk", &ThemeEditor::_dialog_cbk); | 
					
						
							|  |  |  | 	ClassDB::bind_method("_save_template_cbk", &ThemeEditor::_save_template_cbk); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ThemeEditor::ThemeEditor() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	time_left = 0; | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	HBoxContainer *top_menu = memnew(HBoxContainer); | 
					
						
							|  |  |  | 	add_child(top_menu); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	top_menu->add_child(memnew(Label(TTR("Preview:")))); | 
					
						
							|  |  |  | 	top_menu->add_spacer(false); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	theme_menu = memnew(MenuButton); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	theme_menu->set_text(TTR("Edit Theme")); | 
					
						
							| 
									
										
										
										
											2017-10-22 00:05:01 +02:00
										 |  |  | 	theme_menu->set_tooltip(TTR("Theme editing menu.")); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	theme_menu->get_popup()->add_item(TTR("Add Item"), POPUP_ADD); | 
					
						
							|  |  |  | 	theme_menu->get_popup()->add_item(TTR("Add Class Items"), POPUP_CLASS_ADD); | 
					
						
							|  |  |  | 	theme_menu->get_popup()->add_item(TTR("Remove Item"), POPUP_REMOVE); | 
					
						
							|  |  |  | 	theme_menu->get_popup()->add_item(TTR("Remove Class Items"), POPUP_CLASS_REMOVE); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	theme_menu->get_popup()->add_separator(); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	theme_menu->get_popup()->add_item(TTR("Create Empty Template"), POPUP_CREATE_EMPTY); | 
					
						
							|  |  |  | 	theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY); | 
					
						
							| 
									
										
										
										
											2017-11-07 11:51:08 +08:00
										 |  |  | 	theme_menu->get_popup()->add_item(TTR("Create From Current Editor Theme"), POPUP_IMPORT_EDITOR_THEME); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	top_menu->add_child(theme_menu); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	theme_menu->get_popup()->connect("id_pressed", this, "_theme_menu_cbk"); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	ScrollContainer *scroll = memnew(ScrollContainer); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	add_child(scroll); | 
					
						
							|  |  |  | 	scroll->set_enable_v_scroll(true); | 
					
						
							|  |  |  | 	scroll->set_enable_h_scroll(false); | 
					
						
							|  |  |  | 	scroll->set_v_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	MarginContainer *root_container = memnew(MarginContainer); | 
					
						
							|  |  |  | 	scroll->add_child(root_container); | 
					
						
							|  |  |  | 	root_container->set_theme(Theme::get_default()); | 
					
						
							|  |  |  | 	root_container->set_clip_contents(true); | 
					
						
							|  |  |  | 	root_container->set_custom_minimum_size(Size2(700, 0) * EDSCALE); | 
					
						
							|  |  |  | 	root_container->set_v_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	root_container->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	//// Preview Controls ////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	main_panel = memnew(Panel); | 
					
						
							|  |  |  | 	root_container->add_child(main_panel); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	main_container = memnew(MarginContainer); | 
					
						
							|  |  |  | 	root_container->add_child(main_container); | 
					
						
							|  |  |  | 	main_container->add_constant_override("margin_right", 4 * EDSCALE); | 
					
						
							|  |  |  | 	main_container->add_constant_override("margin_top", 4 * EDSCALE); | 
					
						
							|  |  |  | 	main_container->add_constant_override("margin_left", 4 * EDSCALE); | 
					
						
							|  |  |  | 	main_container->add_constant_override("margin_bottom", 4 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	HBoxContainer *main_hb = memnew(HBoxContainer); | 
					
						
							| 
									
										
										
										
											2019-08-13 15:09:25 -03:00
										 |  |  | 	main_container->add_child(main_hb); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	VBoxContainer *first_vb = memnew(VBoxContainer); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	main_hb->add_child(first_vb); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	first_vb->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	first_vb->add_constant_override("separation", 10 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	first_vb->add_child(memnew(Label("Label"))); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	first_vb->add_child(memnew(Button("Button"))); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	Button *bt = memnew(Button); | 
					
						
							|  |  |  | 	bt->set_text(TTR("Toggle Button")); | 
					
						
							|  |  |  | 	bt->set_toggle_mode(true); | 
					
						
							|  |  |  | 	bt->set_pressed(true); | 
					
						
							|  |  |  | 	first_vb->add_child(bt); | 
					
						
							|  |  |  | 	bt = memnew(Button); | 
					
						
							|  |  |  | 	bt->set_text(TTR("Disabled Button")); | 
					
						
							|  |  |  | 	bt->set_disabled(true); | 
					
						
							|  |  |  | 	first_vb->add_child(bt); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ToolButton *tb = memnew(ToolButton); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	tb->set_text("ToolButton"); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	first_vb->add_child(tb); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	CheckButton *cb = memnew(CheckButton); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	cb->set_text("CheckButton"); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	first_vb->add_child(cb); | 
					
						
							|  |  |  | 	CheckBox *cbx = memnew(CheckBox); | 
					
						
							| 
									
										
										
										
											2015-10-19 17:46:13 -03:00
										 |  |  | 	cbx->set_text("CheckBox"); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	first_vb->add_child(cbx); | 
					
						
							| 
									
										
										
										
											2015-10-19 17:46:13 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	MenuButton *test_menu_button = memnew(MenuButton); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	test_menu_button->set_text("MenuButton"); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	test_menu_button->get_popup()->add_item(TTR("Item")); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	test_menu_button->get_popup()->add_item(TTR("Disabled Item")); | 
					
						
							|  |  |  | 	test_menu_button->get_popup()->set_item_disabled(1, true); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	test_menu_button->get_popup()->add_separator(); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	test_menu_button->get_popup()->add_check_item(TTR("Check Item")); | 
					
						
							|  |  |  | 	test_menu_button->get_popup()->add_check_item(TTR("Checked Item")); | 
					
						
							| 
									
										
										
										
											2019-08-09 16:26:43 -03:00
										 |  |  | 	test_menu_button->get_popup()->set_item_checked(4, true); | 
					
						
							| 
									
										
										
										
											2018-03-23 21:55:40 +01:00
										 |  |  | 	test_menu_button->get_popup()->add_separator(); | 
					
						
							| 
									
										
										
										
											2018-04-25 20:12:46 +02:00
										 |  |  | 	test_menu_button->get_popup()->add_radio_check_item(TTR("Radio Item")); | 
					
						
							| 
									
										
										
										
											2018-03-23 21:55:40 +01:00
										 |  |  | 	test_menu_button->get_popup()->add_radio_check_item(TTR("Checked Radio Item")); | 
					
						
							| 
									
										
										
										
											2019-08-09 16:26:43 -03:00
										 |  |  | 	test_menu_button->get_popup()->set_item_checked(7, true); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	test_menu_button->get_popup()->add_separator(TTR("Named Sep.")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	PopupMenu *test_submenu = memnew(PopupMenu); | 
					
						
							|  |  |  | 	test_menu_button->get_popup()->add_child(test_submenu); | 
					
						
							|  |  |  | 	test_submenu->set_name("submenu"); | 
					
						
							|  |  |  | 	test_menu_button->get_popup()->add_submenu_item(TTR("Submenu"), "submenu"); | 
					
						
							| 
									
										
										
										
											2019-08-09 16:26:43 -03:00
										 |  |  | 	test_submenu->add_item(TTR("Subitem 1")); | 
					
						
							|  |  |  | 	test_submenu->add_item(TTR("Subitem 2")); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	first_vb->add_child(test_menu_button); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	OptionButton *test_option_button = memnew(OptionButton); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	test_option_button->add_item("OptionButton"); | 
					
						
							|  |  |  | 	test_option_button->add_separator(); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	test_option_button->add_item(TTR("Has")); | 
					
						
							|  |  |  | 	test_option_button->add_item(TTR("Many")); | 
					
						
							|  |  |  | 	test_option_button->add_item(TTR("Options")); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	first_vb->add_child(test_option_button); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	first_vb->add_child(memnew(ColorPickerButton)); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	VBoxContainer *second_vb = memnew(VBoxContainer); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	second_vb->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	main_hb->add_child(second_vb); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	second_vb->add_constant_override("separation", 10 * EDSCALE); | 
					
						
							|  |  |  | 	LineEdit *le = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	le->set_text("LineEdit"); | 
					
						
							|  |  |  | 	second_vb->add_child(le); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	le = memnew(LineEdit); | 
					
						
							|  |  |  | 	le->set_text(TTR("Disabled LineEdit")); | 
					
						
							|  |  |  | 	le->set_editable(false); | 
					
						
							|  |  |  | 	second_vb->add_child(le); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	TextEdit *te = memnew(TextEdit); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	te->set_text("TextEdit"); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	te->set_custom_minimum_size(Size2(0, 100) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	second_vb->add_child(te); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	second_vb->add_child(memnew(SpinBox)); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	HBoxContainer *vhb = memnew(HBoxContainer); | 
					
						
							|  |  |  | 	second_vb->add_child(vhb); | 
					
						
							|  |  |  | 	vhb->set_custom_minimum_size(Size2(0, 100) * EDSCALE); | 
					
						
							|  |  |  | 	vhb->add_child(memnew(VSlider)); | 
					
						
							|  |  |  | 	VScrollBar *vsb = memnew(VScrollBar); | 
					
						
							|  |  |  | 	vsb->set_page(25); | 
					
						
							|  |  |  | 	vhb->add_child(vsb); | 
					
						
							|  |  |  | 	vhb->add_child(memnew(VSeparator)); | 
					
						
							|  |  |  | 	VBoxContainer *hvb = memnew(VBoxContainer); | 
					
						
							|  |  |  | 	vhb->add_child(hvb); | 
					
						
							|  |  |  | 	hvb->set_alignment(ALIGN_CENTER); | 
					
						
							|  |  |  | 	hvb->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	hvb->add_child(memnew(HSlider)); | 
					
						
							|  |  |  | 	HScrollBar *hsb = memnew(HScrollBar); | 
					
						
							|  |  |  | 	hsb->set_page(25); | 
					
						
							|  |  |  | 	hvb->add_child(hsb); | 
					
						
							|  |  |  | 	HSlider *hs = memnew(HSlider); | 
					
						
							|  |  |  | 	hs->set_editable(false); | 
					
						
							|  |  |  | 	hvb->add_child(hs); | 
					
						
							|  |  |  | 	hvb->add_child(memnew(HSeparator)); | 
					
						
							|  |  |  | 	ProgressBar *pb = memnew(ProgressBar); | 
					
						
							|  |  |  | 	pb->set_value(50); | 
					
						
							|  |  |  | 	hvb->add_child(pb); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	VBoxContainer *third_vb = memnew(VBoxContainer); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	third_vb->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	third_vb->add_constant_override("separation", 10 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	main_hb->add_child(third_vb); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	TabContainer *tc = memnew(TabContainer); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	third_vb->add_child(tc); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	tc->set_custom_minimum_size(Size2(0, 135) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	Control *tcc = memnew(Control); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	tcc->set_name(TTR("Tab 1")); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	tc->add_child(tcc); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	tcc = memnew(Control); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	tcc->set_name(TTR("Tab 2")); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	tc->add_child(tcc); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	tcc = memnew(Control); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	tcc->set_name(TTR("Tab 3")); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	tc->add_child(tcc); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	tc->set_tab_disabled(2, true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Tree *test_tree = memnew(Tree); | 
					
						
							|  |  |  | 	third_vb->add_child(test_tree); | 
					
						
							|  |  |  | 	test_tree->set_custom_minimum_size(Size2(0, 175) * EDSCALE); | 
					
						
							|  |  |  | 	test_tree->add_constant_override("draw_relationship_lines", 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TreeItem *item = test_tree->create_item(); | 
					
						
							|  |  |  | 	item->set_text(0, "Tree"); | 
					
						
							|  |  |  | 	item = test_tree->create_item(test_tree->get_root()); | 
					
						
							|  |  |  | 	item->set_text(0, "Item"); | 
					
						
							|  |  |  | 	item = test_tree->create_item(test_tree->get_root()); | 
					
						
							|  |  |  | 	item->set_editable(0, true); | 
					
						
							|  |  |  | 	item->set_text(0, TTR("Editable Item")); | 
					
						
							|  |  |  | 	TreeItem *sub_tree = test_tree->create_item(test_tree->get_root()); | 
					
						
							|  |  |  | 	sub_tree->set_text(0, TTR("Subtree")); | 
					
						
							|  |  |  | 	item = test_tree->create_item(sub_tree); | 
					
						
							|  |  |  | 	item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); | 
					
						
							|  |  |  | 	item->set_editable(0, true); | 
					
						
							|  |  |  | 	item->set_text(0, "Check Item"); | 
					
						
							|  |  |  | 	item = test_tree->create_item(sub_tree); | 
					
						
							|  |  |  | 	item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); | 
					
						
							|  |  |  | 	item->set_editable(0, true); | 
					
						
							|  |  |  | 	item->set_range_config(0, 0, 20, 0.1); | 
					
						
							|  |  |  | 	item->set_range(0, 2); | 
					
						
							|  |  |  | 	item = test_tree->create_item(sub_tree); | 
					
						
							|  |  |  | 	item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); | 
					
						
							|  |  |  | 	item->set_editable(0, true); | 
					
						
							|  |  |  | 	item->set_text(0, TTR("Has,Many,Options")); | 
					
						
							|  |  |  | 	item->set_range(0, 2); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	main_hb->add_constant_override("separation", 20 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-09 15:38:35 -02:00
										 |  |  | 	////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	add_del_dialog = memnew(ConfirmationDialog); | 
					
						
							|  |  |  | 	add_del_dialog->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	add_child(add_del_dialog); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	VBoxContainer *dialog_vbc = memnew(VBoxContainer); | 
					
						
							|  |  |  | 	add_del_dialog->add_child(dialog_vbc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	Label *l = memnew(Label); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	l->set_text(TTR("Type:")); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	dialog_vbc->add_child(l); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	type_hbc = memnew(HBoxContainer); | 
					
						
							|  |  |  | 	dialog_vbc->add_child(type_hbc); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	type_edit = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	type_edit->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	type_hbc->add_child(type_edit); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	type_menu = memnew(MenuButton); | 
					
						
							| 
									
										
										
										
											2018-09-21 02:18:40 -03:00
										 |  |  | 	type_menu->set_flat(false); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	type_menu->set_text(".."); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	type_hbc->add_child(type_menu); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	type_menu->get_popup()->connect("id_pressed", this, "_type_menu_cbk"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	l = memnew(Label); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	l->set_text(TTR("Name:")); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	dialog_vbc->add_child(l); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	name_select_label = l; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	name_hbc = memnew(HBoxContainer); | 
					
						
							|  |  |  | 	dialog_vbc->add_child(name_hbc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	name_edit = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	name_edit->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	name_hbc->add_child(name_edit); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	name_menu = memnew(MenuButton); | 
					
						
							| 
									
										
										
										
											2018-09-21 02:18:40 -03:00
										 |  |  | 	type_menu->set_flat(false); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	name_menu->set_text(".."); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	name_hbc->add_child(name_menu); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	name_menu->get_popup()->connect("about_to_show", this, "_name_menu_about_to_show"); | 
					
						
							|  |  |  | 	name_menu->get_popup()->connect("id_pressed", this, "_name_menu_cbk"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	type_select_label = memnew(Label); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	type_select_label->set_text(TTR("Data Type:")); | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	dialog_vbc->add_child(type_select_label); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	type_select = memnew(OptionButton); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	type_select->add_item(TTR("Icon")); | 
					
						
							|  |  |  | 	type_select->add_item(TTR("Style")); | 
					
						
							| 
									
										
										
										
											2016-05-21 01:18:35 +02:00
										 |  |  | 	type_select->add_item(TTR("Font")); | 
					
						
							|  |  |  | 	type_select->add_item(TTR("Color")); | 
					
						
							| 
									
										
										
										
											2016-05-03 22:25:37 -03:00
										 |  |  | 	type_select->add_item(TTR("Constant")); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-27 14:17:02 +07:00
										 |  |  | 	dialog_vbc->add_child(type_select); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	add_del_dialog->get_ok()->connect("pressed", this, "_dialog_cbk"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	file_dialog = memnew(EditorFileDialog); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	file_dialog->add_filter("*.theme ; Theme File"); | 
					
						
							|  |  |  | 	add_child(file_dialog); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	file_dialog->connect("file_selected", this, "_save_template_cbk"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThemeEditorPlugin::edit(Object *p_node) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 22:58:51 +02:00
										 |  |  | 	if (Object::cast_to<Theme>(p_node)) { | 
					
						
							|  |  |  | 		theme_editor->edit(Object::cast_to<Theme>(p_node)); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		theme_editor->edit(Ref<Theme>()); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | bool ThemeEditorPlugin::handles(Object *p_node) const { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	return p_node->is_class("Theme"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void ThemeEditorPlugin::make_visible(bool p_visible) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	if (p_visible) { | 
					
						
							|  |  |  | 		theme_editor->set_process(true); | 
					
						
							| 
									
										
										
										
											2016-01-17 20:03:57 -03:00
										 |  |  | 		button->show(); | 
					
						
							| 
									
										
										
										
											2016-03-15 15:15:50 -03:00
										 |  |  | 		editor->make_bottom_panel_item_visible(theme_editor); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		theme_editor->set_process(false); | 
					
						
							| 
									
										
										
										
											2017-01-13 10:45:50 -03:00
										 |  |  | 		if (theme_editor->is_visible_in_tree()) | 
					
						
							| 
									
										
										
										
											2016-03-15 15:15:50 -03:00
										 |  |  | 			editor->hide_bottom_panel(); | 
					
						
							| 
									
										
										
										
											2019-05-21 13:14:45 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 20:03:57 -03:00
										 |  |  | 		button->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-15 02:01:39 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	editor = p_node; | 
					
						
							|  |  |  | 	theme_editor = memnew(ThemeEditor); | 
					
						
							|  |  |  | 	theme_editor->set_custom_minimum_size(Size2(0, 200)); | 
					
						
							| 
									
										
										
										
											2016-01-17 20:03:57 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-23 22:40:15 +08:00
										 |  |  | 	button = editor->add_bottom_panel_item(TTR("Theme"), theme_editor); | 
					
						
							| 
									
										
										
										
											2016-01-17 20:03:57 -03:00
										 |  |  | 	button->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } |