From 0c18009665cc24ccdace885a2385321b77c80943 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Sat, 19 Aug 2017 02:09:58 -0500 Subject: Added missing icon and svgs upscaling --- editor/asset_library_editor_plugin.cpp | 2 +- editor/editor_node.cpp | 2 +- editor/editor_themes.cpp | 4 +-- editor/icons/README.md | 12 +++++++++ editor/icons/dark/icon_checkerboard.svg | 6 +++++ editor/icons/dark/icon_default_project_icon.svg | 33 +++++++++++++++++++++++++ editor/icons/dark/icon_group.svg | 9 +++---- editor/icons/dark/icon_main_stop.svg | 5 ---- editor/icons/dark/icon_reload.svg | 6 +++++ editor/icons/dark/icon_sort.svg | 5 ++++ editor/icons/dark/icon_stop.svg | 5 ++++ editor/icons/dark/icon_thumbnail_wait.svg | 5 ++++ editor/icons/dark/icon_tool_move.svg | 2 +- editor/icons/dark/icon_tool_rotate.svg | 5 ++-- editor/icons/dark/icon_tool_scale.svg | 2 +- editor/icons/dark/icon_ungroup.svg | 12 +++------ editor/icons/icon_checkerboard.svg | 6 +++++ editor/icons/icon_default_project_icon.svg | 33 +++++++++++++++++++++++++ editor/icons/icon_group.svg | 9 +++---- editor/icons/icon_main_stop.svg | 5 ---- editor/icons/icon_reload.svg | 6 +++++ editor/icons/icon_sort.svg | 5 ++++ editor/icons/icon_stop.svg | 5 ++++ editor/icons/icon_thumbnail_wait.svg | 5 ++++ editor/icons/icon_tool_move.svg | 2 +- editor/icons/icon_tool_rotate.svg | 5 ++-- editor/icons/icon_tool_scale.svg | 2 +- editor/icons/icon_ungroup.svg | 12 +++------ editor/project_manager.cpp | 2 +- modules/svg/image_loader_svg.cpp | 17 +++++++------ modules/svg/image_loader_svg.h | 4 +-- 31 files changed, 169 insertions(+), 64 deletions(-) create mode 100644 editor/icons/README.md create mode 100644 editor/icons/dark/icon_checkerboard.svg create mode 100644 editor/icons/dark/icon_default_project_icon.svg delete mode 100644 editor/icons/dark/icon_main_stop.svg create mode 100644 editor/icons/dark/icon_reload.svg create mode 100644 editor/icons/dark/icon_sort.svg create mode 100644 editor/icons/dark/icon_stop.svg create mode 100644 editor/icons/dark/icon_thumbnail_wait.svg create mode 100644 editor/icons/icon_checkerboard.svg create mode 100644 editor/icons/icon_default_project_icon.svg delete mode 100644 editor/icons/icon_main_stop.svg create mode 100644 editor/icons/icon_reload.svg create mode 100644 editor/icons/icon_sort.svg create mode 100644 editor/icons/icon_stop.svg create mode 100644 editor/icons/icon_thumbnail_wait.svg diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp index 0a2799c51f..5ff9c7bb8a 100644 --- a/editor/asset_library_editor_plugin.cpp +++ b/editor/asset_library_editor_plugin.cpp @@ -535,7 +535,7 @@ void EditorAssetLibrary::_notification(int p_what) { TextureRect *tf = memnew(TextureRect); tf->set_texture(get_icon("Error", "EditorIcons")); - reverse->set_icon(get_icon("Updown", "EditorIcons")); + reverse->set_icon(get_icon("Sort", "EditorIcons")); error_hb->add_child(tf); error_label->raise(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 9e34c1872c..b8d9d23f49 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5657,7 +5657,7 @@ EditorNode::EditorNode() { play_hb->add_child(stop_button); //stop_button->set_toggle_mode(true); stop_button->set_focus_mode(Control::FOCUS_NONE); - stop_button->set_icon(gui_base->get_icon("MainStop", "EditorIcons")); + stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons")); stop_button->connect("pressed", this, "_menu_option", make_binds(RUN_STOP)); stop_button->set_tooltip(TTR("Stop the scene.")); stop_button->set_shortcut(ED_SHORTCUT("editor/stop", TTR("Stop"), KEY_F8)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index e0dd9b315c..d1f085f4b9 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -106,7 +106,7 @@ Ref editor_generate_icon(int p_index, bool dark_theme = true) { Ref icon = memnew(ImageTexture); Ref img = memnew(Image); - ImageLoaderSVG::create_image_from_string(img, dark_theme ? editor_icons_sources[p_index] : editor_icons_sources_dark[p_index], EDSCALE); + ImageLoaderSVG::create_image_from_string(img, dark_theme ? editor_icons_sources[p_index] : editor_icons_sources_dark[p_index], EDSCALE, true); if ((EDSCALE - (float)((int)EDSCALE)) > 0.0) icon->create_from_image(img); // in this case filter really helps else @@ -193,7 +193,7 @@ Ref create_editor_theme(const Ref p_theme) { Color separator_color = dark_theme ? Color(1, 1, 1, 0.1) : Color(0, 0, 0, 0.1); // the resolution or the dark theme parameter has not changed, so we do not regenerate the icons - if (p_theme != NULL && (p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && p_theme->get_constant("dark_theme", "Editor") == dark_theme) { + if (p_theme != NULL && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && p_theme->get_constant("dark_theme", "Editor") == dark_theme) { for (int i = 0; i < editor_icons_count; i++) { theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons")); } diff --git a/editor/icons/README.md b/editor/icons/README.md new file mode 100644 index 0000000000..f3aaa23666 --- /dev/null +++ b/editor/icons/README.md @@ -0,0 +1,12 @@ +The icons here are optimized SVGs, because the editor renders the svgs at runtime, they need +to be small in size, so they can be efficiently parsed. + +The original icons can be found at: +https://github.com/djrm/godot-design/tree/master/assets/icons + +There you can find the optimizer script. + +If you add a new icon, please make a pull request to this repo: +https://github.com/djrm/godot-design/ + +and store the the optimized SVG version here. diff --git a/editor/icons/dark/icon_checkerboard.svg b/editor/icons/dark/icon_checkerboard.svg new file mode 100644 index 0000000000..dcb8adb2d7 --- /dev/null +++ b/editor/icons/dark/icon_checkerboard.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/editor/icons/dark/icon_default_project_icon.svg b/editor/icons/dark/icon_default_project_icon.svg new file mode 100644 index 0000000000..d16d137550 --- /dev/null +++ b/editor/icons/dark/icon_default_project_icon.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/editor/icons/dark/icon_group.svg b/editor/icons/dark/icon_group.svg index 3c29f58bf5..324de52572 100644 --- a/editor/icons/dark/icon_group.svg +++ b/editor/icons/dark/icon_group.svg @@ -1,9 +1,6 @@ - - - - - - + + + diff --git a/editor/icons/dark/icon_main_stop.svg b/editor/icons/dark/icon_main_stop.svg deleted file mode 100644 index 1b856b5153..0000000000 --- a/editor/icons/dark/icon_main_stop.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/editor/icons/dark/icon_reload.svg b/editor/icons/dark/icon_reload.svg new file mode 100644 index 0000000000..4c5f0e7dbc --- /dev/null +++ b/editor/icons/dark/icon_reload.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/editor/icons/dark/icon_sort.svg b/editor/icons/dark/icon_sort.svg new file mode 100644 index 0000000000..87bab3cad7 --- /dev/null +++ b/editor/icons/dark/icon_sort.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/dark/icon_stop.svg b/editor/icons/dark/icon_stop.svg new file mode 100644 index 0000000000..1b856b5153 --- /dev/null +++ b/editor/icons/dark/icon_stop.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/dark/icon_thumbnail_wait.svg b/editor/icons/dark/icon_thumbnail_wait.svg new file mode 100644 index 0000000000..833e6f7f69 --- /dev/null +++ b/editor/icons/dark/icon_thumbnail_wait.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/dark/icon_tool_move.svg b/editor/icons/dark/icon_tool_move.svg index de89f59ac9..e5452a5691 100644 --- a/editor/icons/dark/icon_tool_move.svg +++ b/editor/icons/dark/icon_tool_move.svg @@ -1,5 +1,5 @@ - + diff --git a/editor/icons/dark/icon_tool_rotate.svg b/editor/icons/dark/icon_tool_rotate.svg index 4c5f0e7dbc..39a208bb2b 100644 --- a/editor/icons/dark/icon_tool_rotate.svg +++ b/editor/icons/dark/icon_tool_rotate.svg @@ -1,6 +1,5 @@ - - - + + diff --git a/editor/icons/dark/icon_tool_scale.svg b/editor/icons/dark/icon_tool_scale.svg index 2711dae1a3..823baf4dda 100644 --- a/editor/icons/dark/icon_tool_scale.svg +++ b/editor/icons/dark/icon_tool_scale.svg @@ -1,5 +1,5 @@ - + diff --git a/editor/icons/dark/icon_ungroup.svg b/editor/icons/dark/icon_ungroup.svg index 97932c95e0..7bebe96e76 100644 --- a/editor/icons/dark/icon_ungroup.svg +++ b/editor/icons/dark/icon_ungroup.svg @@ -1,12 +1,6 @@ - - - - - - - - - + + + diff --git a/editor/icons/icon_checkerboard.svg b/editor/icons/icon_checkerboard.svg new file mode 100644 index 0000000000..078c54a761 --- /dev/null +++ b/editor/icons/icon_checkerboard.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/editor/icons/icon_default_project_icon.svg b/editor/icons/icon_default_project_icon.svg new file mode 100644 index 0000000000..d16d137550 --- /dev/null +++ b/editor/icons/icon_default_project_icon.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/editor/icons/icon_group.svg b/editor/icons/icon_group.svg index 5e700de162..e607f35660 100644 --- a/editor/icons/icon_group.svg +++ b/editor/icons/icon_group.svg @@ -1,9 +1,6 @@ - - - - - - + + + diff --git a/editor/icons/icon_main_stop.svg b/editor/icons/icon_main_stop.svg deleted file mode 100644 index 640b2998f6..0000000000 --- a/editor/icons/icon_main_stop.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/editor/icons/icon_reload.svg b/editor/icons/icon_reload.svg new file mode 100644 index 0000000000..ae0cf02170 --- /dev/null +++ b/editor/icons/icon_reload.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/editor/icons/icon_sort.svg b/editor/icons/icon_sort.svg new file mode 100644 index 0000000000..1e2e16f459 --- /dev/null +++ b/editor/icons/icon_sort.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/icon_stop.svg b/editor/icons/icon_stop.svg new file mode 100644 index 0000000000..640b2998f6 --- /dev/null +++ b/editor/icons/icon_stop.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/icon_thumbnail_wait.svg b/editor/icons/icon_thumbnail_wait.svg new file mode 100644 index 0000000000..c38ea1de0c --- /dev/null +++ b/editor/icons/icon_thumbnail_wait.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/editor/icons/icon_tool_move.svg b/editor/icons/icon_tool_move.svg index 51ab4bc0df..79fd083669 100644 --- a/editor/icons/icon_tool_move.svg +++ b/editor/icons/icon_tool_move.svg @@ -1,5 +1,5 @@ - + diff --git a/editor/icons/icon_tool_rotate.svg b/editor/icons/icon_tool_rotate.svg index ae0cf02170..0a5c0fc340 100644 --- a/editor/icons/icon_tool_rotate.svg +++ b/editor/icons/icon_tool_rotate.svg @@ -1,6 +1,5 @@ - - - + + diff --git a/editor/icons/icon_tool_scale.svg b/editor/icons/icon_tool_scale.svg index 70acd52082..3d771651bd 100644 --- a/editor/icons/icon_tool_scale.svg +++ b/editor/icons/icon_tool_scale.svg @@ -1,5 +1,5 @@ - + diff --git a/editor/icons/icon_ungroup.svg b/editor/icons/icon_ungroup.svg index edab685ef7..cdda5d3dbf 100644 --- a/editor/icons/icon_ungroup.svg +++ b/editor/icons/icon_ungroup.svg @@ -1,12 +1,6 @@ - - - - - - - - - + + + diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 68dfe7e967..4c46879887 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1449,7 +1449,7 @@ void ProjectListFilter::_filter_option_selected(int p_idx) { void ProjectListFilter::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - clear_search_button->set_icon(get_icon("CloseHover", "EditorIcons")); + clear_search_button->set_icon(get_icon("Close", "EditorIcons")); } break; } } diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index cc801775b8..46931fb0f6 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -47,7 +47,7 @@ SVGRasterizer::~SVGRasterizer() { SVGRasterizer ImageLoaderSVG::rasterizer; -Error ImageLoaderSVG::_create_image(Ref p_image, const PoolVector *p_data, float p_scale) { +Error ImageLoaderSVG::_create_image(Ref p_image, const PoolVector *p_data, float p_scale, bool upsample) { NSVGimage *svg_image; PoolVector::Read src_r = p_data->read(); svg_image = nsvgParse((char *)src_r.ptr(), "px", 96); @@ -55,15 +55,18 @@ Error ImageLoaderSVG::_create_image(Ref p_image, const PoolVectorwidth * p_scale); - int h = (int)(svg_image->height * p_scale); + + float upscale = upsample ? 2.0 : 1.0; + + int w = (int)(svg_image->width * p_scale * upscale); + int h = (int)(svg_image->height * p_scale * upscale); PoolVector dst_image; dst_image.resize(w * h * 4); PoolVector::Write dw = dst_image.write(); - rasterizer.rasterize(svg_image, 0, 0, p_scale, (unsigned char *)dw.ptr(), w, h, w * 4); + rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw.ptr(), w, h, w * 4); dw = PoolVector::Write(); p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image); @@ -75,7 +78,7 @@ Error ImageLoaderSVG::_create_image(Ref p_image, const PoolVector p_image, const char *svg_str, float p_scale) { +Error ImageLoaderSVG::create_image_from_string(Ref p_image, const char *svg_str, float p_scale, bool upsample) { size_t str_len = strlen(svg_str); PoolVector src_data; @@ -83,7 +86,7 @@ Error ImageLoaderSVG::create_image_from_string(Ref p_image, const char *s PoolVector::Write src_w = src_data.write(); memcpy(src_w.ptr(), svg_str, str_len); - return _create_image(p_image, &src_data, p_scale); + return _create_image(p_image, &src_data, p_scale, upsample); } Error ImageLoaderSVG::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { @@ -94,7 +97,7 @@ Error ImageLoaderSVG::load_image(Ref p_image, FileAccess *f, bool p_force PoolVector::Write src_w = src_image.write(); f->get_buffer(src_w.ptr(), size); - return _create_image(p_image, &src_image, p_scale); + return _create_image(p_image, &src_image, p_scale, 1.0); } void ImageLoaderSVG::get_recognized_extensions(List *p_extensions) const { diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h index 2b6a59edc8..d93e1e3d62 100644 --- a/modules/svg/image_loader_svg.h +++ b/modules/svg/image_loader_svg.h @@ -54,10 +54,10 @@ public: class ImageLoaderSVG : public ImageFormatLoader { static SVGRasterizer rasterizer; - static Error _create_image(Ref p_image, const PoolVector *p_data, float p_scale); + static Error _create_image(Ref p_image, const PoolVector *p_data, float p_scale, bool upsample); public: - static Error create_image_from_string(Ref p_image, const char *p_svg_str, float p_scale); + static Error create_image_from_string(Ref p_image, const char *p_svg_str, float p_scale, bool upsample); virtual Error load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale); virtual void get_recognized_extensions(List *p_extensions) const; -- cgit v1.2.3