diff options
Diffstat (limited to 'editor/editor_themes.cpp')
| -rw-r--r-- | editor/editor_themes.cpp | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 1903514ea6..cacd26a20a 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -86,7 +86,7 @@ static Ref<StyleBoxFlat> change_border_color(Ref<StyleBoxFlat> p_style, Color p_ return style; } -Ref<ImageTexture> editor_generate_icon(int p_index, bool dark_theme = true, Dictionary *p_colors = NULL, float p_scale = EDSCALE, bool force_filter = false) { +Ref<ImageTexture> editor_generate_icon(int p_index, bool convert_color, float p_scale = EDSCALE, bool force_filter = false) { Ref<ImageTexture> icon = memnew(ImageTexture); Ref<Image> img = memnew(Image); @@ -94,7 +94,7 @@ Ref<ImageTexture> 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], p_scale, true, dark_theme ? NULL : p_colors); + ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, true, convert_color); if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || force_filter) icon->create_from_image(img); // in this case filter really helps @@ -160,34 +160,41 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool dark_theme = tr clock_t begin_time = clock(); + ImageLoaderSVG::set_convert_colors(dark_theme ? NULL : &dark_icon_color_dictionary); + + // generate icons if (!only_thumbs) for (int i = 0; i < editor_icons_count; i++) { List<String>::Element *is_exception = exceptions.find(editor_icons_names[i]); - if (is_exception) { - exceptions.erase(is_exception); - } - Ref<ImageTexture> icon = editor_generate_icon(i, dark_theme, is_exception ? NULL : &dark_icon_color_dictionary); + if (is_exception) exceptions.erase(is_exception); + Ref<ImageTexture> icon = editor_generate_icon(i, !dark_theme && !is_exception); 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 // generate thumb files with the given thumb size + 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<ImageTexture> icon = editor_generate_icon(index, dark_theme, &dark_icon_color_dictionary, scale, force_filter); + List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]); + if (is_exception) exceptions.erase(is_exception); + Ref<ImageTexture> icon = editor_generate_icon(index, !dark_theme && !is_exception, 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<ImageTexture> icon = editor_generate_icon(index, dark_theme, &dark_icon_color_dictionary, scale, force_filter); + List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]); + if (is_exception) exceptions.erase(is_exception); + Ref<ImageTexture> icon = editor_generate_icon(index, !dark_theme && !is_exception, scale, force_filter); p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon); } } + ImageLoaderSVG::set_convert_colors(NULL); + clock_t end_time = clock(); double time_d = (double)(end_time - begin_time) / CLOCKS_PER_SEC; @@ -312,7 +319,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Color tab_color = highlight_tabs ? base_color.linear_interpolate(font_color, contrast) : base_color; const int border_width = CLAMP(border_size, 0, 3) * EDSCALE; - const int default_margin_size = 4 * EDSCALE; + const int default_margin_size = 4; + // styleboxes // this is the most commonly used stylebox, variations should be made as duplicate of this Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size); @@ -345,10 +353,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // style for windows, popups, etc.. Ref<StyleBoxFlat> style_popup = style_default->duplicate(); - style_popup->set_default_margin(MARGIN_LEFT, default_margin_size * 2); - style_popup->set_default_margin(MARGIN_TOP, default_margin_size * 2); - style_popup->set_default_margin(MARGIN_RIGHT, default_margin_size * 2); - style_popup->set_default_margin(MARGIN_BOTTOM, default_margin_size * 2); + style_popup->set_default_margin(MARGIN_LEFT, default_margin_size * EDSCALE * 2); + style_popup->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE * 2); + style_popup->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE * 2); + style_popup->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE * 2); style_popup->set_border_color_all(contrast_color_1); style_popup->set_border_width_all(MAX(EDSCALE, border_width)); const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1); @@ -392,7 +400,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_menu_hover_border = style_default->duplicate(); style_menu_hover_border->set_draw_center(false); style_menu_hover_border->set_border_width_all(0); - style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width * EDSCALE); + style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width); style_menu_hover_border->set_border_color_all(accent_color); Ref<StyleBoxFlat> style_menu_hover_bg = style_default->duplicate(); @@ -433,7 +441,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate(); style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width); style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size); - style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width); + style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width); style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width); theme->set_stylebox("panel", "TabContainer", style_content_panel); theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); @@ -683,14 +691,16 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("decrement_highlight", "VScrollBar", empty_icon); // HSlider - theme->set_stylebox("slider", "HSlider", make_stylebox(theme->get_icon("GuiHsliderBg", "EditorIcons"), default_margin_size, default_margin_size, default_margin_size, default_margin_size)); - theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); + theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); + theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2)); + theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); // VSlider - theme->set_stylebox("slider", "VSlider", make_stylebox(theme->get_icon("GuiVsliderBg", "EditorIcons"), default_margin_size, default_margin_size, default_margin_size, default_margin_size)); theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); + theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0)); + theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); //RichTextLabel Color rtl_combined_bg_color = dark_color_1.linear_interpolate(script_bg_color, script_bg_color.a); |