summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 518fb86)
raw | patch | inline | side by side (parent: 518fb86)
author | jucablues <jucablues@users.sourceforge.net> | |
Tue, 19 Feb 2008 20:57:06 +0000 (20:57 +0000) | ||
committer | jucablues <jucablues@users.sourceforge.net> | |
Tue, 19 Feb 2008 20:57:06 +0000 (20:57 +0000) |
* set default values explicitly for all combobox filter settings at the filters dialog.
diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp
index 838db0fdfc5516b96d901f226c53987f5e4e18cc..5d454e6cdd5fd87cbb1500f923a27f236d9a9dff 100644 (file)
if (input == 1) _input2 = slot;
}
-void FilterDisplacementMap::set_channel_selector(int s, int channel) {
- if (channel>3 || channel <0) {
+void FilterDisplacementMap::set_channel_selector(int s, FilterDisplacementMapChannelSelector channel) {
+ if (channel > DISPLACEMENTMAP_CHANNEL_ALPHA || channel < DISPLACEMENTMAP_CHANNEL_RED) {
g_warning("Selected an invalid channel value. (%d)", channel);
return;
}
index b89553697d88647b64c9afad2c918e550fd21b59..34ba3aad263447330946e7c0ded8d9ca622b7229 100644 (file)
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include "sp-fedisplacementmap.h"
#include "display/nr-filter-primitive.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
virtual void set_input(int slot);
virtual void set_input(int input, int slot);
virtual void set_scale(double s);
- virtual void set_channel_selector(int channel, int s);
+ virtual void set_channel_selector(int s, FilterDisplacementMapChannelSelector channel);
virtual int render(FilterSlot &slot, FilterUnits const &units);
virtual void area_enlarge(NRRectL &area, Matrix const &trans);
virtual FilterTraits get_input_traits();
private:
double scale;
int _input2;
- int Xchannel;
- int Ychannel;
+ FilterDisplacementMapChannelSelector Xchannel;
+ FilterDisplacementMapChannelSelector Ychannel;
int out_x0, out_y0, out_w, out_h;
};
diff --git a/src/filter-enums.cpp b/src/filter-enums.cpp
index df494c50c1c80004bcdff5957b915abf40e383de..45a1c4c720ec93e6b58e072eebe6c5eb5fcce44c 100644 (file)
--- a/src/filter-enums.cpp
+++ b/src/filter-enums.cpp
@@ -97,13 +97,13 @@ const EnumData<NR::FilterConvolveMatrixEdgeMode> ConvolveMatrixEdgeModeData[NR::
const EnumDataConverter<NR::FilterConvolveMatrixEdgeMode> ConvolveMatrixEdgeModeConverter(ConvolveMatrixEdgeModeData, NR::CONVOLVEMATRIX_EDGEMODE_ENDTYPE);
// feDisplacementMap
-const EnumData<int> DisplacementMapChannelData[4] = {
- {0, _("Red"), "R"},
- {1, _("Green"), "G"},
- {2, _("Blue"), "B"},
- {3, _("Alpha"), "A"}
+const EnumData<FilterDisplacementMapChannelSelector> DisplacementMapChannelData[DISPLACEMENTMAP_CHANNEL_ENDTYPE] = {
+ {DISPLACEMENTMAP_CHANNEL_RED, _("Red"), "R"},
+ {DISPLACEMENTMAP_CHANNEL_GREEN, _("Green"), "G"},
+ {DISPLACEMENTMAP_CHANNEL_BLUE, _("Blue"), "B"},
+ {DISPLACEMENTMAP_CHANNEL_ALPHA, _("Alpha"), "A"}
};
-const EnumDataConverter<int> DisplacementMapChannelConverter(DisplacementMapChannelData, 4);
+const EnumDataConverter<FilterDisplacementMapChannelSelector> DisplacementMapChannelConverter(DisplacementMapChannelData, DISPLACEMENTMAP_CHANNEL_ENDTYPE);
// feMorphology
const EnumData<NR::FilterMorphologyOperator> MorphologyOperatorData[NR::MORPHOLOGY_OPERATOR_END] = {
diff --git a/src/filter-enums.h b/src/filter-enums.h
index fe517ea5ec8e77982d52664e5d5d5d0e71fcb26a..87d5c1217676d90d46b91d38dfc9ef1539e6c818 100644 (file)
--- a/src/filter-enums.h
+++ b/src/filter-enums.h
#include "display/nr-filter-morphology.h"
#include "display/nr-filter-turbulence.h"
#include "display/nr-filter-types.h"
+#include "sp-fedisplacementmap.h"
#include "util/enums.h"
// Filter primitives
extern const Inkscape::Util::EnumData<NR::FilterConvolveMatrixEdgeMode> ConvolveMatrixEdgeModeData[NR::CONVOLVEMATRIX_EDGEMODE_ENDTYPE];
extern const Inkscape::Util::EnumDataConverter<NR::FilterConvolveMatrixEdgeMode> ConvolveMatrixEdgeModeConverter;
// DisplacementMap channel
-extern const Inkscape::Util::EnumData<int> DisplacementMapChannelData[4];
-extern const Inkscape::Util::EnumDataConverter<int> DisplacementMapChannelConverter;
+extern const Inkscape::Util::EnumData<FilterDisplacementMapChannelSelector> DisplacementMapChannelData[4];
+extern const Inkscape::Util::EnumDataConverter<FilterDisplacementMapChannelSelector> DisplacementMapChannelConverter;
// Morphology operator
extern const Inkscape::Util::EnumData<NR::FilterMorphologyOperator> MorphologyOperatorData[NR::MORPHOLOGY_OPERATOR_END];
extern const Inkscape::Util::EnumDataConverter<NR::FilterMorphologyOperator> MorphologyOperatorConverter;
index 0fb5318422076192fcfa5373076e871a6323ac70..b53238093f91e216c49977d733a716f90f086cd3 100644 (file)
sp_feDisplacementMap_init(SPFeDisplacementMap *feDisplacementMap)
{
feDisplacementMap->scale=0;
- feDisplacementMap->xChannelSelector=3;
- feDisplacementMap->yChannelSelector=3;
+ feDisplacementMap->xChannelSelector = DISPLACEMENTMAP_CHANNEL_ALPHA;
+ feDisplacementMap->yChannelSelector = DISPLACEMENTMAP_CHANNEL_ALPHA;
feDisplacementMap->in2 = NR::NR_FILTER_SLOT_NOT_SET;
}
((SPObjectClass *) feDisplacementMap_parent_class)->release(object);
}
-static int sp_feDisplacementMap_readChannelSelector(gchar const *value)
+static FilterDisplacementMapChannelSelector sp_feDisplacementMap_readChannelSelector(gchar const *value)
{
- if (!value) return 3;
+ if (!value) return DISPLACEMENTMAP_CHANNEL_ALPHA;
switch (value[0]) {
case 'R':
- return 0;
+ return DISPLACEMENTMAP_CHANNEL_RED;
break;
case 'G':
- return 1;
+ return DISPLACEMENTMAP_CHANNEL_GREEN;
break;
case 'B':
- return 2;
+ return DISPLACEMENTMAP_CHANNEL_BLUE;
break;
case 'A':
- return 3;
+ return DISPLACEMENTMAP_CHANNEL_ALPHA;
break;
default:
// error
g_warning("Invalid attribute for Channel Selector. Valid modes are 'R', 'G', 'B' or 'A'");
break;
}
- return 3; //default is Alpha Channel
+ return DISPLACEMENTMAP_CHANNEL_ALPHA; //default is Alpha Channel
}
/**
@@ -147,7 +147,7 @@ sp_feDisplacementMap_set(SPObject *object, unsigned int key, gchar const *value)
(void)feDisplacementMap;
int input;
double read_num;
- int read_selector;
+ FilterDisplacementMapChannelSelector read_selector;
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_XCHANNELSELECTOR:
index 427bce1538661d39c84174eeb07f17061080ee68..914f770b5579a5ceddd2bea2b17a996940c11c66 100644 (file)
#include "sp-filter.h"
#include "sp-fedisplacementmap-fns.h"
+enum FilterDisplacementMapChannelSelector {
+ DISPLACEMENTMAP_CHANNEL_RED,
+ DISPLACEMENTMAP_CHANNEL_GREEN,
+ DISPLACEMENTMAP_CHANNEL_BLUE,
+ DISPLACEMENTMAP_CHANNEL_ALPHA,
+ DISPLACEMENTMAP_CHANNEL_ENDTYPE
+};
+
/* FeDisplacementMap base class */
class SPFeDisplacementMapClass;
/** DISPLACEMENTMAP ATTRIBUTES HERE */
int in2;
double scale;
- int xChannelSelector;
- int yChannelSelector;
+ FilterDisplacementMapChannelSelector xChannelSelector;
+ FilterDisplacementMapChannelSelector yChannelSelector;
};
struct SPFeDisplacementMapClass {
index a97654b75774914be3031f36be45cfdfeb0b3242..c78c3a7ee6fddabf347ada066b23933813621bf2 100644 (file)
}
// ComboBoxEnum
- template<typename T> ComboBoxEnum<T>* add_combo(const SPAttributeEnum attr,
+ template<typename T> ComboBoxEnum<T>* add_combo(T default_value, const SPAttributeEnum attr,
const Glib::ustring& label,
const Util::EnumDataConverter<T>& conv)
{
- ComboBoxEnum<T>* combo = new ComboBoxEnum<T>(conv, attr);
+ ComboBoxEnum<T>* combo = new ComboBoxEnum<T>(default_value, conv, attr);
add_widget(combo, label);
add_attr_widget(combo);
return combo;
_add_primitive(_("Add Effect:")),
_empty_settings(_("No effect selected"), Gtk::ALIGN_LEFT),
_no_filter_selected(_("No filter selected"), Gtk::ALIGN_LEFT),
+ _settings_initialized(false),
_locked(false),
- _attr_lock(false),
- _settings_initialized(false)
+ _attr_lock(false)
{
_settings = new Settings(*this, _settings_tab1, sigc::mem_fun(*this, &FilterEffectsDialog::set_attr_direct),
NR_FILTER_ENDPRIMITIVETYPE);
_filter_general_settings->add_multispinbutton(/*default width:*/ (double) 1.2, /*default height:*/ (double) 1.2, SP_ATTR_WIDTH, SP_ATTR_HEIGHT, _("Dimensions"), 0, 1000, 0.01, 0.1, 2);
_settings->type(NR_FILTER_BLEND);
- _settings->add_combo(SP_ATTR_MODE, _("Mode"), BlendModeConverter);
+ _settings->add_combo(BLEND_NORMAL, SP_ATTR_MODE, _("Mode"), BlendModeConverter);
_settings->type(NR_FILTER_COLORMATRIX);
- ComboBoxEnum<FilterColorMatrixType>* colmat = _settings->add_combo(SP_ATTR_TYPE, _("Type"), ColorMatrixTypeConverter);
+ ComboBoxEnum<FilterColorMatrixType>* colmat = _settings->add_combo(COLORMATRIX_MATRIX, 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_COMPONENTTRANSFER);
_settings->add_notimplemented();
- /*_settings->add_combo(SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter);
+ /*_settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, 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_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);
+ _settings->add_combo(COMPOSITE_OVER, SP_ATTR_OPERATOR, _("Operator"), CompositeOperatorConverter);
_k1 = _settings->add_spinslider(SP_ATTR_K1, _("K1"), -10, 10, 0.1, 0.01, 2);
_k2 = _settings->add_spinslider(SP_ATTR_K2, _("K2"), -10, 10, 0.1, 0.01, 2);
_k3 = _settings->add_spinslider(SP_ATTR_K3, _("K3"), -10, 10, 0.1, 0.01, 2);
_convolve_order->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::convolve_order_changed));
_settings->add_spinslider(SP_ATTR_DIVISOR, _("Divisor"), 1, 20, 1, 0.1, 2);
_settings->add_spinslider(SP_ATTR_BIAS, _("Bias"), -10, 10, 1, 0.01, 1);
- _settings->add_combo(SP_ATTR_EDGEMODE, _("Edge Mode"), ConvolveMatrixEdgeModeConverter);
+ _settings->add_combo(CONVOLVEMATRIX_EDGEMODE_DUPLICATE, SP_ATTR_EDGEMODE, _("Edge Mode"), ConvolveMatrixEdgeModeConverter);
_settings->add_checkbutton(SP_ATTR_PRESERVEALPHA, _("Preserve Alpha"), "true", "false");
_settings->type(NR_FILTER_DIFFUSELIGHTING);
_settings->type(NR_FILTER_DISPLACEMENTMAP);
_settings->add_spinslider(SP_ATTR_SCALE, _("Scale"), 0, 100, 1, 0.01, 1);
- _settings->add_combo(SP_ATTR_XCHANNELSELECTOR, _("X Channel"), DisplacementMapChannelConverter);
- _settings->add_combo(SP_ATTR_YCHANNELSELECTOR, _("Y Channel"), DisplacementMapChannelConverter);
+ _settings->add_combo(DISPLACEMENTMAP_CHANNEL_ALPHA, SP_ATTR_XCHANNELSELECTOR, _("X Channel"), DisplacementMapChannelConverter);
+ _settings->add_combo(DISPLACEMENTMAP_CHANNEL_ALPHA, SP_ATTR_YCHANNELSELECTOR, _("Y Channel"), DisplacementMapChannelConverter);
_settings->type(NR_FILTER_FLOOD);
_settings->add_color(SP_PROP_FLOOD_COLOR, _("Flood Color"));
_settings->add_dualspinslider(SP_ATTR_STDDEVIATION, _("Standard Deviation"), 0.01, 100, 1, 0.01, 1);
_settings->type(NR_FILTER_MORPHOLOGY);
- _settings->add_combo(SP_ATTR_OPERATOR, _("Operator"), MorphologyOperatorConverter);
+ _settings->add_combo(MORPHOLOGY_OPERATOR_ERODE, SP_ATTR_OPERATOR, _("Operator"), MorphologyOperatorConverter);
_settings->add_dualspinslider(SP_ATTR_RADIUS, _("Radius"), 0, 100, 1, 0.01, 1);
_settings->type(NR_FILTER_IMAGE);
_settings->type(NR_FILTER_TURBULENCE);
_settings->add_checkbutton(SP_ATTR_STITCHTILES, _("Stitch Tiles"), "stitch", "noStitch");
- _settings->add_combo(SP_ATTR_TYPE, _("Type"), TurbulenceTypeConverter);
+ _settings->add_combo(TURBULENCE_TURBULENCE, SP_ATTR_TYPE, _("Type"), TurbulenceTypeConverter);
_settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency"), 0, 1, 0.001, 0.01, 3);
_settings->add_spinslider(SP_ATTR_NUMOCTAVES, _("Octaves"), 1, 10, 1, 1, 0);
_settings->add_spinslider(SP_ATTR_SEED, _("Seed"), 0, 1000, 1, 1, 0);
index 0bd47b52ffed401d486750247c8622ff805d0a96..16d684dd48be4d21a21f392e3268576af51b7557 100644 (file)
Gtk::Label _empty_settings;
Gtk::Label _no_filter_selected;
bool _settings_initialized;
+
class Settings;
class MatrixAttr;
class ColorMatrixValues;
index c87e860d5da882c6b3dea4eef091b9f6ca6a44d0..34aae7db9e7a86dcd55483c1bf06898e2fd59ad6 100644 (file)
T_NONE,
T_DOUBLE,
T_VECT_DOUBLE,
- T_BOOL
+ T_BOOL,
+ T_UINT
};
class DefaultValueHolder
double d_val;
std::vector<double>* vt_val;
bool b_val;
+ unsigned int uint_val;
} value;
//FIXME remove copy ctor and assignment operator as private to avoid double free of the vector
value.b_val = d;
}
+ DefaultValueHolder (unsigned int ui) {
+ type = T_UINT;
+ value.uint_val = ui;
+ }
+
~DefaultValueHolder() {
if (type == T_VECT_DOUBLE)
delete value.vt_val;
}
+ unsigned int as_uint() {
+ g_assert (type == T_UINT);
+ return value.uint_val;
+ }
+
bool as_bool() {
g_assert (type == T_BOOL);
return value.b_val;
class AttrWidget
{
public:
+ AttrWidget(const SPAttributeEnum a, unsigned int value)
+ : _attr(a),
+ _default(value)
+ {}
+
AttrWidget(const SPAttributeEnum a, double value)
: _attr(a),
_default(value)
index c77c2f5a89a80090cc9e8fd57b2df9e0735665d1..75760ab123c5eaa3f934ff5aeafeb0637e680a74 100644 (file)
template<typename E> class ComboBoxEnum : public Gtk::ComboBox, public AttrWidget
{
public:
+ ComboBoxEnum(E default_value, const Util::EnumDataConverter<E>& c, const SPAttributeEnum a = SP_ATTR_INVALID)
+ : AttrWidget(a, (unsigned int)default_value), setProgrammatically(false), _converter(c)
+ {
+ signal_changed().connect(signal_attr_changed().make_slot());
+
+ _model = Gtk::ListStore::create(_columns);
+ set_model(_model);
+
+ pack_start(_columns.label);
+
+ // Initialize list
+ for(int i = 0; i < _converter.end; ++i) {
+ Gtk::TreeModel::Row row = *_model->append();
+ const Util::EnumData<E>* data = &_converter.data(i);
+ row[_columns.data] = data;
+ row[_columns.label] = _( _converter.get_label(data->id).c_str() );
+ }
+ set_active_by_id(default_value);
+ }
+
ComboBoxEnum(const Util::EnumDataConverter<E>& c, const SPAttributeEnum a = SP_ATTR_INVALID)
: AttrWidget(a), setProgrammatically(false), _converter(c)
{
row[_columns.data] = data;
row[_columns.label] = _( _converter.get_label(data->id).c_str() );
}
-
set_active(0);
}
if(val)
set_active(_converter.get_id_from_key(val));
else
- set_active(0);
+ set_active(get_default()->as_uint());
}
const Util::EnumData<E>* get_active_data() const