summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2007-08-07 06:53:24 +0000
committernicholasbishop <nicholasbishop@users.sourceforge.net>2007-08-07 06:53:24 +0000
commit8c55e0bd53e0804d7e1918215da5c2c93383a688 (patch)
tree5daf499728d419d6ec7f3fcf0fba0ca89f74f7c4 /src
parentenable Path_for_item to work on flowtext (diff)
downloadinkscape-8c55e0bd53e0804d7e1918215da5c2c93383a688.tar.gz
inkscape-8c55e0bd53e0804d7e1918215da5c2c93383a688.zip
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. (bzr r3407)
Diffstat (limited to 'src')
-rw-r--r--src/helper-fns.h8
-rw-r--r--src/sp-fecolormatrix.cpp1
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp47
-rw-r--r--src/ui/dialog/filter-effects-dialog.h4
4 files changed, 32 insertions, 28 deletions
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 <sstream>
+
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<gdouble> helperfns_read_vector(const gchar* value, int size){
std::vector<gdouble> v(size, (gdouble) 0);
- int i;
- gchar** values = g_strsplit(value , " ", size);
- for (i=0;i<size && values[i];i++)
- v[i] = g_ascii_strtod(values[i], NULL);
+ std::istringstream is(value);
+ for(int i = 0; i < size && (is >> 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<gdouble>* 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<Gtk::CellRendererText*>(_tree.get_column(i)->get_first_cell_renderer())->signal_edited().connect(
- sigc::mem_fun(*this, &MatrixAttr::rebind));
+ dynamic_cast<Gtk::CellRendererText*>(
+ _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<FilterColorMatrixType>* 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<Gtk::SizeGroup> _sizegroup;
+ // Color Matrix
+ ColorMatrixValues* _color_matrix_values;
+
// Convolve Matrix
MatrixAttr* _convolve_matrix;
DualSpinButton* _convolve_order;