diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 9334dc62bd8..f6eea296c04 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -86,7 +86,7 @@ static Ref change_border_color(Ref p_style, Color p_ return style; } -Ref editor_generate_icon(int p_index, bool dark_theme = true, Dictionary *p_colors = NULL) { +Ref editor_generate_icon(int p_index, bool dark_theme = true, Dictionary *p_colors = NULL, float p_scale = EDSCALE, bool force_filter = false) { Ref icon = memnew(ImageTexture); Ref img = memnew(Image); @@ -94,9 +94,9 @@ Ref editor_generate_icon(int p_index, bool dark_theme = true, Dict // dumb gizmo check bool is_gizmo = String(editor_icons_names[p_index]).begins_with("Gizmo"); - ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], EDSCALE, true, dark_theme ? NULL : p_colors); + ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, true, dark_theme ? NULL : p_colors); - if ((EDSCALE - (float)((int)EDSCALE)) > 0.0 || is_gizmo) + if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || force_filter) icon->create_from_image(img); // in this case filter really helps else icon->create_from_image(img, 0); @@ -108,10 +108,9 @@ Ref editor_generate_icon(int p_index, bool dark_theme = true, Dict #define ADD_CONVERT_COLOR(dictionary, old_color, new_color) dictionary[Color::html(old_color)] = Color::html(new_color) #endif -void editor_register_and_generate_icons(Ref p_theme, bool dark_theme = true) { +void editor_register_and_generate_icons(Ref p_theme, bool dark_theme = true, int p_thumb_size = 32, bool only_thumbs = false) { #ifdef SVG_ENABLED - Dictionary dark_icon_color_dictionary; //convert color: FROM TO ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e0e0e0", "#4f4f4f"); // common icon color @@ -161,13 +160,31 @@ void editor_register_and_generate_icons(Ref p_theme, bool dark_theme = tr clock_t begin_time = clock(); - for (int i = 0; i < editor_icons_count; i++) { - List::Element *is_exception = exceptions.find(editor_icons_names[i]); - if (is_exception) { - exceptions.erase(is_exception); + if (!only_thumbs) + for (int i = 0; i < editor_icons_count; i++) { + List::Element *is_exception = exceptions.find(editor_icons_names[i]); + if (is_exception) { + exceptions.erase(is_exception); + } + Ref icon = editor_generate_icon(i, dark_theme, is_exception ? NULL : &dark_icon_color_dictionary); + p_theme->set_icon(editor_icons_names[i], "EditorIcons", icon); + } + + bool force_filter = !(p_thumb_size == 64 && p_thumb_size == 32); // we dont need filter with original resolution + if (p_thumb_size >= 64) { + float scale = (float)p_thumb_size / 64.0 * EDSCALE; + for (int i = 0; i < editor_bg_thumbs_count; i++) { + int index = editor_bg_thumbs_indices[i]; + Ref icon = editor_generate_icon(index, dark_theme, &dark_icon_color_dictionary, scale, force_filter); + p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon); + } + } else { + float scale = (float)p_thumb_size / 32.0 * EDSCALE; + for (int i = 0; i < editor_md_thumbs_count; i++) { + int index = editor_md_thumbs_indices[i]; + Ref icon = editor_generate_icon(index, dark_theme, &dark_icon_color_dictionary, scale, force_filter); + p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon); } - Ref icon = editor_generate_icon(i, dark_theme, is_exception ? NULL : &dark_icon_color_dictionary); - p_theme->set_icon(editor_icons_names[i], "EditorIcons", icon); } clock_t end_time = clock(); @@ -267,7 +284,9 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_color("warning_color", "Editor", warning_color); theme->set_color("error_color", "Editor", error_color); + const int thumb_size = EDITOR_DEF("filesystem/file_dialog/thumbnail_size", 64); theme->set_constant("scale", "Editor", EDSCALE); + theme->set_constant("thumb_size", "Editor", thumb_size); theme->set_constant("dark_theme", "Editor", dark_theme); //Register icons + font @@ -279,7 +298,11 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons")); } } else { - editor_register_and_generate_icons(theme, dark_theme); + editor_register_and_generate_icons(theme, dark_theme, thumb_size); + } + // thumbnail size has changed, so we regenerate the medium sizes + if (p_theme != NULL && fabs(p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { + editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true); } editor_register_fonts(theme); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index a66d1724a10..69c14244035 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -215,9 +215,6 @@ void FileSystemDock::_notification(int p_what) { button_hist_next->set_icon(get_icon("Forward", "EditorIcons")); button_hist_prev->set_icon(get_icon("Back", "EditorIcons")); - Theme::get_default()->clear_icon("ResizedFolder", "EditorIcons"); - Theme::get_default()->clear_icon("ResizedFile", "EditorIcons"); - if (new_mode != display_mode) { set_display_mode(new_mode); } else { @@ -437,39 +434,15 @@ void FileSystemDock::_update_files(bool p_keep_selection) { files->set_max_text_lines(2); files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); - if (!has_icon("ResizedFolder", "EditorIcons")) { - Ref folder = get_icon("FolderBig", "EditorIcons"); - Ref img = folder->get_data(); - img = img->duplicate(); - img->resize(thumbnail_size, thumbnail_size); - Ref resized_folder = Ref(memnew(ImageTexture)); - resized_folder->create_from_image(img, 0); - Theme::get_default()->set_icon("ResizedFolder", "EditorIcons", resized_folder); + if (thumbnail_size < 64) { + folder_thumbnail = get_icon("FolderMediumThumb", "EditorIcons"); + file_thumbnail = get_icon("FileMediumThumb", "EditorIcons"); + file_thumbnail_broken = get_icon("FileDeadMediumThumb", "EditorIcons"); + } else { + folder_thumbnail = get_icon("FolderBigThumb", "EditorIcons"); + file_thumbnail = get_icon("FileBigThumb", "EditorIcons"); + file_thumbnail_broken = get_icon("FileDeadBigThumb", "EditorIcons"); } - - folder_thumbnail = get_icon("ResizedFolder", "EditorIcons"); - - if (!has_icon("ResizedFile", "EditorIcons")) { - Ref file = get_icon("FileBig", "EditorIcons"); - Ref img = file->get_data(); - img->resize(thumbnail_size, thumbnail_size); - Ref resized_file = Ref(memnew(ImageTexture)); - resized_file->create_from_image(img, 0); - Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file); - } - - if (!has_icon("ResizedFileBroken", "EditorIcons")) { - Ref file = get_icon("FileBigBroken", "EditorIcons"); - Ref img = file->get_data(); - img->resize(thumbnail_size, thumbnail_size); - Ref resized_file = Ref(memnew(ImageTexture)); - resized_file->create_from_image(img, 0); - Theme::get_default()->set_icon("ResizedFileBroken", "EditorIcons", resized_file); - } - - file_thumbnail = get_icon("ResizedFile", "EditorIcons"); - - file_thumbnail_broken = get_icon("ResizedFileBroken", "EditorIcons"); } else { files->set_icon_mode(ItemList::ICON_MODE_LEFT); diff --git a/editor/icons/SCsub b/editor/icons/SCsub index 534a8186a52..e28c229a38d 100644 --- a/editor/icons/SCsub +++ b/editor/icons/SCsub @@ -39,18 +39,44 @@ def make_editor_icons_action(target, source, env): s.write(icons_string.getvalue()) s.write('};\n\n') s.write("static const char *editor_icons_names[] = {\n") + + # this is used to store the indices of thumbnail icons + thumb_medium_indices = []; + thumb_big_indices = []; + index = 0 for f in svg_icons: fname = str(f) icon_name = os.path.basename(fname)[5:-4].title().replace("_", "") + if icon_name.endswith("MediumThumb"): # dont know a better way to handle this + thumb_medium_indices.append(str(index)) + if icon_name.endswith("BigThumb"): # dont know a better way to handle this + thumb_big_indices.append(str(index)) s.write('\t"%s"' % icon_name) if fname != svg_icons[-1]: s.write(",") s.write('\n') + + index += 1 + s.write('};\n') + + if thumb_medium_indices: + s.write("\n\n") + s.write("static const int editor_md_thumbs_count = %s;\n" % len(thumb_medium_indices)) + s.write("static const int editor_md_thumbs_indices[] = {") + s.write(", ".join(thumb_medium_indices)) + s.write("};\n") + if thumb_big_indices: + s.write("\n\n") + s.write("static const int editor_bg_thumbs_count = %s;\n" % len(thumb_big_indices)) + s.write("static const int editor_bg_thumbs_indices[] = {") + s.write(", ".join(thumb_big_indices)) + s.write("};\n") + s.write("#endif\n") diff --git a/editor/icons/icon_file.svg b/editor/icons/icon_file.svg new file mode 100644 index 00000000000..67a081a7040 --- /dev/null +++ b/editor/icons/icon_file.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/editor/icons/icon_file_big.svg b/editor/icons/icon_file_big_thumb.svg similarity index 100% rename from editor/icons/icon_file_big.svg rename to editor/icons/icon_file_big_thumb.svg diff --git a/editor/icons/icon_file_big_broken.svg b/editor/icons/icon_file_broken_big_thumb.svg similarity index 100% rename from editor/icons/icon_file_big_broken.svg rename to editor/icons/icon_file_broken_big_thumb.svg diff --git a/editor/icons/icon_file_big_dead.svg b/editor/icons/icon_file_dead_big_thumb.svg similarity index 100% rename from editor/icons/icon_file_big_dead.svg rename to editor/icons/icon_file_dead_big_thumb.svg diff --git a/editor/icons/icon_file_dead_medium_thumb.svg b/editor/icons/icon_file_dead_medium_thumb.svg new file mode 100644 index 00000000000..60a456a6005 --- /dev/null +++ b/editor/icons/icon_file_dead_medium_thumb.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/editor/icons/icon_file_medium_thumb.svg b/editor/icons/icon_file_medium_thumb.svg new file mode 100644 index 00000000000..a143aa5c8fe --- /dev/null +++ b/editor/icons/icon_file_medium_thumb.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/editor/icons/icon_folder_big.svg b/editor/icons/icon_folder_big.svg deleted file mode 100644 index 1c0cd3584e7..00000000000 --- a/editor/icons/icon_folder_big.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/editor/icons/icon_folder_big_thumb.svg b/editor/icons/icon_folder_big_thumb.svg new file mode 100644 index 00000000000..a7e830b019a --- /dev/null +++ b/editor/icons/icon_folder_big_thumb.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/icon_folder_medium_thumb.svg b/editor/icons/icon_folder_medium_thumb.svg new file mode 100644 index 00000000000..23b9ffc25c7 --- /dev/null +++ b/editor/icons/icon_folder_medium_thumb.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/icon_godot.svg b/editor/icons/icon_godot.svg index 32a1eeb6ec7..b8bdfcc023b 100644 --- a/editor/icons/icon_godot.svg +++ b/editor/icons/icon_godot.svg @@ -26,8 +26,5 @@ - - - diff --git a/editor/icons/icon_godot_docs.svg b/editor/icons/icon_godot_docs.svg new file mode 100644 index 00000000000..9caa09066d9 --- /dev/null +++ b/editor/icons/icon_godot_docs.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/editor/icons/icon_logo.svg b/editor/icons/icon_logo.svg new file mode 100644 index 00000000000..269fe1b245d --- /dev/null +++ b/editor/icons/icon_logo.svg @@ -0,0 +1,7 @@ + + + + + + +