From 441fc40cb3111c840cdad1ae986af72140d793ec Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 19 Dec 2017 13:35:32 +0100 Subject: Enable SimpleFilterModifier to handle blend and blur filter primitives at the same time. Add opacity to SimpleFilterModifier. Use SimpleFilterModifier in Layers, Objects, and Fill and Stroke dialogs. --- src/ui/dialog/fill-and-stroke.cpp | 4 +- src/ui/dialog/layers.cpp | 5 +- src/ui/dialog/objects.cpp | 106 ++++++++-------------------- src/ui/dialog/objects.h | 18 ++--- src/ui/widget/filter-effect-chooser.cpp | 51 +++++++++---- src/ui/widget/filter-effect-chooser.h | 36 ++++++---- src/ui/widget/object-composite-settings.cpp | 74 ++++++++----------- src/ui/widget/object-composite-settings.h | 8 +-- 8 files changed, 129 insertions(+), 173 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index b271c951b..513cee752 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -42,7 +42,9 @@ FillAndStroke::FillAndStroke() _page_fill(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))), _page_stroke_paint(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))), _page_stroke_style(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))), - _composite_settings(SP_VERB_DIALOG_FILL_STROKE, "fillstroke", UI::Widget::SimpleFilterModifier::BLUR), + _composite_settings(SP_VERB_DIALOG_FILL_STROKE, "fillstroke", + UI::Widget::SimpleFilterModifier::BLUR | + UI::Widget::SimpleFilterModifier::OPACITY ), deskTrack(), targetDesktop(0), fillWdgt(0), diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 6223bd627..5bbf4c952 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -799,7 +799,10 @@ LayersPanel::LayersPanel() : _model(0), _pending(0), _toggleEvent(0), - _compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", UI::Widget::SimpleFilterModifier::BLEND), + _compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", + UI::Widget::SimpleFilterModifier::BLEND | + UI::Widget::SimpleFilterModifier::OPACITY | + UI::Widget::SimpleFilterModifier::BLUR), desktopChangeConn() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index b50d68239..07fdb2bd7 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -4,8 +4,10 @@ * Authors: * Theodore Janeczko * Tweaked by Liam P White for use in Inkscape + * Tavmjong Bah * * Copyright (C) Theodore Janeczko 2012 + * Tavmjong Bah 2017 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -509,27 +511,30 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { */ void ObjectsPanel::_setCompositingValues(SPItem *item) { - //Block the connections to avoid interference + // Block the connections to avoid interference _opacityConnection.block(); _blendConnection.block(); _blurConnection.block(); - //Set the opacity - _opacity_adjustment->set_value((item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1) * _opacity_adjustment->get_upper()); + // Set the opacity + double opacity = (item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1); + opacity *= 100; // Display in percent. + _filter_modifier.set_opacity_value(opacity); + SPFeBlend *spblend = NULL; SPGaussianBlur *spblur = NULL; - if (item->style->getFilter()) - { + if (item->style->getFilter()) { + for (auto& primitive_obj: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { break; } - if(SP_IS_FEBLEND(&primitive_obj) && !spblend) { + if (SP_IS_FEBLEND(&primitive_obj) && !spblend) { //Get the blend mode spblend = SP_FEBLEND(&primitive_obj); } - if(SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) { + if (SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) { //Get the blur value spblur = SP_GAUSSIANBLUR(&primitive_obj); } @@ -537,15 +542,15 @@ void ObjectsPanel::_setCompositingValues(SPItem *item) } //Set the blend mode - _fe_cb.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL); - + _filter_modifier.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL); + //Set the blur value Geom::OptRect bbox = item->bounds(SPItem::GEOMETRIC_BBOX); if (bbox && spblur) { double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct? - _fe_blur.set_blur_value(spblur->stdDeviation.getNumber() * 400 / perimeter); + _filter_modifier.set_blur_value(spblur->stdDeviation.getNumber() * 400 / perimeter); } else { - _fe_blur.set_blur_value(0); + _filter_modifier.set_blur_value(0); } //Unblock connections @@ -1494,7 +1499,7 @@ void ObjectsPanel::_opacityChangedIter(const Gtk::TreeIter& iter) if (item) { item->style->opacity.set = TRUE; - item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_opacity_adjustment->get_value() / _opacity_adjustment->get_upper()); + item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_filter_modifier.get_opacity_value() / 100); item->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); } } @@ -1505,7 +1510,7 @@ void ObjectsPanel::_opacityChangedIter(const Gtk::TreeIter& iter) void ObjectsPanel::_blendValueChanged() { _blockCompositeUpdate = true; - const Glib::ustring blendmode = _fe_cb.get_blend_mode(); + const Glib::ustring blendmode = _filter_modifier.get_blend_mode(); _tree.get_selection()->selected_foreach_iter(sigc::bind(sigc::mem_fun(*this, &ObjectsPanel::_blendChangedIter), blendmode)); DocumentUndo::done(_document, SP_VERB_DIALOG_OBJECTS, _("Set object blend mode")); @@ -1534,11 +1539,12 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { break; } + // We should read in the current radius and use that! if (SP_IS_GAUSSIANBLUR(&primitive)) { Geom::OptRect bbox = item->bounds(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? - radius = _fe_blur.get_blur_value() * perimeter / 400; + radius = _filter_modifier.get_blur_value() * perimeter / 400; } } } @@ -1576,7 +1582,7 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl void ObjectsPanel::_blurValueChanged() { _blockCompositeUpdate = true; - _tree.get_selection()->selected_foreach_iter(sigc::bind(sigc::mem_fun(*this, &ObjectsPanel::_blurChangedIter), _fe_blur.get_blur_value())); + _tree.get_selection()->selected_foreach_iter(sigc::bind(sigc::mem_fun(*this, &ObjectsPanel::_blurChangedIter), _filter_modifier.get_blur_value())); DocumentUndo::maybeDone(_document, "blur", SP_VERB_DIALOG_OBJECTS, _("Set object blur")); _blockCompositeUpdate = false; } @@ -1649,17 +1655,9 @@ ObjectsPanel::ObjectsPanel() : _clipmaskHeader(C_("Clip and mask", "CM")), _highlightHeader(C_("Highlight", "HL")), _nameHeader(_("Label")), - _composite_vbox(Gtk::ORIENTATION_VERTICAL), - _opacity_vbox(Gtk::ORIENTATION_VERTICAL), - _opacity_label(_("Opacity:")), - _opacity_label_unit(_("%")), - _opacity_adjustment(Gtk::Adjustment::create(100.0, 0.0, 100.0, 1.0, 1.0, 0.0)), - _opacity_hscale(_opacity_adjustment), - _opacity_spin_button(_opacity_adjustment, 0.01, 1), - _fe_cb(UI::Widget::SimpleFilterModifier::BLEND), - _fe_vbox(Gtk::ORIENTATION_VERTICAL), - _fe_blur(UI::Widget::SimpleFilterModifier::BLUR), - _blur_vbox(Gtk::ORIENTATION_VERTICAL), + _filter_modifier( UI::Widget::SimpleFilterModifier::BLEND | + UI::Widget::SimpleFilterModifier::BLUR | + UI::Widget::SimpleFilterModifier::OPACITY ), _colorSelectorDialog("dialogs.colorpickerwindow") { //Create the tree model and store @@ -1794,58 +1792,12 @@ ObjectsPanel::ObjectsPanel() : _page.pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET ); //Set up the compositing items - //Blend mode filter effect - _composite_vbox.pack_start(_fe_vbox, false, false, 2); - - _fe_cb.set_halign(Gtk::ALIGN_FILL); - _fe_cb.set_valign(Gtk::ALIGN_END); - -#if WITH_GTKMM_3_12 - _fe_cb.set_margin_start(4); -#else - _fe_cb.set_margin_left(4); -#endif - - _fe_vbox.pack_start(_fe_cb, false, false, 0); - _blendConnection = _fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_blendValueChanged)); - - //Blur filter effect - _composite_vbox.pack_start(_blur_vbox, false, false, 2); - - _fe_blur.set_hexpand(); - _fe_blur.set_halign(Gtk::ALIGN_FILL); - _fe_blur.set_valign(Gtk::ALIGN_END); - -#if WITH_GTKMM_3_12 - _fe_blur.set_margin_start(4); -#else - _fe_blur.set_margin_left(4); -#endif - - _blur_vbox.pack_start(_fe_blur, false, false, 0); - _blurConnection = _fe_blur.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_blurValueChanged)); - - //Opacity - _composite_vbox.pack_start(_opacity_vbox, false, false, 2); - _opacity_label.set_halign(Gtk::ALIGN_END); - _opacity_label.set_valign(Gtk::ALIGN_CENTER); - _opacity_hbox.pack_start(_opacity_label, false, false, 3); - _opacity_vbox.pack_start(_opacity_hbox, false, false, 0); - _opacity_hbox.pack_start(_opacity_hscale, true, true, 0); - _opacity_hbox.pack_start(_opacity_spin_button, false, false, 0); - _opacity_hbox.pack_start(_opacity_label_unit, false, false, 3); - _opacity_hscale.set_draw_value(false); - _opacityConnection = _opacity_adjustment->signal_value_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged)); - _opacity_label.set_mnemonic_widget(_opacity_hscale); - - //Keep the labels aligned - GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - gtk_size_group_add_widget(labels, GTK_WIDGET(_opacity_label.gobj())); - gtk_size_group_add_widget(labels, GTK_WIDGET(_fe_cb.get_blur_label()->gobj())); - gtk_size_group_add_widget(labels, GTK_WIDGET(_fe_blur.get_blur_label()->gobj())); + _blendConnection = _filter_modifier.signal_blend_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_blendValueChanged)); + _blurConnection = _filter_modifier.signal_blur_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_blurValueChanged)); + _opacityConnection = _filter_modifier.signal_opacity_changed().connect( sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged)); //Pack the compositing functions and the button row - _page.pack_end(_composite_vbox, Gtk::PACK_SHRINK); + _page.pack_end(_filter_modifier, Gtk::PACK_SHRINK); _page.pack_end(_buttonsRow, Gtk::PACK_SHRINK); //Pack into the panel contents @@ -1914,7 +1866,7 @@ ObjectsPanel::ObjectsPanel() : _buttonsRow.pack_start(_buttonsSecondary, Gtk::PACK_EXPAND_WIDGET); _buttonsRow.pack_end(_buttonsPrimary, Gtk::PACK_EXPAND_WIDGET); - _watching.push_back(&_composite_vbox); + _watching.push_back(&_filter_modifier); //Set up the pop-up menu // ------------------------------------------------------- diff --git a/src/ui/dialog/objects.h b/src/ui/dialog/objects.h index 73a0f0643..439e3af2a 100644 --- a/src/ui/dialog/objects.h +++ b/src/ui/dialog/objects.h @@ -3,8 +3,10 @@ * * Authors: * Theodore Janeczko + * Tavmjong Bah * * Copyright (C) Theodore Janeczko 2012 + * Tavmjong Bah 2017 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -151,20 +153,8 @@ private: Gtk::Label _highlightHeader; Gtk::Label _nameHeader; - /* Composite Settings */ - Gtk::Box _composite_vbox; - Gtk::Box _opacity_vbox; - Gtk::Box _opacity_hbox; - Gtk::Label _opacity_label; - Gtk::Label _opacity_label_unit; - Glib::RefPtr _opacity_adjustment; - Gtk::Scale _opacity_hscale; - Inkscape::UI::Widget::SpinButton _opacity_spin_button; - - Inkscape::UI::Widget::SimpleFilterModifier _fe_cb; - Gtk::Box _fe_vbox; - Inkscape::UI::Widget::SimpleFilterModifier _fe_blur; - Gtk::Box _blur_vbox; + /* Composite Settings (blend, blur, opacity). */ + Inkscape::UI::Widget::SimpleFilterModifier _filter_modifier; Gtk::Dialog _colorSelectorDialog; std::unique_ptr _selectedColor; diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index 30506851c..c19aa037a 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -3,8 +3,9 @@ * * Author: * Nicholas Bishop + * Tavmjong Bah * - * Copyright (C) 2007 Authors + * Copyright (C) 2007, 2017 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -18,11 +19,11 @@ namespace UI { namespace Widget { SimpleFilterModifier::SimpleFilterModifier(int flags) - : _lb_blend(_("Blend mode:")), - _lb_blur(_("_Blur:")), - _lb_blur_unit(_("%")), - _blend(BlendModeConverter, SP_ATTR_INVALID, false), - _blur(_("Blur (%)"), 0, 0, 100, 1, 1, 1) + : _flags( flags ) + , _lb_blend(_("Blend mode:")) + , _blend(BlendModeConverter, SP_ATTR_INVALID, false) + , _blur( _("Blur (%)" ), 0, 0, 100, 1, 1, 1) + , _opacity(_("Opacity (%)"), 0, 0, 100, 1, 1, 1) { set_name("SimpleFilterModifier"); @@ -30,25 +31,40 @@ SimpleFilterModifier::SimpleFilterModifier(int flags) if (flags & BLEND) { add(_hb_blend); + _lb_blend.set_use_underline(); + _lb_blend.set_mnemonic_widget(_blend); _hb_blend.pack_start(_lb_blend, false, false, 0); _hb_blend.pack_start(_blend); } + if (flags & BLUR) { add(_blur); } + if (flags & OPACITY) { + add(_opacity); + } + show_all_children(); - _hb_blend.set_spacing(12); - _lb_blend.set_use_underline(); - _lb_blend.set_mnemonic_widget(_blend); - _blend.signal_changed().connect(signal_blend_blur_changed()); - _blur.signal_value_changed().connect(signal_blend_blur_changed()); + _blend.signal_changed().connect(signal_blend_changed()); + _blur.signal_value_changed().connect(signal_blur_changed()); + _opacity.signal_value_changed().connect(signal_opacity_changed()); +} + +sigc::signal& SimpleFilterModifier::signal_blend_changed() +{ + return _signal_blend_changed; +} + +sigc::signal& SimpleFilterModifier::signal_blur_changed() +{ + return _signal_blur_changed; } -sigc::signal& SimpleFilterModifier::signal_blend_blur_changed() +sigc::signal& SimpleFilterModifier::signal_opacity_changed() { - return _signal_blend_blur_changed; + return _signal_opacity_changed; } const Glib::ustring SimpleFilterModifier::get_blend_mode() @@ -75,9 +91,14 @@ void SimpleFilterModifier::set_blur_value(const double val) _blur.set_value(val); } -void SimpleFilterModifier::set_blur_sensitive(const bool s) +double SimpleFilterModifier::get_opacity_value() const +{ + return _opacity.get_value(); +} + +void SimpleFilterModifier::set_opacity_value(const double val) { - _blur.set_sensitive(s); + _opacity.set_value(val); } } diff --git a/src/ui/widget/filter-effect-chooser.h b/src/ui/widget/filter-effect-chooser.h index 0bcf97433..148f44d04 100644 --- a/src/ui/widget/filter-effect-chooser.h +++ b/src/ui/widget/filter-effect-chooser.h @@ -6,8 +6,9 @@ * * Author: * Nicholas Bishop + * Tavmjong Bah * - * Copyright (C) 2007 Authors + * Copyright (C) 2007, 2017 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -23,40 +24,47 @@ namespace Inkscape { namespace UI { namespace Widget { -/* Allows basic control over feBlend and feGaussianBlur effects, - with an option to use the full filter effect controls. */ +/* Allows basic control over feBlend and feGaussianBlur effects as well as opacity. + * Common for Object, Layers, and Fill and Stroke dialogs. +*/ class SimpleFilterModifier : public Gtk::VBox { public: enum Flags { - NONE=0, - BLUR=1, - BLEND=2 + NONE = 0, + BLUR = 1, + OPACITY= 2, + BLEND = 4 }; SimpleFilterModifier(int flags); - sigc::signal& signal_blend_blur_changed(); + sigc::signal& signal_blend_changed(); + sigc::signal& signal_blur_changed(); + sigc::signal& signal_opacity_changed(); const Glib::ustring get_blend_mode(); // Uses blend mode enum values, or -1 for a complex filter void set_blend_mode(const int); double get_blur_value() const; - void set_blur_value(const double); - void set_blur_sensitive(const bool); - Gtk::Label *get_blur_label() { return &_lb_blur; }; + void set_blur_value(const double); + + double get_opacity_value() const; + void set_opacity_value(const double); private: int _flags; - Gtk::HBox _hb_blend; - Gtk::HBox _hb_blur; - Gtk::Label _lb_blend, _lb_blur, _lb_blur_unit; + Gtk::HBox _hb_blend; + Gtk::Label _lb_blend; ComboBoxEnum _blend; SpinScale _blur; + SpinScale _opacity; - sigc::signal _signal_blend_blur_changed; + sigc::signal _signal_blend_changed; + sigc::signal _signal_blur_changed; + sigc::signal _signal_opacity_changed; }; } diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index ae01c049b..161f5ba4f 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -33,42 +33,24 @@ namespace Widget { ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char const *history_prefix, int flags) : _verb_code(verb_code), + _blend_tag(Glib::ustring(history_prefix) + ":blend"), _blur_tag(Glib::ustring(history_prefix) + ":blur"), _opacity_tag(Glib::ustring(history_prefix) + ":opacity"), - _opacity_vbox(false, 0), - _opacity_scale(_("Opacity (%)"), 100.0, 0.0, 100.0, 1.0, 1.0, 1), - _fe_cb(flags), - _fe_vbox(false, 0), + _filter_modifier(flags), _blocked(false) { - set_name( "CompositeSettings"); + set_name( "ObjectCompositeSettings"); // Filter Effects - pack_start(_fe_vbox, false, false, 2); - _fe_vbox.pack_start(_fe_cb, false, false, 0); - _fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_blendBlurValueChanged)); + pack_start(_filter_modifier, false, false, 2); - // Opacity - pack_start(_opacity_vbox, false, false, 2); - _opacity_vbox.pack_start(_opacity_scale); - - _opacity_scale.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged)); + _filter_modifier.signal_blend_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_blendBlurValueChanged)); + _filter_modifier.signal_blur_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_blendBlurValueChanged)); + _filter_modifier.signal_opacity_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged)); SPDesktop *desktop = SP_ACTIVE_DESKTOP; - _opacity_scale.set_focuswidget(GTK_WIDGET(desktop->canvas)); - - /* SizeGroup keeps the blur and opacity labels aligned in Fill & Stroke dlg */ -/* - GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - gtk_size_group_add_widget(labels, GTK_WIDGET(_opacity_label.gobj())); - gtk_size_group_add_widget(labels, GTK_WIDGET(_fe_cb.get_blur_label()->gobj())); -*/ show_all_children(); - - // These signals don't properly detect change in desktop, rely on owner dialog to call setSubject() from setTargetDesktop() - //_desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_activate), this ); - //_desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "deactivate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_deactivate), this ); } ObjectCompositeSettings::~ObjectCompositeSettings() { @@ -84,6 +66,12 @@ void ObjectCompositeSettings::setSubject(StyleSubject *subject) { } } +// We get away with sharing one callback for blend and blur as this is used by +// * the Layers dialog where only one layer can be selected at a time, +// * the Fill and Stroke dialog where only blur is used. +// If both blend and blur are used in a dialog where more than one object can +// be selected then this should be split into separate functions for blend and +// blur (like in the Objects dialog). void ObjectCompositeSettings::_blendBlurValueChanged() { @@ -108,12 +96,12 @@ ObjectCompositeSettings::_blendBlurValueChanged() double radius; if (bbox) { double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct? - radius = _fe_cb.get_blur_value() * perimeter / 400; + radius = _filter_modifier.get_blur_value() * perimeter / 400; } else { radius = 0; } - const Glib::ustring blendmode = _fe_cb.get_blend_mode(); + const Glib::ustring blendmode = _filter_modifier.get_blend_mode(); //apply created filter to every selected item std::vector sel = _subject->list(); @@ -148,7 +136,7 @@ ObjectCompositeSettings::_blendBlurValueChanged() } DocumentUndo::maybeDone(document, _blur_tag.c_str(), _verb_code, - _("Change blur")); + _("Change blur/blend filter")); // resume interruptibility //sp_canvas_end_forced_full_redraws(desktop->getCanvas()); @@ -172,15 +160,10 @@ ObjectCompositeSettings::_opacityValueChanged() return; _blocked = true; - // 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(desktop->getCanvas(), 0); - SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream os; - os << CLAMP (_opacity_scale.get_adjustment()->get_value() / 100, 0.0, 1.0); + os << CLAMP (_filter_modifier.get_opacity_value() / 100, 0.0, 1.0); sp_repr_css_set_property (css, "opacity", os.str().c_str()); _subject->setCSS(css); @@ -216,14 +199,11 @@ ObjectCompositeSettings::_subjectChanged() { switch (result) { case QUERY_STYLE_NOTHING: - _opacity_vbox.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_vbox.set_sensitive(true); - _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query.opacity.value)); + _filter_modifier.set_opacity_value(100 * SP_SCALE24_TO_FLOAT(query.opacity.value)); break; } @@ -231,16 +211,13 @@ ObjectCompositeSettings::_subjectChanged() { const int blend_result = _subject->queryStyle(&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); + _filter_modifier.set_blend_mode(query.filter_blend_mode.value); break; case QUERY_STYLE_MULTIPLE_DIFFERENT: // TODO: set text - _fe_cb.set_sensitive(false); break; } @@ -248,7 +225,7 @@ ObjectCompositeSettings::_subjectChanged() { int blur_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLUR); switch (blur_result) { case QUERY_STYLE_NOTHING: //no blurring - _fe_cb.set_blur_sensitive(false); + _filter_modifier.set_blur_value(0); break; case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_AVERAGED: @@ -256,16 +233,23 @@ ObjectCompositeSettings::_subjectChanged() { 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? - _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); + _filter_modifier.set_blur_value(percent); } break; } } + // If we have nothing selected, disable dialog. + if (result == QUERY_STYLE_NOTHING && + blend_result == QUERY_STYLE_NOTHING ) { + _filter_modifier.set_sensitive( false ); + } else { + _filter_modifier.set_sensitive( true ); + } + _blocked = false; } diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index eff1ba800..9e810bc00 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -18,7 +18,6 @@ #include #include "ui/widget/filter-effect-chooser.h" -#include "ui/widget/spinbutton.h" class SPDesktop; struct InkscapeApplication; @@ -42,16 +41,13 @@ public: private: unsigned int _verb_code; + Glib::ustring _blend_tag; Glib::ustring _blur_tag; Glib::ustring _opacity_tag; - Gtk::VBox _opacity_vbox; - SpinScale _opacity_scale; - StyleSubject *_subject; - SimpleFilterModifier _fe_cb; - Gtk::VBox _fe_vbox; + SimpleFilterModifier _filter_modifier; bool _blocked; gulong _desktop_activated; -- cgit v1.2.3