From: nicholasbishop Date: Tue, 7 Aug 2007 06:53:24 +0000 (+0000) Subject: Filter effects: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=087b237ce230e9b7a16dc95537dbb62f7d715026;p=inkscape.git Filter effects: * Fixed a few bugs with the feColorMatrix settings, such as bad sensitivity settings and missing updates. * Changed matrix loading (for the values attribute of feColorMatrix) so that it can handle values separated by more than one space. --- diff --git a/src/helper-fns.h b/src/helper-fns.h index 29fd2ebec..4e51c9a16 100644 --- a/src/helper-fns.h +++ b/src/helper-fns.h @@ -13,6 +13,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + static double helperfns_read_number(gchar const *value) { if (!value) return 0; @@ -42,10 +44,8 @@ static bool helperfns_read_bool(gchar const *value, bool default_value){ static std::vector helperfns_read_vector(const gchar* value, int size){ std::vector v(size, (gdouble) 0); - int i; - gchar** values = g_strsplit(value , " ", size); - for (i=0;i> v[i]); i++); return v; } diff --git a/src/sp-fecolormatrix.cpp b/src/sp-fecolormatrix.cpp index 6ff107b9f..e158839ba 100644 --- a/src/sp-fecolormatrix.cpp +++ b/src/sp-fecolormatrix.cpp @@ -137,7 +137,6 @@ sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *str) (void)feColorMatrix; NR::FilterColorMatrixType read_type; - gdouble read_num; /*DEAL WITH SETTING ATTRIBUTES HERE*/ switch(key) { case SP_ATTR_TYPE: diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index edcb1e9ca..116d0ec89 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -330,12 +330,11 @@ private: _tree.remove_all_columns(); - SPFeColorMatrix* col = 0; - SPFeConvolveMatrix* conv = 0; + std::vector* values = NULL; if(SP_IS_FECOLORMATRIX(o)) - col = SP_FECOLORMATRIX(o); + values = &SP_FECOLORMATRIX(o)->values; else if(SP_IS_FECONVOLVEMATRIX(o)) - conv = SP_FECONVOLVEMATRIX(o); + values = &SP_FECONVOLVEMATRIX(o)->kernelMatrix; else return; @@ -344,18 +343,15 @@ private: for(int i = 0; i < cols; ++i) { _tree.append_column_numeric_editable("", _columns.cols[i], "%.2f"); - dynamic_cast(_tree.get_column(i)->get_first_cell_renderer())->signal_edited().connect( - sigc::mem_fun(*this, &MatrixAttr::rebind)); + dynamic_cast( + _tree.get_column(i)->get_first_cell_renderer())->signal_edited().connect( + sigc::mem_fun(*this, &MatrixAttr::rebind)); } for(int r = 0; r < rows; ++r) { Gtk::TreeRow row = *(_model->append()); - for(int c = 0; c < cols; ++c, ++ndx) { - if(col) - row[_columns.cols[c]] = ndx < (int)col->values.size() ? col->values[ndx] : 0; - else - row[_columns.cols[c]] = ndx < (int)conv->kernelMatrix.size() ? conv->kernelMatrix[ndx] : 0; - } + for(int c = 0; c < cols; ++c, ++ndx) + row[_columns.cols[c]] = ndx < (int)values->size() ? (*values)[ndx] : 0; } } } @@ -381,12 +377,15 @@ public: _angle(0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES), _label(_("None"), Gtk::ALIGN_LEFT) { + _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()); + _matrix.show(); _saturation.show(); _angle.show(); - - _label.set_sensitive(false); _label.show(); + _label.set_sensitive(false); set_shadow_type(Gtk::SHADOW_NONE); } @@ -1653,8 +1652,9 @@ void FilterEffectsDialog::init_settings_widgets() _settings->add_combo(SP_ATTR_MODE, _("Mode"), BlendModeConverter); _settings->type(NR_FILTER_COLORMATRIX); - _settings->add_combo(SP_ATTR_TYPE, _("Type"), ColorMatrixTypeConverter); - _settings->add_colormatrixvalues(_("Value(s)")); + ComboBoxEnum* colmat = _settings->add_combo(SP_ATTR_TYPE, _("Type"), ColorMatrixTypeConverter); + _color_matrix_values = _settings->add_colormatrixvalues(_("Value(s)")); + colmat->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::update_color_matrix)); _settings->type(NR_FILTER_COMPOSITE); _settings->add_combo(SP_ATTR_OPERATOR, _("Operator"), CompositeOperatorConverter); @@ -1794,14 +1794,10 @@ void FilterEffectsDialog::update_settings_view() _settings_box.hide_all(); _settings_box.show(); - _settings_box.set_sensitive(false); - _empty_settings.show(); - - if(prim) { + if(prim) _settings->show_and_update(FPConverter.get_id_from_key(prim->repr->name()), prim); - _settings_box.set_sensitive(true); - _empty_settings.hide(); - } + else + _empty_settings.show(); update_settings_sensitivity(); } @@ -1816,6 +1812,11 @@ void FilterEffectsDialog::update_settings_sensitivity() _k4->set_sensitive(use_k); } +void FilterEffectsDialog::update_color_matrix() +{ + _color_matrix_values->set_from_attribute(_primitive_list.get_selected()); +} + } // namespace Dialog } // namespace UI } // namespace Inkscape diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 9e272fbab..96fb481a0 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -179,6 +179,7 @@ private: void set_attr(SPObject*, const SPAttributeEnum, const gchar* val); void update_settings_view(); void update_settings_sensitivity(); + void update_color_matrix(); // Filter effect selection FilterModifier _filter_modifier; @@ -200,6 +201,9 @@ private: Settings* _settings; Glib::RefPtr _sizegroup; + // Color Matrix + ColorMatrixValues* _color_matrix_values; + // Convolve Matrix MatrixAttr* _convolve_matrix; DualSpinButton* _convolve_order;