summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/editor_fonts.cpp6
-rw-r--r--tools/editor/editor_node.cpp24
-rw-r--r--tools/editor/editor_node.h1
-rw-r--r--tools/editor/editor_settings.cpp4
-rw-r--r--tools/editor/plugins/theme_editor_plugin.cpp74
-rw-r--r--tools/editor/plugins/theme_editor_plugin.h3
6 files changed, 102 insertions, 10 deletions
diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp
index 7ec22a4068..47891eef6c 100644
--- a/tools/editor/editor_fonts.cpp
+++ b/tools/editor/editor_fonts.cpp
@@ -157,12 +157,18 @@ void editor_register_fonts(Ref<Theme> p_theme) {
p_theme->set_font("doc_source","EditorFonts",df_doc_code);
+
if (editor_is_hidpi()) {
//replace default theme
Ref<Texture> di;
Ref<StyleBox> ds;
fill_default_theme(p_theme,df,df_doc,di,ds,true);
+ } else {
+ Ref<Texture> di;
+ Ref<StyleBox> ds;
+ fill_default_theme(p_theme,df,df_doc,di,ds,false);
+
}
}
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 1132db5991..a2db125d84 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -5320,13 +5320,17 @@ EditorNode::EditorNode() {
ObjectTypeDB::set_type_enabled("CollisionPolygon2D",true);
//ObjectTypeDB::set_type_enabled("BodyVolumeConvexPolygon",true);
+ Control *theme_base = memnew( Control );
+ add_child(theme_base);
+ theme_base->set_area_as_parent_rect();
+
gui_base = memnew( Panel );
- add_child(gui_base);
+ theme_base->add_child(gui_base);
gui_base->set_area_as_parent_rect();
theme = Ref<Theme>( memnew( Theme ) );
- gui_base->set_theme( theme );
+ theme_base->set_theme( theme );
editor_register_icons(theme);
editor_register_fonts(theme);
@@ -5341,6 +5345,8 @@ EditorNode::EditorNode() {
}
}
+
+
Ref<StyleBoxTexture> focus_sbt=memnew( StyleBoxTexture );
focus_sbt->set_texture(theme->get_icon("EditorFocus","EditorIcons"));
for(int i=0;i<4;i++) {
@@ -5351,6 +5357,16 @@ EditorNode::EditorNode() {
theme->set_stylebox("EditorFocus","EditorStyles",focus_sbt);
+ String custom_theme = EditorSettings::get_singleton()->get("global/custom_theme");
+ if (custom_theme!="") {
+ Ref<Theme> theme = ResourceLoader::load(custom_theme);
+ if (theme.is_valid()) {
+ gui_base->set_theme(theme);
+ }
+ }
+
+
+
resource_preview = memnew( EditorResourcePreview );
add_child(resource_preview);
progress_dialog = memnew( ProgressDialog );
@@ -6540,12 +6556,12 @@ EditorNode::EditorNode() {
{
List<StringName> tl;
StringName ei = "EditorIcons";
- gui_base->get_theme()->get_icon_list(ei,&tl);
+ theme_base->get_theme()->get_icon_list(ei,&tl);
for(List<StringName>::Element *E=tl.front();E;E=E->next()) {
if (!ObjectTypeDB::type_exists(E->get()))
continue;
- icon_type_cache[E->get()]=gui_base->get_theme()->get_icon(E->get(),ei);
+ icon_type_cache[E->get()]=theme_base->get_theme()->get_icon(E->get(),ei);
}
}
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 7023c6c174..d56cf4bc07 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -693,6 +693,7 @@ public:
static void unregister_editor_types();
Control *get_gui_base() { return gui_base; }
+ Control *get_theme_base() { return gui_base->get_parent_control(); }
static void add_io_error(const String& p_error);
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 5756b7485f..4100644311 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -518,6 +518,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["global/source_font_size"]=PropertyInfo(Variant::INT,"global/source_font_size",PROPERTY_HINT_RANGE,"10,40,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
set("global/custom_font","");
hints["global/custom_font"]=PropertyInfo(Variant::STRING,"global/custom_font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
+ set("global/custom_theme","");
+ hints["global/custom_theme"]=PropertyInfo(Variant::STRING,"global/custom_theme",PROPERTY_HINT_GLOBAL_FILE,"*.res,*.tres,*.theme",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
+
+
set("global/autoscan_project_path","");
hints["global/autoscan_project_path"]=PropertyInfo(Variant::STRING,"global/autoscan_project_path",PROPERTY_HINT_GLOBAL_DIR);
set("global/default_project_path","");
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");
diff --git a/tools/editor/plugins/theme_editor_plugin.h b/tools/editor/plugins/theme_editor_plugin.h
index 49d5ae3096..1384fa6b69 100644
--- a/tools/editor/plugins/theme_editor_plugin.h
+++ b/tools/editor/plugins/theme_editor_plugin.h
@@ -68,7 +68,8 @@ class ThemeEditor : public Control {
POPUP_CLASS_ADD,
POPUP_REMOVE,
POPUP_CLASS_REMOVE,
- POPUP_CREATE_TEMPLATE
+ POPUP_CREATE_EMPTY,
+ POPUP_CREATE_EDITOR_EMPTY
};
int popup_mode;