From aa916bee1f1106fa94adb62552cb286b998f4f24 Mon Sep 17 00:00:00 2001 From: nicholasbishop Date: Fri, 17 Aug 2007 04:41:39 +0000 Subject: [PATCH] Filter effects dialog: * Added most of the settings for feComponentTransfer to the filter dialog (still haven't done the table attribute) --- src/filter-enums.cpp | 10 ++++++++++ src/filter-enums.h | 4 ++++ src/sp-fecomponenttransfer.cpp | 8 ++++++++ src/ui/dialog/filter-effects-dialog.cpp | 25 +++++++++++++++++++++++-- src/ui/dialog/filter-effects-dialog.h | 1 + 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/filter-enums.cpp b/src/filter-enums.cpp index 111cd62f9..0fce491dd 100644 --- a/src/filter-enums.cpp +++ b/src/filter-enums.cpp @@ -77,6 +77,16 @@ const EnumData CompositeOperatorData[COMPOSITE_ENDOPERATOR] }; const EnumDataConverter CompositeOperatorConverter(CompositeOperatorData, COMPOSITE_ENDOPERATOR); +// feComponentTransfer +const EnumData ComponentTransferTypeData[NR::COMPONENTTRANSFER_TYPE_ERROR] = { + {NR::COMPONENTTRANSFER_TYPE_IDENTITY, _("Identity"), "identity"}, + {NR::COMPONENTTRANSFER_TYPE_TABLE, _("Table"), "table"}, + {NR::COMPONENTTRANSFER_TYPE_DISCRETE, _("Discrete"), "discrete"}, + {NR::COMPONENTTRANSFER_TYPE_LINEAR, _("Linear"), "linear"}, + {NR::COMPONENTTRANSFER_TYPE_GAMMA, _("Gamma"), "gamma"}, +}; +const EnumDataConverter ComponentTransferTypeConverter(ComponentTransferTypeData, NR::COMPONENTTRANSFER_TYPE_ERROR); + // feConvolveMatrix const EnumData ConvolveMatrixEdgeModeData[NR::CONVOLVEMATRIX_EDGEMODE_ENDTYPE] = { {NR::CONVOLVEMATRIX_EDGEMODE_DUPLICATE, _("Duplicate"), "duplicate"}, diff --git a/src/filter-enums.h b/src/filter-enums.h index c1e3fcdcc..fe517ea5e 100644 --- a/src/filter-enums.h +++ b/src/filter-enums.h @@ -14,6 +14,7 @@ #include "display/nr-filter-blend.h" #include "display/nr-filter-colormatrix.h" +#include "display/nr-filter-component-transfer.h" #include "display/nr-filter-composite.h" #include "display/nr-filter-convolve-matrix.h" #include "display/nr-filter-morphology.h" @@ -44,6 +45,9 @@ extern const Inkscape::Util::EnumDataConverter BlendModeCon // ColorMatrix type extern const Inkscape::Util::EnumData ColorMatrixTypeData[NR::COLORMATRIX_ENDTYPE]; extern const Inkscape::Util::EnumDataConverter ColorMatrixTypeConverter; +// ComponentTransfer type +extern const Inkscape::Util::EnumData ComponentTransferTypeData[NR::COMPONENTTRANSFER_TYPE_ERROR]; +extern const Inkscape::Util::EnumDataConverter ComponentTransferTypeConverter; // Composite operator extern const Inkscape::Util::EnumData CompositeOperatorData[COMPOSITE_ENDOPERATOR]; extern const Inkscape::Util::EnumDataConverter CompositeOperatorConverter; diff --git a/src/sp-fecomponenttransfer.cpp b/src/sp-fecomponenttransfer.cpp index 2bf3e809a..1ff231a1f 100644 --- a/src/sp-fecomponenttransfer.cpp +++ b/src/sp-fecomponenttransfer.cpp @@ -147,7 +147,15 @@ sp_feComponentTransfer_set(SPObject *object, unsigned int key, gchar const *valu SPFeComponentTransfer *feComponentTransfer = SP_FECOMPONENTTRANSFER(object); (void)feComponentTransfer; + NR::FilterComponentTransferType type; switch(key) { + case SP_ATTR_TYPE: + type = sp_feComponenttransfer_read_type(value); + if(type != feComponentTransfer->type) { + feComponentTransfer->type = type; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } + break; /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: if (((SPObjectClass *) feComponentTransfer_parent_class)->set) diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 60e2c8c8c..0e3727ce8 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -37,6 +37,7 @@ #include "selection.h" #include "sp-feblend.h" #include "sp-fecolormatrix.h" +#include "sp-fecomponenttransfer.h" #include "sp-fecomposite.h" #include "sp-feconvolvematrix.h" #include "sp-fedisplacementmap.h" @@ -1887,6 +1888,14 @@ void FilterEffectsDialog::init_settings_widgets() _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_COMPONENTTRANSFER); + _settings->add_combo(SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter); + _ct_slope = _settings->add_spinslider(SP_ATTR_SLOPE, _("Slope"), -100, 100, 1, 0.01, 1); + _ct_intercept = _settings->add_spinslider(SP_ATTR_INTERCEPT, _("Intercept"), -100, 100, 1, 0.01, 1); + _ct_amplitude = _settings->add_spinslider(SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 100, 1, 0.01, 1); + _ct_exponent = _settings->add_spinslider(SP_ATTR_EXPONENT, _("Exponent"), 0, 100, 1, 0.01, 1); + _ct_offset = _settings->add_spinslider(SP_ATTR_OFFSET, _("Offset"), -100, 100, 1, 0.01, 1); + _settings->type(NR_FILTER_COMPOSITE); _settings->add_combo(SP_ATTR_OPERATOR, _("Operator"), CompositeOperatorConverter); _k1 = _settings->add_spinslider(SP_ATTR_K1, _("K1"), -10, 10, 1, 0.01, 1); @@ -2032,6 +2041,8 @@ void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, cons void FilterEffectsDialog::update_settings_view() { + update_settings_sensitivity(); + if(_attr_lock) return; @@ -2046,8 +2057,6 @@ void FilterEffectsDialog::update_settings_view() _settings_box.show(); _empty_settings.show(); } - - update_settings_sensitivity(); } void FilterEffectsDialog::update_settings_sensitivity() @@ -2058,6 +2067,18 @@ void FilterEffectsDialog::update_settings_sensitivity() _k2->set_sensitive(use_k); _k3->set_sensitive(use_k); _k4->set_sensitive(use_k); + + if(SP_IS_FECOMPONENTTRANSFER(prim)) { + SPFeComponentTransfer* ct = SP_FECOMPONENTTRANSFER(prim); + const bool linear = ct->type == COMPONENTTRANSFER_TYPE_LINEAR; + const bool gamma = ct->type == COMPONENTTRANSFER_TYPE_GAMMA; + //_ct_table->set_sensitive(ct->type == COMPONENTTRANSFER_TYPE_TABLE || ct->type == COMPONENTTRANSFER_TYPE_DISCRETE); + _ct_slope->set_sensitive(linear); + _ct_intercept->set_sensitive(linear); + _ct_amplitude->set_sensitive(gamma); + _ct_exponent->set_sensitive(gamma); + _ct_offset->set_sensitive(gamma); + } } void FilterEffectsDialog::update_color_matrix() diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index ac7b96fd6..1a4285dd9 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -259,6 +259,7 @@ private: // For controlling setting sensitivity Gtk::Widget* _k1, *_k2, *_k3, *_k4; + Gtk::Widget* _ct_table, *_ct_slope, *_ct_intercept, *_ct_amplitude, *_ct_exponent, *_ct_offset; // To prevent unwanted signals bool _locked; -- 2.30.2