From f0d9245ecf981dada4595da0e525cc95a0caf785 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 17 Jun 2016 01:13:23 -0300 Subject: -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 --- tools/editor/plugins/theme_editor_plugin.cpp | 74 ++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 5 deletions(-) (limited to 'tools/editor/plugins/theme_editor_plugin.cpp') 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 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 types; + base_theme->get_type_list(&types); + + + for (List::Element *T=types.front();T;T=T->next()) { + StringName type = T->get(); + + List icons; + base_theme->get_icon_list(type,&icons); + + for (List::Element *E=icons.front();E;E=E->next()) { + theme->set_icon(E->get(),type,Ref()); + } + + List shaders; + base_theme->get_shader_list(type,&shaders); + + for (List::Element *E=shaders.front();E;E=E->next()) { + theme->set_shader(E->get(),type,Ref()); + } + + List styleboxs; + base_theme->get_stylebox_list(type,&styleboxs); + + for (List::Element *E=styleboxs.front();E;E=E->next()) { + theme->set_stylebox(E->get(),type,Ref()); + } + + List fonts; + base_theme->get_font_list(type,&fonts); + + for (List::Element *E=fonts.front();E;E=E->next()) { + theme->set_font(E->get(),type,Ref()); + } + + List colors; + base_theme->get_color_list(type,&colors); + + for (List::Element *E=colors.front();E;E=E->next()) { + theme->set_color(E->get(),type,Color()); + } + + + List constants; + base_theme->get_constant_list(type,&constants); + + for (List::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"); -- cgit v1.2.3