From d58f1115618f0458496b0e0a081238d5fda64ef5 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Mon, 14 Oct 2019 14:25:28 +0000 Subject: Re-Add blending modes UI using CSS instead filters --- src/ui/widget/object-composite-settings.cpp | 54 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'src/ui/widget/object-composite-settings.cpp') diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 6e37c095b..4052e1d38 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -113,13 +113,18 @@ ObjectCompositeSettings::_blendBlurValueChanged() SPStyle *style = item->style; g_assert(style != nullptr); - if (blendmode != "normal") { - SPFilter *filter = new_filter_simple_from_item(document, item, blendmode.c_str(), radius); - sp_style_set_property_url(item, "filter", filter, false); + SPCSSAttr *css = sp_repr_css_attr_new(); + + if (blendmode == "normal") { + sp_repr_css_unset_property(css, "mix-blend-mode"); } else { - sp_style_set_property_url(item, "filter", nullptr, false); + sp_repr_css_set_property(css, "mix-blend-mode", blendmode.c_str()); } + _subject->setCSS(css); + + sp_repr_css_attr_unref(css); + if (radius == 0 && item->style->filter.set && filter_is_single_gaussian_blur(SP_FILTER(item->style->getFilter()))) { remove_filter(item, false); @@ -192,7 +197,6 @@ ObjectCompositeSettings::_subjectChanged() { if (_blocked) return; _blocked = true; - SPStyle query(desktop->getDocument()); int result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_MASTEROPACITY); @@ -213,32 +217,32 @@ ObjectCompositeSettings::_subjectChanged() { break; case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_SAME: - _filter_modifier.set_blend_mode(query.filter_blend_mode.value); + _filter_modifier.set_blend_mode(query.mix_blend_mode.value); // here dont work mix_blend_mode.set break; case QUERY_STYLE_MULTIPLE_DIFFERENT: // TODO: set text break; } - if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) { - int blur_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLUR); - switch (blur_result) { - case QUERY_STYLE_NOTHING: //no blurring - _filter_modifier.set_blur_value(0); - break; - case QUERY_STYLE_SINGLE: - case QUERY_STYLE_MULTIPLE_AVERAGED: - case QUERY_STYLE_MULTIPLE_SAME: - Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX); - if (bbox) { - double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct? - //update blur widget value - float radius = query.filter_gaussianBlur_deviation.value; - float percent = radius * 400 / perimeter; // so that for a square, 100% == half side - _filter_modifier.set_blur_value(percent); - } - break; - } + int blur_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLUR); + switch (blur_result) { + case QUERY_STYLE_NOTHING: // no blurring + _filter_modifier.set_blur_value(0); + break; + case QUERY_STYLE_SINGLE: + case QUERY_STYLE_MULTIPLE_AVERAGED: + case QUERY_STYLE_MULTIPLE_SAME: + Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX); + if (bbox) { + double perimeter = + bbox->dimensions()[Geom::X] + + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct? + // update blur widget value + float radius = query.filter_gaussianBlur_deviation.value; + float percent = radius * 400 / perimeter; // so that for a square, 100% == half side + _filter_modifier.set_blur_value(percent); + } + break; } // If we have nothing selected, disable dialog. -- cgit v1.2.3