summaryrefslogtreecommitdiff
path: root/tools/editor/plugins/theme_editor_plugin.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-17 01:13:23 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-17 01:13:23 -0300
commitf0d9245ecf981dada4595da0e525cc95a0caf785 (patch)
tree037a745f42c5b89a1fcae1166b10a17c90883254 /tools/editor/plugins/theme_editor_plugin.cpp
parent816b3fa94de91fb671b58d7cda57f10104a682da (diff)
-added missing .inc files
-Made it possible to change the editor theme -Added two options to theme editor plugin to create empty template themes and editor themes -Make sure that saved themes to .tres keep the null theme fields, to make it easier to keep those when saving/loading the theme
Diffstat (limited to 'tools/editor/plugins/theme_editor_plugin.cpp')
-rw-r--r--tools/editor/plugins/theme_editor_plugin.cpp74
1 files changed, 69 insertions, 5 deletions
diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp
index 2673948365..77097b11f6 100644
--- a/tools/editor/plugins/theme_editor_plugin.cpp
+++ b/tools/editor/plugins/theme_editor_plugin.cpp
@@ -454,11 +454,73 @@ void ThemeEditor::_dialog_cbk() {
void ThemeEditor::_theme_menu_cbk(int p_option) {
- if (p_option==POPUP_CREATE_TEMPLATE) {
+ if (p_option==POPUP_CREATE_EMPTY || p_option==POPUP_CREATE_EDITOR_EMPTY) {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
- file_dialog->set_current_path("custom.theme");
- file_dialog->popup_centered_ratio();
+
+ Ref<Theme> base_theme;
+
+ if (p_option==POPUP_CREATE_EMPTY) {
+ 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);
+
+
+ for (List<StringName>::Element *T=types.front();T;T=T->next()) {
+ StringName type = T->get();
+
+ List<StringName> icons;
+ base_theme->get_icon_list(type,&icons);
+
+ for (List<StringName>::Element *E=icons.front();E;E=E->next()) {
+ theme->set_icon(E->get(),type,Ref<Texture>());
+ }
+
+ List<StringName> shaders;
+ base_theme->get_shader_list(type,&shaders);
+
+ for (List<StringName>::Element *E=shaders.front();E;E=E->next()) {
+ theme->set_shader(E->get(),type,Ref<Shader>());
+ }
+
+ List<StringName> styleboxs;
+ base_theme->get_stylebox_list(type,&styleboxs);
+
+ for (List<StringName>::Element *E=styleboxs.front();E;E=E->next()) {
+ theme->set_stylebox(E->get(),type,Ref<StyleBox>());
+ }
+
+ List<StringName> fonts;
+ base_theme->get_font_list(type,&fonts);
+
+ for (List<StringName>::Element *E=fonts.front();E;E=E->next()) {
+ theme->set_font(E->get(),type,Ref<Font>());
+ }
+
+ List<StringName> colors;
+ base_theme->get_color_list(type,&colors);
+
+ for (List<StringName>::Element *E=colors.front();E;E=E->next()) {
+ theme->set_color(E->get(),type,Color());
+ }
+
+
+ List<StringName> constants;
+ base_theme->get_constant_list(type,&constants);
+
+ for (List<StringName>::Element *E=constants.front();E;E=E->next()) {
+ theme->set_constant(E->get(),type,base_theme->get_constant(type,E->get()));
+ }
+
+ }
+
+ }
return;
}
@@ -602,7 +664,9 @@ ThemeEditor::ThemeEditor() {
theme_menu->get_popup()->add_item(TTR("Remove Item"),POPUP_REMOVE);
theme_menu->get_popup()->add_item(TTR("Remove Class Items"),POPUP_CLASS_REMOVE);
theme_menu->get_popup()->add_separator();
- theme_menu->get_popup()->add_item(TTR("Create Template"),POPUP_CREATE_TEMPLATE);
+ 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);
+
hb_menu->add_child(theme_menu);
theme_menu->get_popup()->connect("item_pressed", this,"_theme_menu_cbk");