Code

Made possible to use blur on object that has a complex filter applied
authorkiirala <kiirala@users.sourceforge.net>
Mon, 2 Jun 2008 13:47:31 +0000 (13:47 +0000)
committerkiirala <kiirala@users.sourceforge.net>
Mon, 2 Jun 2008 13:47:31 +0000 (13:47 +0000)
src/filter-chemistry.cpp
src/ui/widget/filter-effect-chooser.cpp
src/ui/widget/object-composite-settings.cpp

index ea201b8fde932bf5a3d027a51edb6d26661a5134..0be3252a9f3b874e25f6541d6c6e680b637aee09 100644 (file)
@@ -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());
index 70db2284359786970ffe8594eff26d235a880ee1..80418abd883673403bfaf32cc1cfbf6b3d9b26ca 100644 (file)
@@ -56,7 +56,15 @@ sigc::signal<void>& 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<NR::FilterBlendMode> *d = _blend.get_active_data();
+        if (d)
+            return _blend.get_active_data()->key;
+        else
+            return "filter";
+    }
 }
 
 void SimpleFilterModifier::set_blend_mode(const int val)
index 1e277fa0dcc6cfdfbde4395aa1453bcb2d8f23c6..7f0f4767b6ea4b0a1b53b62e4c6f89602da2309a 100644 (file)
@@ -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));