X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fui%2Fwidget%2Fobject-composite-settings.cpp;h=1de425da376b97856680a119645773f65f6017ea;hb=9dc68827cbd515262ecb8d5ae8547d9e82c72e00;hp=aeb6a263a00fdf73f9edf47baaf6d694ff7c3b89;hpb=17eb9e57e1550f744916bf486947162aa523bdda;p=inkscape.git diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index aeb6a263a..1de425da3 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -4,8 +4,10 @@ * Authors: * Bryce W. Harrington * Gustav Broberg + * Niko Kiirala + * Abhishek Sharma * - * Copyright (C) 2004--2007 Authors + * Copyright (C) 2004--2008 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -17,13 +19,14 @@ #include "document.h" #include "filter-chemistry.h" #include "inkscape.h" -#include "inkscape-stock.h" #include "selection.h" #include "style.h" +#include "sp-item.h" #include "svg/css-ostringstream.h" #include "verbs.h" #include "xml/repr.h" #include "widgets/icon.h" +#include "ui/icon-names.h" #include "ui/widget/object-composite-settings.h" #include "display/sp-canvas.h" @@ -31,23 +34,37 @@ namespace Inkscape { namespace UI { namespace Widget { -void ObjectCompositeSettings::_on_desktop_switch( - Inkscape::Application *application, - SPDesktop *desktop, - ObjectCompositeSettings *w +void ObjectCompositeSettings::_on_desktop_activate( + Inkscape::Application */*application*/, + SPDesktop *desktop, + ObjectCompositeSettings *w ) { if (w->_subject) { w->_subject->setDesktop(desktop); } } -ObjectCompositeSettings::ObjectCompositeSettings() -: _opacity_vbox(false, 0), +void ObjectCompositeSettings::_on_desktop_deactivate( + Inkscape::Application */*application*/, + SPDesktop */*desktop*/, + ObjectCompositeSettings *w +) { + if (w->_subject) { + w->_subject->setDesktop(NULL); + } +} + +ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char const *history_prefix, int flags) +: _verb_code(verb_code), + _blur_tag(Glib::ustring(history_prefix) + ":blur"), + _opacity_tag(Glib::ustring(history_prefix) + ":opacity"), + _opacity_vbox(false, 0), _opacity_label_box(false, 0), - _opacity_label(_("Opacity, %"), 0.0, 1.0, true), + _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), + _fe_cb(flags), _fe_vbox(false, 0), _fe_alignment(1, 1, 1, 1), _blocked(false) @@ -67,11 +84,13 @@ ObjectCompositeSettings::ObjectCompositeSettings() _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_hscale.set_update_policy(Gtk::UPDATE_DELAYED); _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged)); show_all_children(); - _desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_switch), this ); + _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() { @@ -99,59 +118,62 @@ ObjectCompositeSettings::_blendBlurValueChanged() if (!desktop) { return; } + SPDocument *document = sp_desktop_document (desktop); if (_blocked) return; _blocked = true; // 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); - - NR::Maybe bbox = _subject->getBounds(); - if (!bbox) { - return; + //sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0); + + Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX); + 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; + } else { + radius = 0; } - 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) { - 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); - - 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 )); + + //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); + + 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); + } else { + sp_style_set_property_url(item, "filter", NULL, false); } + + if (radius == 0 && item->style->filter.set + && filter_is_single_gaussian_blur(SP_FILTER(item->style->getFilter()))) { + remove_filter(item, false); + } + else if (radius != 0) { + 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), "fillstroke:blur", SP_VERB_DIALOG_FILL_STROKE, _("Change blur")); + DocumentUndo::maybeDone(document, _blur_tag.c_str(), _verb_code, + _("Change blur")); // resume interruptibility - sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop)); + //sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop)); _blocked = false; } @@ -175,7 +197,7 @@ ObjectCompositeSettings::_opacityValueChanged() // 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); + //sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0); SPCSSAttr *css = sp_repr_css_attr_new (); @@ -187,11 +209,11 @@ ObjectCompositeSettings::_opacityValueChanged() sp_repr_css_attr_unref (css); - sp_document_maybe_done (sp_desktop_document (desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, + DocumentUndo::maybeDone(sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, _("Change opacity")); // resume interruptibility - sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop)); + //sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop)); _blocked = false; } @@ -253,9 +275,9 @@ ObjectCompositeSettings::_subjectChanged() { case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_AVERAGED: case QUERY_STYLE_MULTIPLE_SAME: - NR::Maybe bbox = _subject->getBounds(); + Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX); if (bbox) { - double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y); + 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; @@ -284,4 +306,4 @@ ObjectCompositeSettings::_subjectChanged() { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :