diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-14 14:25:28 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-14 14:25:28 +0000 |
| commit | d58f1115618f0458496b0e0a081238d5fda64ef5 (patch) | |
| tree | 0d87bf8067744160cf824defc783f5ff73935399 /src/desktop-style.cpp | |
| parent | Prevent returning references to local variable (diff) | |
| download | inkscape-d58f1115618f0458496b0e0a081238d5fda64ef5.tar.gz inkscape-d58f1115618f0458496b0e0a081238d5fda64ef5.zip | |
Re-Add blending modes UI using CSS instead filters
Diffstat (limited to 'src/desktop-style.cpp')
| -rw-r--r-- | src/desktop-style.cpp | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 666044bd6..092c48ec3 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -404,6 +404,7 @@ sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib: Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool(tool_path + "/usecurrent") && css_current) { + sp_repr_css_unset_property(css_current, "mix-blend-mode"); sp_repr_css_set(repr, css_current, "style"); } else { SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style"); @@ -1700,11 +1701,10 @@ objects_query_fontspecification (const std::vector<SPItem*> &objects, SPStyle *s } } -static int +int objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) { const int empty_prev = -2; - const int complex_filter = 5; int blend = 0; float blend_prev = empty_prev; bool same_blend = true; @@ -1721,43 +1721,8 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) items++; - //if object has a filter - if (style->filter.set && style->getFilter()) { - int blurcount = 0; - int blendcount = 0; - - // determine whether filter is simple (blend and/or blur) or complex - for(auto& primitive_obj: style->getFilter()->children) { - SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); - if (!primitive) { - break; - } - if (dynamic_cast<SPFeBlend *>(primitive)) { - ++blendcount; - } else if (dynamic_cast<SPGaussianBlur *>(primitive)) { - ++blurcount; - } else { - blurcount = complex_filter; - break; - } - } - - // simple filter - if(blurcount == 1 || blendcount == 1) { - for(auto& primitive_obj: style->getFilter()->children) { - SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); - if (!primitive) { - break; - } - SPFeBlend *spblend = dynamic_cast<SPFeBlend *>(&primitive_obj); - if (spblend) { - blend = spblend->blend_mode; - } - } - } - else { - blend = complex_filter; - } + if (style->mix_blend_mode.set) { + blend = style->mix_blend_mode.value; } // defaults to blend mode = "normal" else { @@ -1770,7 +1735,7 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) } if (items > 0) { - style_res->filter_blend_mode.value = blend; + style_res->mix_blend_mode.value = blend; } if (items == 0) { @@ -1958,6 +1923,7 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query) int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY); int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR); + int result_blend = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLEND); return (result_family != QUERY_STYLE_NOTHING || result_fstyle != QUERY_STYLE_NOTHING || @@ -1970,7 +1936,8 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query) result_strokecap != QUERY_STYLE_NOTHING || result_strokejoin != QUERY_STYLE_NOTHING || result_paintorder != QUERY_STYLE_NOTHING || - result_blur != QUERY_STYLE_NOTHING); + result_blur != QUERY_STYLE_NOTHING || + result_blend != QUERY_STYLE_NOTHING); } |
