From 5b83d8f8b1d91bad5d00fa014a9f73dee688a09a Mon Sep 17 00:00:00 2001 From: kiirala Date: Mon, 2 Jun 2008 13:47:31 +0000 Subject: [PATCH] Made possible to use blur on object that has a complex filter applied --- src/filter-chemistry.cpp | 2 +- src/ui/widget/filter-effect-chooser.cpp | 10 +++- src/ui/widget/object-composite-settings.cpp | 51 ++++++++++----------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index ea201b8fd..0be3252a9 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -349,7 +349,7 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, gdouble radius) { if (!item->style || !item->style->filter.set) { - //return new_filter_gaussian_blur_from_item(document, item, radius); + return new_filter_simple_from_item(document, item, "normal", radius); } SPFilter *filter = SP_FILTER(item->style->getFilter()); diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index 70db22843..80418abd8 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -56,7 +56,15 @@ sigc::signal& SimpleFilterModifier::signal_blend_blur_changed() const Glib::ustring SimpleFilterModifier::get_blend_mode() { - return _blend.get_active_row_number() == 5 ? "filter" : _blend.get_active_data()->key; + if (_blend.get_active_row_number() == 5) { + return "filter"; + } else { + const Util::EnumData *d = _blend.get_active_data(); + if (d) + return _blend.get_active_data()->key; + else + return "filter"; + } } void SimpleFilterModifier::set_blend_mode(const int val) diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 1e277fa0d..7f0f4767b 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -104,6 +104,7 @@ ObjectCompositeSettings::_blendBlurValueChanged() if (!desktop) { return; } + SPDocument *document = sp_desktop_document (desktop); if (_blocked) return; @@ -121,40 +122,34 @@ ObjectCompositeSettings::_blendBlurValueChanged() radius = 0; } - const Glib::ustring blendmode = _fe_cb.get_blend_mode(); + //const Glib::ustring blendmode = _fe_cb.get_blend_mode(); - SPFilter *filter = 0; - const bool remfilter = (blendmode == "normal" && radius == 0) || (blendmode == "filter" && !filter); - - if(blendmode != "filter" || filter) { - SPDocument *document = sp_desktop_document (desktop); - - //apply created filter to every selected item - for (StyleSubject::iterator i = _subject->begin() ; i != _subject->end() ; ++i ) { - if (!SP_IS_ITEM(*i)) { - continue; - } - - SPItem * item = SP_ITEM(*i); - SPStyle *style = SP_OBJECT_STYLE(item); - g_assert(style != NULL); + //apply created filter to every selected item + for (StyleSubject::iterator i = _subject->begin() ; i != _subject->end() ; ++i ) { + if (!SP_IS_ITEM(*i)) { + continue; + } - if(remfilter) { - remove_filter (item, false); - } - else { - if(blendmode != "filter") - filter = new_filter_simple_from_item(document, item, blendmode.c_str(), radius); - sp_style_set_property_url (SP_OBJECT(item), "filter", SP_OBJECT(filter), false); - } + SPItem * item = SP_ITEM(*i); + SPStyle *style = SP_OBJECT_STYLE(item); + g_assert(style != NULL); - //request update - SP_OBJECT(item)->requestDisplayUpdate(( SP_OBJECT_MODIFIED_FLAG | - SP_OBJECT_STYLE_MODIFIED_FLAG )); + if (radius == 0 && item->style->filter.set + && filter_is_single_gaussian_blur(SP_FILTER(item->style->getFilter()))) { + remove_filter(item, false); + } + else { + SPFilter *filter = modify_filter_gaussian_blur_from_item(document, item, radius); + sp_style_set_property_url(item, "filter", filter, false); } + + //request update + item->requestDisplayUpdate(( SP_OBJECT_MODIFIED_FLAG | + SP_OBJECT_STYLE_MODIFIED_FLAG )); } - sp_document_maybe_done (sp_desktop_document (desktop), _blur_tag.c_str(), _verb_code, _("Change blur")); + sp_document_maybe_done (document, _blur_tag.c_str(), _verb_code, + _("Change blur")); // resume interruptibility sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop)); -- 2.30.2