summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e6c36b3)
raw | patch | inline | side by side (parent: e6c36b3)
author | nicholasbishop <nicholasbishop@users.sourceforge.net> | |
Sun, 5 Aug 2007 23:56:17 +0000 (23:56 +0000) | ||
committer | nicholasbishop <nicholasbishop@users.sourceforge.net> | |
Sun, 5 Aug 2007 23:56:17 +0000 (23:56 +0000) |
* Added control for the values attribute of feColorMatrix; shows a matrix or a slider depending on the value of the type attribute.
* Added a frame shadow around the matrix used by feColorMatrix and feConvolveMatrix.
* Added a frame shadow around the matrix used by feColorMatrix and feConvolveMatrix.
src/ui/dialog/filter-effects-dialog.cpp | patch | blob | history | |
src/ui/dialog/filter-effects-dialog.h | patch | blob | history |
index f842e97ad64be4c5f35bf3f150646b66e6a289e5..edbae518dc752bbefdd8730b45fed752d623445a 100644 (file)
#include "inkscape.h"
#include "selection.h"
#include "sp-feblend.h"
+#include "sp-fecolormatrix.h"
#include "sp-fecomposite.h"
+#include "sp-feconvolvematrix.h"
#include "sp-fedisplacementmap.h"
#include "sp-fedistantlight.h"
#include "sp-femerge.h"
}
};
-/* Displays/Edits the kernel matrix for feConvolveMatrix */
-class FilterEffectsDialog::ConvolveMatrix : public Gtk::TreeView, public AttrWidget
+/* Displays/Edits the matrix for feConvolveMatrix or feColorMatrix */
+class FilterEffectsDialog::MatrixAttr : public Gtk::Frame, public AttrWidget
{
public:
- ConvolveMatrix(const SPAttributeEnum a)
+ MatrixAttr(const SPAttributeEnum a)
: AttrWidget(a)
{
- signal_changed().connect(signal_attr_changed().make_slot());
-
_model = Gtk::ListStore::create(_columns);
- set_model(_model);
- set_headers_visible(false);
+ _tree.set_model(_model);
+ _tree.set_headers_visible(false);
+ _tree.show();
+ add(_tree);
+ set_shadow_type(Gtk::SHADOW_IN);
}
Glib::ustring get_as_attribute() const
for(Gtk::TreeIter iter = _model->children().begin();
iter != _model->children().end(); ++iter) {
- for(unsigned c = 0; c < get_columns().size(); ++c) {
+ for(unsigned c = 0; c < _tree.get_columns().size(); ++c) {
os << (*iter)[_columns.cols[c]] << " ";
}
}
void set_from_attribute(SPObject* o)
{
- update(SP_FECONVOLVEMATRIX(o));
- }
-
- sigc::signal<void>& signal_changed()
- {
- return _signal_changed;
- }
-
- void update(SPFeConvolveMatrix* conv)
- {
- if(conv) {
- int cols, rows;
-
- cols = (int)conv->order.getNumber();
- if(cols > 5)
- cols = 5;
- rows = conv->order.optNumber_set ? (int)conv->order.getOptNumber() : cols;
-
- update(conv, cols, rows);
+ if(o) {
+ if(SP_IS_FECONVOLVEMATRIX(o)) {
+ SPFeConvolveMatrix* conv = SP_FECONVOLVEMATRIX(o);
+ int cols, rows;
+ cols = (int)conv->order.getNumber();
+ if(cols > 5)
+ cols = 5;
+ rows = conv->order.optNumber_set ? (int)conv->order.getOptNumber() : cols;
+ update(o, rows, cols);
+ }
+ else if(SP_IS_FECOLORMATRIX(o))
+ update(o, 4, 5);
}
}
private:
- class ConvolveMatrixColumns : public Gtk::TreeModel::ColumnRecord
+ class MatrixColumns : public Gtk::TreeModel::ColumnRecord
{
public:
- ConvolveMatrixColumns()
+ MatrixColumns()
{
cols.resize(5);
for(unsigned i = 0; i < cols.size(); ++i)
std::vector<Gtk::TreeModelColumn<double> > cols;
};
- void update(SPFeConvolveMatrix* conv, const int rows, const int cols)
+ void update(SPObject* o, const int rows, const int cols)
{
_model->clear();
- remove_all_columns();
+ _tree.remove_all_columns();
+
+ SPFeColorMatrix* col = 0;
+ SPFeConvolveMatrix* conv = 0;
+ if(SP_IS_FECOLORMATRIX(o))
+ col = SP_FECOLORMATRIX(o);
+ else if(SP_IS_FECONVOLVEMATRIX(o))
+ conv = SP_FECONVOLVEMATRIX(o);
+ else
+ return;
- if(conv) {
+ if(o) {
int ndx = 0;
for(int i = 0; i < cols; ++i) {
- append_column_numeric_editable("", _columns.cols[i], "%.2f");
- dynamic_cast<Gtk::CellRendererText*>(get_column(i)->get_first_cell_renderer())->signal_edited().connect(
- sigc::mem_fun(*this, &ConvolveMatrix::rebind));
+ _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));
}
for(int r = 0; r < rows; ++r) {
Gtk::TreeRow row = *(_model->append());
- for(int c = 0; c < cols; ++c, ++ndx)
- row[_columns.cols[c]] = ndx < (int)conv->kernelMatrix.size() ? conv->kernelMatrix[ndx] : 0;
+ 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;
+ }
}
}
}
void rebind(const Glib::ustring&, const Glib::ustring&)
{
- _signal_changed();
+ signal_attr_changed()();
}
+ Gtk::TreeView _tree;
Glib::RefPtr<Gtk::ListStore> _model;
- ConvolveMatrixColumns _columns;
- sigc::signal<void> _signal_changed;
+ MatrixColumns _columns;
+};
+
+// Displays a matrix or a slider for feColorMatrix
+class FilterEffectsDialog::ColorMatrixValues : public Gtk::Frame, public AttrWidget
+{
+public:
+ ColorMatrixValues()
+ : AttrWidget(SP_ATTR_VALUES),
+ _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)
+ {
+ _matrix.show();
+ _saturation.show();
+ _angle.show();
+
+ _label.set_sensitive(false);
+ _label.show();
+
+ set_shadow_type(Gtk::SHADOW_NONE);
+ }
+
+ virtual void set_from_attribute(SPObject* o)
+ {
+ if(SP_IS_FECOLORMATRIX(o)) {
+ SPFeColorMatrix* col = SP_FECOLORMATRIX(o);
+ remove();
+ switch(col->type) {
+ case COLORMATRIX_SATURATE:
+ add(_saturation);
+ _saturation.set_from_attribute(o);
+ break;
+ case COLORMATRIX_HUEROTATE:
+ add(_angle);
+ _angle.set_from_attribute(o);
+ break;
+ case COLORMATRIX_LUMINANCETOALPHA:
+ add(_label);
+ break;
+ case COLORMATRIX_MATRIX:
+ default:
+ add(_matrix);
+ _matrix.set_from_attribute(o);
+ break;
+ }
+ }
+ }
+
+ virtual Glib::ustring get_as_attribute() const
+ {
+ const Widget* w = get_child();
+ if(w == &_label)
+ return "";
+ else
+ return dynamic_cast<const AttrWidget*>(w)->get_as_attribute();
+ }
+private:
+ MatrixAttr _matrix;
+ SpinSlider _saturation;
+ SpinSlider _angle;
+ Gtk::Label _label;
};
class FilterEffectsDialog::Settings
return col;
}
- // ConvolveMatrix
- ConvolveMatrix* add_matrix(const SPAttributeEnum attr, const Glib::ustring& label)
+ // Matrix
+ MatrixAttr* add_matrix(const SPAttributeEnum attr, const Glib::ustring& label)
{
- ConvolveMatrix* conv = new ConvolveMatrix(attr);
+ MatrixAttr* conv = new MatrixAttr(attr);
add_widget(conv, label);
add_attr_widget(conv);
return conv;
}
+ // ColorMatrixValues
+ ColorMatrixValues* add_colormatrixvalues(const Glib::ustring& label)
+ {
+ ColorMatrixValues* cmv = new ColorMatrixValues;
+ add_widget(cmv, label);
+ add_attr_widget(cmv);
+ return cmv;
+ }
+
// SpinSlider
SpinSlider* add_spinslider(const SPAttributeEnum attr, const Glib::ustring& label,
const double lo, const double hi, const double step_inc, const double climb, const int digits)
_settings->type(NR_FILTER_COLORMATRIX);
_settings->add_combo(SP_ATTR_TYPE, _("Type"), ColorMatrixTypeConverter);
+ _settings->add_colormatrixvalues(_("Value(s)"));
_settings->type(NR_FILTER_COMPOSITE);
_settings->add_combo(SP_ATTR_OPERATOR, _("Operator"), CompositeOperatorConverter);
void FilterEffectsDialog::convolve_order_changed()
{
- _convolve_matrix->update(SP_FECONVOLVEMATRIX(_primitive_list.get_selected()));
+ _convolve_matrix->set_from_attribute(SP_OBJECT(_primitive_list.get_selected()));
_convolve_target->get_spinbuttons()[0]->get_adjustment()->set_upper(_convolve_order->get_spinbutton1().get_value() - 1);
_convolve_target->get_spinbuttons()[1]->get_adjustment()->set_upper(_convolve_order->get_spinbutton2().get_value() - 1);
}
index 2dacd4860e7234ce9d163efc0c6f441480ac1804..9e272fbabf86097661cf50b96cb21becd1fb999e 100644 (file)
#include "attributes.h"
#include "dialog.h"
#include "sp-filter.h"
-#include "sp-feconvolvematrix.h"
#include "ui/widget/filter-effect-chooser.h"
#include "ui/widget/spin-slider.h"
Gtk::Label _empty_settings;
class Settings;
- class ConvolveMatrix;
+ class MatrixAttr;
+ class ColorMatrixValues;
class LightSourceControl;
Settings* _settings;
Glib::RefPtr<Gtk::SizeGroup> _sizegroup;
// Convolve Matrix
- ConvolveMatrix* _convolve_matrix;
+ MatrixAttr* _convolve_matrix;
DualSpinButton* _convolve_order;
MultiSpinButton* _convolve_target;