From: nicholasbishop Date: Fri, 17 Aug 2007 03:02:39 +0000 (+0000) Subject: Filter effects dialog: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9da625e1ff559d10b9830fcfc127d8b12404386f;p=inkscape.git Filter effects dialog: * Added stored values for each of the different value types in feColorMatrix. Switching the type in the filter dialog now shows a separate value for each. --- diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 6cc5d0fa8..60e2c8c8c 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -325,6 +325,31 @@ public: set_shadow_type(Gtk::SHADOW_IN); } + std::vector get_values() const + { + std::vector vec; + for(Gtk::TreeIter iter = _model->children().begin(); + iter != _model->children().end(); ++iter) { + for(unsigned c = 0; c < _tree.get_columns().size(); ++c) + vec.push_back((*iter)[_columns.cols[c]]); + } + return vec; + } + + void set_values(const std::vector& v) + { + unsigned i = 0; + for(Gtk::TreeIter iter = _model->children().begin(); + iter != _model->children().end(); ++iter) { + for(unsigned c = 0; c < _tree.get_columns().size(); ++c) { + if(i >= v.size()) + return; + (*iter)[_columns.cols[c]] = v[i]; + ++i; + } + } + } + Glib::ustring get_as_attribute() const { std::ostringstream os; @@ -425,11 +450,15 @@ public: _matrix(SP_ATTR_VALUES), _saturation(0, 0, 1, 0.1, 0.01, 2, SP_ATTR_VALUES), _angle(0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES), - _label(_("None"), Gtk::ALIGN_LEFT) + _label(_("None"), Gtk::ALIGN_LEFT), + _use_stored(false), + _saturation_store(0), + _angle_store(0) { _matrix.signal_attr_changed().connect(signal_attr_changed().make_slot()); _saturation.signal_attr_changed().connect(signal_attr_changed().make_slot()); _angle.signal_attr_changed().connect(signal_attr_changed().make_slot()); + signal_attr_changed().connect(sigc::mem_fun(*this, &ColorMatrixValues::update_store)); _matrix.show(); _saturation.show(); @@ -448,11 +477,17 @@ public: switch(col->type) { case COLORMATRIX_SATURATE: add(_saturation); - _saturation.set_from_attribute(o); + if(_use_stored) + _saturation.set_value(_saturation_store); + else + _saturation.set_from_attribute(o); break; case COLORMATRIX_HUEROTATE: add(_angle); - _angle.set_from_attribute(o); + if(_use_stored) + _angle.set_value(_angle_store); + else + _angle.set_from_attribute(o); break; case COLORMATRIX_LUMINANCETOALPHA: add(_label); @@ -460,9 +495,13 @@ public: case COLORMATRIX_MATRIX: default: add(_matrix); - _matrix.set_from_attribute(o); + if(_use_stored) + _matrix.set_values(_matrix_store); + else + _matrix.set_from_attribute(o); break; } + _use_stored = true; } } @@ -474,11 +513,33 @@ public: else return dynamic_cast(w)->get_as_attribute(); } + + void clear_store() + { + _use_stored = false; + } private: + void update_store() + { + const Widget* w = get_child(); + if(w == &_matrix) + _matrix_store = _matrix.get_values(); + else if(w == &_saturation) + _saturation_store = _saturation.get_value(); + else if(w == &_angle) + _angle_store = _angle.get_value(); + } + MatrixAttr _matrix; SpinSlider _saturation; SpinSlider _angle; Gtk::Label _label; + + // Store separate values for the different color modes + bool _use_stored; + std::vector _matrix_store; + double _saturation_store; + double _angle_store; }; class FilterEffectsDialog::Settings @@ -1192,6 +1253,7 @@ void FilterEffectsDialog::PrimitiveList::on_primitive_selection_changed() { _observer->set(get_selected()); signal_primitive_changed()(); + _dialog._color_matrix_values->clear_store(); } /* Add all filter primitives in the current to the list. @@ -1753,7 +1815,8 @@ FilterEffectsDialog::FilterEffectsDialog() _add_primitive_type(FPConverter), _add_primitive(Gtk::Stock::ADD), _empty_settings(_("No primitive selected"), Gtk::ALIGN_LEFT), - _locked(false) + _locked(false), + _attr_lock(false) { _settings = new Settings(*this, sigc::mem_fun(*this, &FilterEffectsDialog::set_attr_direct), NR_FILTER_ENDPRIMITIVETYPE); @@ -1947,6 +2010,8 @@ void FilterEffectsDialog::set_child_attr_direct(const AttrWidget* input) void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, const gchar* val) { if(!_locked) { + _attr_lock = true; + SPFilter *filter = _filter_modifier.get_selected_filter(); const gchar* name = (const gchar*)sp_attribute_name(attr); if(filter && name && o) { @@ -1960,11 +2025,16 @@ void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, cons sp_document_maybe_done(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, _("Set filter primitive attribute")); } + + _attr_lock = false; } } void FilterEffectsDialog::update_settings_view() { + if(_attr_lock) + return; + SPFilterPrimitive* prim = _primitive_list.get_selected(); if(prim) { diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index ace6e68bd..ac7b96fd6 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -262,6 +262,7 @@ private: // To prevent unwanted signals bool _locked; + bool _attr_lock; FilterEffectsDialog(FilterEffectsDialog const &d); FilterEffectsDialog& operator=(FilterEffectsDialog const &d);