summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/object-composite-settings.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-10-14 14:25:28 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-10-14 14:25:28 +0000
commitd58f1115618f0458496b0e0a081238d5fda64ef5 (patch)
tree0d87bf8067744160cf824defc783f5ff73935399 /src/ui/widget/object-composite-settings.cpp
parentPrevent returning references to local variable (diff)
downloadinkscape-d58f1115618f0458496b0e0a081238d5fda64ef5.tar.gz
inkscape-d58f1115618f0458496b0e0a081238d5fda64ef5.zip
Re-Add blending modes UI using CSS instead filters
Diffstat (limited to 'src/ui/widget/object-composite-settings.cpp')
-rw-r--r--src/ui/widget/object-composite-settings.cpp54
1 files changed, 29 insertions, 25 deletions
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.