Code

Filter effects dialog:
authornicholasbishop <nicholasbishop@users.sourceforge.net>
Fri, 17 Aug 2007 04:41:39 +0000 (04:41 +0000)
committernicholasbishop <nicholasbishop@users.sourceforge.net>
Fri, 17 Aug 2007 04:41:39 +0000 (04:41 +0000)
* Added most of the settings for feComponentTransfer to the filter dialog (still haven't done the table attribute)

src/filter-enums.cpp
src/filter-enums.h
src/sp-fecomponenttransfer.cpp
src/ui/dialog/filter-effects-dialog.cpp
src/ui/dialog/filter-effects-dialog.h

index 111cd62f9ea860a25563d5dfec920a781cfad5e9..0fce491dd28a1e579c7525d69f48aaf7b9a893d3 100644 (file)
@@ -77,6 +77,16 @@ const EnumData<FeCompositeOperator> CompositeOperatorData[COMPOSITE_ENDOPERATOR]
 };
 const EnumDataConverter<FeCompositeOperator> CompositeOperatorConverter(CompositeOperatorData, COMPOSITE_ENDOPERATOR);
 
+// feComponentTransfer
+const EnumData<NR::FilterComponentTransferType> 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<NR::FilterComponentTransferType> ComponentTransferTypeConverter(ComponentTransferTypeData, NR::COMPONENTTRANSFER_TYPE_ERROR);
+
 // feConvolveMatrix
 const EnumData<NR::FilterConvolveMatrixEdgeMode> ConvolveMatrixEdgeModeData[NR::CONVOLVEMATRIX_EDGEMODE_ENDTYPE] = {
     {NR::CONVOLVEMATRIX_EDGEMODE_DUPLICATE, _("Duplicate"), "duplicate"},
index c1e3fcdcc7a74794fc9120d3d0efba2903ee267d..fe517ea5ec8e77982d52664e5d5d5d0e71fcb26a 100644 (file)
@@ -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<NR::FilterBlendMode> BlendModeCon
 // ColorMatrix type
 extern const Inkscape::Util::EnumData<NR::FilterColorMatrixType> ColorMatrixTypeData[NR::COLORMATRIX_ENDTYPE];
 extern const Inkscape::Util::EnumDataConverter<NR::FilterColorMatrixType> ColorMatrixTypeConverter;
+// ComponentTransfer type
+extern const Inkscape::Util::EnumData<NR::FilterComponentTransferType> ComponentTransferTypeData[NR::COMPONENTTRANSFER_TYPE_ERROR];
+extern const Inkscape::Util::EnumDataConverter<NR::FilterComponentTransferType> ComponentTransferTypeConverter;
 // Composite operator
 extern const Inkscape::Util::EnumData<FeCompositeOperator> CompositeOperatorData[COMPOSITE_ENDOPERATOR];
 extern const Inkscape::Util::EnumDataConverter<FeCompositeOperator> CompositeOperatorConverter;
index 2bf3e809a0346ea0373be2d9479da67086748d87..1ff231a1ff1e32e8228ba3ae1e6a82a6236c1706 100644 (file)
@@ -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)
index 60e2c8c8c5afcbdde7c7fe809ab67ce94b9f604b..0e3727ce81ff1f3e97a13319171979bc7a0ed761 100644 (file)
@@ -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()
index ac7b96fd664609f06033c25a4d602e19ff6a04a7..1a4285dd9300cf24882fa6e70dddbbaee640766b 100644 (file)
@@ -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;