Code

factor filter and opacity controls into separate metawidget
authormental <mental@users.sourceforge.net>
Tue, 1 Jan 2008 04:40:04 +0000 (04:40 +0000)
committermental <mental@users.sourceforge.net>
Tue, 1 Jan 2008 04:40:04 +0000 (04:40 +0000)
src/ui/dialog/fill-and-stroke.cpp
src/ui/dialog/fill-and-stroke.h
src/ui/widget/Makefile_insert
src/ui/widget/object-composite-settings.cpp [new file with mode: 0644]
src/ui/widget/object-composite-settings.h [new file with mode: 0644]

index ab25f5bb3da0d5055a9d7795989fa78e66a5d8b7..d4c2161870d40f95691cd631dc2cb92f3d093309 100644 (file)
@@ -29,7 +29,6 @@
 #include "xml/repr.h"
 #include "widgets/icon.h"
 
-
 #include "dialogs/fill-style.h"
 #include "dialogs/stroke-style.h"
 
@@ -39,36 +38,11 @@ namespace Inkscape {
 namespace UI {
 namespace Dialog {
 
-void on_selection_changed(Inkscape::Application *inkscape,
-                          Inkscape::Selection *selection,
-                          FillAndStroke *dlg)
-{
-    dlg->selectionChanged(inkscape, selection);
-}
-
-void on_selection_modified(Inkscape::Application *inkscape,
-                           Inkscape::Selection *selection,
-                           guint /*flags*/,
-                           FillAndStroke *dlg)
-{
-    dlg->selectionChanged(inkscape, selection);
-}
-
-
 FillAndStroke::FillAndStroke()
     : UI::Widget::Panel ("", "dialogs.fillstroke", SP_VERB_DIALOG_FILL_STROKE),
       _page_fill(1, 1, true, true),
       _page_stroke_paint(1, 1, true, true),
-      _page_stroke_style(1, 1, true, true),
-      _fe_vbox(false, 0),
-      _fe_alignment(1, 1, 1, 1),
-      _opacity_vbox(false, 0),
-      _opacity_label_box(false, 0),
-      _opacity_label(_("Opacity, %"), 0.0, 1.0, true),
-      _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0),
-      _opacity_hscale(_opacity_adjustment),
-      _opacity_spin_button(_opacity_adjustment, 0.01, 1),
-      _blocked(false)
+      _page_stroke_style(1, 1, true, true)
 {
     Gtk::Box *contents = _getContents();
     contents->set_spacing(0);
@@ -83,31 +57,7 @@ FillAndStroke::FillAndStroke()
     _layoutPageStrokePaint();
     _layoutPageStrokeStyle();
 
-    // Filter Effects
-    contents->pack_start(_fe_vbox, false, false, 2);
-    _fe_alignment.set_padding(0, 0, 4, 0);
-    _fe_alignment.add(_fe_cb);
-    _fe_vbox.pack_start(_fe_alignment, false, false, 0);
-
-    _fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::FillAndStroke::_blendBlurValueChanged));
-
-    // Opacity
-    contents->pack_start(_opacity_vbox, false, false, 2);
-    _opacity_label_box.pack_start(_opacity_label, false, false, 4);
-    _opacity_vbox.pack_start(_opacity_label_box, false, false, 0);
-    _opacity_vbox.pack_start(_opacity_hbox, false, false, 0);
-    _opacity_hbox.pack_start(_opacity_hscale, true, true, 4);
-    _opacity_hbox.pack_start(_opacity_spin_button, false, false, 0);
-    _opacity_hscale.set_draw_value(false);
-    _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::FillAndStroke::_opacityValueChanged));
-
-    // these callbacks are only for the blur and master opacity update; the tabs above take care of themselves
-    g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this );
-    g_signal_connect ( G_OBJECT (INKSCAPE), "change_subselection", G_CALLBACK (on_selection_changed), this );
-    g_signal_connect ( G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this );
-    g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (on_selection_changed), this );
-
-    selectionChanged(INKSCAPE, sp_desktop_selection(getDesktop()));
+    contents->pack_start(_composite_settings, false, false, 0);
 
     show_all_children();
 }
@@ -158,178 +108,6 @@ FillAndStroke::showPageStrokeStyle()
     _notebook.set_current_page(2);
 }
 
-
-void
-FillAndStroke::_blendBlurValueChanged()
-{
-    if (_blocked)
-        return;
-    _blocked = true;
-
-    //get desktop
-    SPDesktop *desktop = getDesktop();
-    if (!desktop) {
-        return;
-    }
-
-    // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
-    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
-
-    //get current selection
-    Inkscape::Selection *selection = sp_desktop_selection (desktop);
-
-    NR::Maybe<NR::Rect> bbox = selection->bounds();
-    if (!bbox) {
-        return;
-    }
-    //get list of selected items
-    GSList const *items = selection->itemList();
-    //get current document
-    SPDocument *document = sp_desktop_document (desktop);
-
-    double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y);
-
-    const Glib::ustring blendmode = _fe_cb.get_blend_mode();
-    double radius = _fe_cb.get_blur_value() * perimeter / 400;
-
-    SPFilter *filter = 0;
-    const bool remfilter = (blendmode == "normal" && radius == 0) || (blendmode == "filter" && !filter);
-
-    if(blendmode != "filter" || filter) {
-        //apply created filter to every selected item
-        for (GSList const *i = items; i != NULL; i = i->next) {
-            SPItem * item = SP_ITEM(i->data);
-            SPStyle *style = SP_OBJECT_STYLE(item);
-            g_assert(style != NULL);
-
-            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);
-            }
-
-            //request update
-            SP_OBJECT(item)->requestDisplayUpdate(( SP_OBJECT_MODIFIED_FLAG |
-                                                    SP_OBJECT_STYLE_MODIFIED_FLAG ));
-        }
-    }
-
-    sp_document_maybe_done (sp_desktop_document (desktop), "fillstroke:blur", SP_VERB_DIALOG_FILL_STROKE,  _("Change blur"));
-
-    // resume interruptibility
-    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
-
-    _blocked = false;
-}
-
-void
-FillAndStroke::_opacityValueChanged()
-{
-    if (_blocked)
-        return;
-    _blocked = true;
-
-    SPDesktop *desktop = getDesktop();
-
-    // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
-    // UPDATE: crash fixed in GTK+ 2.10.7 (bug 374378), remove this as soon as it's reasonably common
-    // (though this only fixes the crash, not the multiple change events)
-    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
-
-    SPCSSAttr *css = sp_repr_css_attr_new ();
-
-    Inkscape::CSSOStringStream os;
-    os << CLAMP (_opacity_adjustment.get_value() / 100, 0.0, 1.0);
-    sp_repr_css_set_property (css, "opacity", os.str().c_str());
-
-    sp_desktop_set_style (desktop, css);
-
-    sp_repr_css_attr_unref (css);
-
-    sp_document_maybe_done (sp_desktop_document (desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
-                            _("Change opacity"));
-
-    // resume interruptibility
-    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
-
-    _blocked = false;
-}
-
-void
-FillAndStroke::selectionChanged(Inkscape::Application */*inkscape*/,
-                                Inkscape::Selection */*selection*/)
-{
-    if (_blocked)
-        return;
-    _blocked = true;
-
-    SPDesktop *desktop = getDesktop();
-
-    // create temporary style
-    SPStyle *query = sp_style_new (sp_desktop_document(desktop));
-    // query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
-    int result = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
-
-    switch (result) {
-        case QUERY_STYLE_NOTHING:
-            _opacity_hbox.set_sensitive(false);
-            // gtk_widget_set_sensitive (opa, FALSE);
-            break;
-        case QUERY_STYLE_SINGLE:
-        case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently
-        case QUERY_STYLE_MULTIPLE_SAME:
-            _opacity_hbox.set_sensitive(true);
-            _opacity_adjustment.set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
-            break;
-    }
-
-    //query now for current filter mode and average blurring of selection
-    const int blend_result = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLEND);
-    switch(blend_result) {
-        case QUERY_STYLE_NOTHING:
-            _fe_cb.set_sensitive(false);
-            break;
-        case QUERY_STYLE_SINGLE:
-        case QUERY_STYLE_MULTIPLE_SAME:
-            _fe_cb.set_blend_mode(query->filter_blend_mode.value);
-            _fe_cb.set_sensitive(true);
-            break;
-        case QUERY_STYLE_MULTIPLE_DIFFERENT:
-            // TODO: set text
-            _fe_cb.set_sensitive(false);
-            break;
-    }
-
-    if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) {
-        int blur_result = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
-        switch (blur_result) {
-            case QUERY_STYLE_NOTHING: //no blurring
-                _fe_cb.set_blur_sensitive(false);
-                break;
-            case QUERY_STYLE_SINGLE:
-            case QUERY_STYLE_MULTIPLE_AVERAGED:
-            case QUERY_STYLE_MULTIPLE_SAME:
-                NR::Maybe<NR::Rect> bbox = sp_desktop_selection(desktop)->bounds();
-                if (bbox) {
-                    double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y);
-                    _fe_cb.set_blur_sensitive(true);
-                    //update blur widget value
-                    float radius = query->filter_gaussianBlur_deviation.value;
-                    float percent = radius * 400 / perimeter; // so that for a square, 100% == half side
-                    _fe_cb.set_blur_value(percent);
-                }
-                break;
-        }
-    }
-
-    sp_style_unref(query);
-
-    _blocked = false;
-}
-
 Gtk::HBox&
 FillAndStroke::_createPageTabLabel(const Glib::ustring& label, const char *label_image)
 {
index f2313adae6124914432d7c8d500333ca30d10492..ee8c32b4f251a84eb08758c2977c65e917203efd 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "ui/widget/panel.h"
 #include "ui/widget/notebook-page.h"
-#include "ui/widget/filter-effect-chooser.h"
+#include "ui/widget/object-composite-settings.h"
 
 using namespace Inkscape::UI::Widget;
 
@@ -52,30 +52,15 @@ protected:
     NotebookPage    _page_stroke_paint;
     NotebookPage    _page_stroke_style;
 
-    Gtk::VBox       _fe_vbox;
-    Gtk::Alignment  _fe_alignment;
-
-    Gtk::VBox       _opacity_vbox;
-    Gtk::HBox       _opacity_label_box;
-    Gtk::HBox       _opacity_hbox;
-    Gtk::Label      _opacity_label;
-    Gtk::Adjustment _opacity_adjustment;
-    Gtk::HScale     _opacity_hscale;
-    Gtk::SpinButton _opacity_spin_button;
+    ObjectCompositeSettings _composite_settings;
 
     Gtk::HBox &_createPageTabLabel(const Glib::ustring &label, 
                                    const char *label_image);
-    SimpleFilterModifier _fe_cb;
 
     void _layoutPageFill();
     void _layoutPageStrokePaint();
     void _layoutPageStrokeStyle();
 
-    void _blendBlurValueChanged();
-    void _opacityValueChanged();
-
-    bool _blocked;
-
 private:
     FillAndStroke(FillAndStroke const &d);
     FillAndStroke& operator=(FillAndStroke const &d);
index 33a65effe156e3fd163c8278ecaab5244c2bbf9a..7661aeb8e5f5c838cab6cc1b20a0788b97714a41 100644 (file)
@@ -38,6 +38,8 @@ ui_widget_libuiwidget_a_SOURCES =     \
        ui/widget/licensor.h            \
        ui/widget/notebook-page.cpp     \
        ui/widget/notebook-page.h       \
+       ui/widget/object-composite-settings.cpp \
+       ui/widget/object-composite-settings.h   \
        ui/widget/page-sizer.cpp        \
        ui/widget/page-sizer.h          \
        ui/widget/panel.cpp             \
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
new file mode 100644 (file)
index 0000000..65458dc
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * A widget for controlling object compositing (filter, opacity, etc.)
+ *
+ * Authors:
+ *   Bryce W. Harrington <bryce@bryceharrington.org>
+ *   Gustav Broberg <broberg@kth.se>
+ *
+ * Copyright (C) 2004--2007 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glibmm/i18n.h>
+
+#include "desktop-handles.h"
+#include "desktop-style.h"
+#include "document.h"
+#include "filter-chemistry.h"
+#include "inkscape.h"
+#include "inkscape-stock.h"
+#include "selection.h"
+#include "style.h"
+#include "svg/css-ostringstream.h"
+#include "verbs.h"
+#include "xml/repr.h"
+#include "widgets/icon.h"
+#include "ui/widget/object-composite-settings.h"
+#include "display/sp-canvas.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+void ObjectCompositeSettings::on_selection_changed(
+  Inkscape::Application *inkscape,
+  Inkscape::Selection *selection,
+  ObjectCompositeSettings *w
+) {
+    w->selectionChanged(inkscape, selection);
+}
+
+void ObjectCompositeSettings::on_selection_modified(
+  Inkscape::Application *inkscape,
+  Inkscape::Selection *selection,
+  guint /*flags*/,
+  ObjectCompositeSettings *w
+) {
+    w->selectionChanged(inkscape, selection);
+}
+
+ObjectCompositeSettings::ObjectCompositeSettings()
+: _fe_vbox(false, 0),
+  _fe_alignment(1, 1, 1, 1),
+  _opacity_vbox(false, 0),
+  _opacity_label_box(false, 0),
+  _opacity_label(_("Opacity, %"), 0.0, 1.0, true),
+  _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0),
+  _opacity_hscale(_opacity_adjustment),
+  _opacity_spin_button(_opacity_adjustment, 0.01, 1),
+  _blocked(false)
+{
+    // Filter Effects
+    pack_start(_fe_vbox, false, false, 2);
+    _fe_alignment.set_padding(0, 0, 4, 0);
+    _fe_alignment.add(_fe_cb);
+    _fe_vbox.pack_start(_fe_alignment, false, false, 0);
+    _fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_blendBlurValueChanged));
+
+    // Opacity
+    pack_start(_opacity_vbox, false, false, 2);
+    _opacity_label_box.pack_start(_opacity_label, false, false, 4);
+    _opacity_vbox.pack_start(_opacity_label_box, false, false, 0);
+    _opacity_vbox.pack_start(_opacity_hbox, false, false, 0);
+    _opacity_hbox.pack_start(_opacity_hscale, true, true, 4);
+    _opacity_hbox.pack_start(_opacity_spin_button, false, false, 0);
+    _opacity_hscale.set_draw_value(false);
+    _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged));
+
+    _sel_changed = g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this );
+    _subsel_changed = g_signal_connect ( G_OBJECT (INKSCAPE), "change_subselection", G_CALLBACK (on_selection_changed), this );
+    _sel_modified = g_signal_connect ( G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this );
+    _desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (on_selection_changed), this );
+
+    selectionChanged(INKSCAPE, sp_desktop_selection(SP_ACTIVE_DESKTOP));
+
+    show_all_children();
+}
+
+ObjectCompositeSettings::~ObjectCompositeSettings() {
+    g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _sel_changed);
+    g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _subsel_changed);
+    g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _sel_modified);
+    g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _desktop_activated);
+}
+
+void
+ObjectCompositeSettings::_blendBlurValueChanged()
+{
+    if (_blocked)
+        return;
+    _blocked = true;
+
+    //get desktop
+    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+    if (!desktop) {
+        return;
+    }
+
+    // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
+    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+
+    //get current selection
+    Inkscape::Selection *selection = sp_desktop_selection (desktop);
+
+    NR::Maybe<NR::Rect> bbox = selection->bounds();
+    if (!bbox) {
+        return;
+    }
+    //get list of selected items
+    GSList const *items = selection->itemList();
+    //get current document
+    SPDocument *document = sp_desktop_document (desktop);
+
+    double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y);
+
+    const Glib::ustring blendmode = _fe_cb.get_blend_mode();
+    double radius = _fe_cb.get_blur_value() * perimeter / 400;
+
+    SPFilter *filter = 0;
+    const bool remfilter = (blendmode == "normal" && radius == 0) || (blendmode == "filter" && !filter);
+
+    if(blendmode != "filter" || filter) {
+        //apply created filter to every selected item
+        for (GSList const *i = items; i != NULL; i = i->next) {
+            SPItem * item = SP_ITEM(i->data);
+            SPStyle *style = SP_OBJECT_STYLE(item);
+            g_assert(style != NULL);
+
+
+            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);
+            }
+
+            //request update
+            SP_OBJECT(item)->requestDisplayUpdate(( SP_OBJECT_MODIFIED_FLAG |
+                                                    SP_OBJECT_STYLE_MODIFIED_FLAG ));
+        }
+    }
+
+    sp_document_maybe_done (sp_desktop_document (desktop), "fillstroke:blur", SP_VERB_DIALOG_FILL_STROKE,  _("Change blur"));
+
+    // resume interruptibility
+    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+
+    _blocked = false;
+}
+
+void
+ObjectCompositeSettings::_opacityValueChanged()
+{
+    if (_blocked)
+        return;
+    _blocked = true;
+
+    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+
+    // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
+    // UPDATE: crash fixed in GTK+ 2.10.7 (bug 374378), remove this as soon as it's reasonably common
+    // (though this only fixes the crash, not the multiple change events)
+    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+
+    SPCSSAttr *css = sp_repr_css_attr_new ();
+
+    Inkscape::CSSOStringStream os;
+    os << CLAMP (_opacity_adjustment.get_value() / 100, 0.0, 1.0);
+    sp_repr_css_set_property (css, "opacity", os.str().c_str());
+
+    sp_desktop_set_style (desktop, css);
+
+    sp_repr_css_attr_unref (css);
+
+    sp_document_maybe_done (sp_desktop_document (desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
+                            _("Change opacity"));
+
+    // resume interruptibility
+    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+
+    _blocked = false;
+}
+
+void
+ObjectCompositeSettings::selectionChanged(Inkscape::Application */*inkscape*/,
+                                          Inkscape::Selection */*selection*/)
+{
+    if (_blocked)
+        return;
+    _blocked = true;
+
+    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+
+    // create temporary style
+    SPStyle *query = sp_style_new (sp_desktop_document(desktop));
+    // query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
+    int result = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
+
+    switch (result) {
+        case QUERY_STYLE_NOTHING:
+            _opacity_hbox.set_sensitive(false);
+            // gtk_widget_set_sensitive (opa, FALSE);
+            break;
+        case QUERY_STYLE_SINGLE:
+        case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently
+        case QUERY_STYLE_MULTIPLE_SAME:
+            _opacity_hbox.set_sensitive(true);
+            _opacity_adjustment.set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
+            break;
+    }
+
+    //query now for current filter mode and average blurring of selection
+    const int blend_result = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLEND);
+    switch(blend_result) {
+        case QUERY_STYLE_NOTHING:
+            _fe_cb.set_sensitive(false);
+            break;
+        case QUERY_STYLE_SINGLE:
+        case QUERY_STYLE_MULTIPLE_SAME:
+            _fe_cb.set_blend_mode(query->filter_blend_mode.value);
+            _fe_cb.set_sensitive(true);
+            break;
+        case QUERY_STYLE_MULTIPLE_DIFFERENT:
+            // TODO: set text
+            _fe_cb.set_sensitive(false);
+            break;
+    }
+
+    if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) {
+        int blur_result = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
+        switch (blur_result) {
+            case QUERY_STYLE_NOTHING: //no blurring
+                _fe_cb.set_blur_sensitive(false);
+                break;
+            case QUERY_STYLE_SINGLE:
+            case QUERY_STYLE_MULTIPLE_AVERAGED:
+            case QUERY_STYLE_MULTIPLE_SAME:
+                NR::Maybe<NR::Rect> bbox = sp_desktop_selection(desktop)->bounds();
+                if (bbox) {
+                    double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y);
+                    _fe_cb.set_blur_sensitive(true);
+                    //update blur widget value
+                    float radius = query->filter_gaussianBlur_deviation.value;
+                    float percent = radius * 400 / perimeter; // so that for a square, 100% == half side
+                    _fe_cb.set_blur_value(percent);
+                }
+                break;
+        }
+    }
+
+    sp_style_unref(query);
+
+    _blocked = false;
+}
+
+}
+}
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h
new file mode 100644 (file)
index 0000000..fa00768
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef SEEN_UI_WIDGET_OBJECT_COMPOSITE_SETTINGS_H
+#define SEEN_UI_WIDGET_OBJECT_COMPOSITE_SETTINGS_H
+
+/*
+ * A widget for controlling object compositing (filter, opacity, etc.)
+ *
+ * Authors:
+ *   Bryce W. Harrington <bryce@bryceharrington.org>
+ *   Gustav Broberg <broberg@kth.se>
+ *
+ * Copyright (C) 2004--2007 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/box.h>
+#include <gtkmm/alignment.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/label.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/scale.h>
+
+#include "ui/widget/filter-effect-chooser.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+class ObjectCompositeSettings : public Gtk::VBox {
+public:
+    ObjectCompositeSettings();
+    ~ObjectCompositeSettings();
+
+private:
+    Gtk::VBox       _opacity_vbox;
+    Gtk::HBox       _opacity_label_box;
+    Gtk::HBox       _opacity_hbox;
+    Gtk::Label      _opacity_label;
+    Gtk::Adjustment _opacity_adjustment;
+    Gtk::HScale     _opacity_hscale;
+    Gtk::SpinButton _opacity_spin_button;
+
+    SimpleFilterModifier _fe_cb;
+    Gtk::VBox       _fe_vbox;
+    Gtk::Alignment  _fe_alignment;
+
+    void selectionChanged(Inkscape::Application *inkscape,
+                          Inkscape::Selection *selection);
+
+    static void on_selection_changed(Inkscape::Application *inkscape,
+                                     Inkscape::Selection *selection,
+                                     ObjectCompositeSettings *w);
+
+    static void on_selection_modified(Inkscape::Application *inkscape,
+                                      Inkscape::Selection *selection,
+                                      guint flags,
+                                      ObjectCompositeSettings *w);
+
+    void _blendBlurValueChanged();
+    void _opacityValueChanged();
+
+    bool _blocked;
+
+    gulong _sel_changed;
+    gulong _subsel_changed;
+    gulong _sel_modified;
+    gulong _desktop_activated;
+};
+
+}
+}
+}
+
+#endif
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :