diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-08-17 20:30:10 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-08-17 20:30:10 +0000 |
| commit | 32144cc14e87e3c3eede2966a874f17da9c24eba (patch) | |
| tree | 8044c7a6c739386393357d085dd7b9db793bc4dd /src/live_effects/parameter | |
| parent | Enable center-dragging of boxes ('in perspective') within the XY-plane (diff) | |
| download | inkscape-32144cc14e87e3c3eede2966a874f17da9c24eba.tar.gz inkscape-32144cc14e87e3c3eede2966a874f17da9c24eba.zip | |
Fix LPE:
* add default values for parameters
* remove text for LPE_INVALID
* update example for skel strokes
* clean a bit of the code
(bzr r3498)
Diffstat (limited to 'src/live_effects/parameter')
| -rw-r--r-- | src/live_effects/parameter/enum.h | 32 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.cpp | 8 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.h | 18 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.h | 11 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.cpp | 17 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.h | 11 |
7 files changed, 64 insertions, 40 deletions
diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index d70360a24..bfc9fd352 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -28,11 +28,14 @@ public: const Glib::ustring& tip,
const Glib::ustring& key,
const Util::EnumDataConverter<E>& c,
- Inkscape::UI::Widget::Registry* wr, Effect* effect)
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ E defvalue)
: Parameter(label, tip, key, wr, effect)
{
regenum = NULL;
enumdataconv = &c;
+ value = defvalue;
};
~EnumParam() {
if (regenum)
@@ -44,37 +47,36 @@ public: regenum = new Inkscape::UI::Widget::RegisteredEnum<E>();
regenum->init(param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));
+ regenum->combobox()->set_active_by_id(value);
}
return dynamic_cast<Gtk::Widget *> (regenum->labelled);
};
bool param_readSVGValue(const gchar * strvalue) {
+ if (!strvalue) return false;
+
+ value = enumdataconv->get_id_from_key(Glib::ustring(strvalue));
+
if (regenum)
- regenum->combobox()->set_active_by_key(Glib::ustring(strvalue));
+ regenum->combobox()->set_active_by_id(value);
+
return true;
};
gchar * param_writeSVGValue() const {
- if (regenum) {
- gchar * str = g_strdup(regenum->combobox()->get_active_data()->key.c_str());
- return str;
- } else {
- return NULL;
- }
+ gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
+ return str;
};
- const Util::EnumData<E>* get_selected_data() {
- if (regenum) {
- return regenum->combobox()->get_active_data();
- } else {
- return NULL;
- }
- };
+ E get_value() const {
+ return value;
+ }
private:
EnumParam(const EnumParam&);
EnumParam& operator=(const EnumParam&);
UI::Widget::RegisteredEnum<E> * regenum;
+ E value;
const Util::EnumDataConverter<E> * enumdataconv;
};
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 6806a1d49..beaafcc22 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -62,6 +62,8 @@ RealParam::param_readSVGValue(const gchar * strvalue) unsigned int success = sp_svg_number_read_d(strvalue, &newval);
if (success == 1) {
value = newval;
+ if (rsu)
+ rsu->setValue(value);
return true;
}
return false;
@@ -71,7 +73,7 @@ gchar * RealParam::param_writeSVGValue() const
{
Inkscape::SVGOStringStream os;
- os << rsu->getS()->getValue();
+ os << value;
gchar * str = g_strdup(os.str().c_str());
return str;
}
@@ -89,9 +91,9 @@ RealParam::param_getWidget() }
-}; /* namespace LivePathEffect */
+} /* namespace LivePathEffect */
-}; /* namespace Inkscape */
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 327d3d153..93cdc94ee 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -28,7 +28,11 @@ class Effect; class Parameter {
public:
- Parameter(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);
+ Parameter( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect);
virtual ~Parameter() {};
virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
@@ -56,8 +60,12 @@ private: class RealParam : public Parameter {
public:
- RealParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key,
- Inkscape::UI::Widget::Registry* wr, Effect* effect, gdouble initial_value = 1.0);
+ RealParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ gdouble initial_value = 1.0);
~RealParam();
bool param_readSVGValue(const gchar * strvalue);
@@ -77,8 +85,8 @@ private: };
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; //namespace Inkscape
+} //namespace Inkscape
#endif
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 90974f686..d2615901f 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -33,11 +33,12 @@ namespace LivePathEffect { PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect )
+ Effect* effect, const gchar * defvalue)
: Parameter(label, tip, key, wr, effect)
{
_widget = NULL;
_tooltips = NULL;
+ param_readSVGValue(defvalue);
}
PathParam::~PathParam()
@@ -150,9 +151,9 @@ PathParam::param_write_to_repr(const char * svgd) }
-}; /* namespace LivePathEffect */
+} /* namespace LivePathEffect */
-}; /* namespace Inkscape */
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 39ea9e2d8..18ffe5321 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -25,7 +25,12 @@ namespace LivePathEffect { class PathParam : public Geom::Piecewise<Geom::D2<Geom::SBasis> >, public Parameter {
public:
- PathParam(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);;
+ PathParam ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const gchar * defvalue = "M0,0 L1,1");
~PathParam();
Gtk::Widget * param_getWidget();
@@ -49,8 +54,8 @@ private: };
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; //namespace Inkscape
+} //namespace Inkscape
#endif
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 8079f54eb..39208ad62 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -29,8 +29,8 @@ namespace LivePathEffect { PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect )
- : Geom::Point(0,0), Parameter(label, tip, key, wr, effect)
+ Effect* effect, Geom::Point defvalue )
+ : Geom::Point(defvalue), Parameter(label, tip, key, wr, effect)
{
_widget = NULL;
pointwdg = NULL;
@@ -58,7 +58,7 @@ PointParam::param_readSVGValue(const gchar * strvalue) success += sp_svg_number_read_d(strarray[1], &newy);
g_strfreev (strarray);
if (success == 2) {
- *dynamic_cast<Geom::Point *>( this ) = Geom::Point(newx, newy);
+ param_setValue( Geom::Point(newx, newy) );
return true;
}
return false;
@@ -68,7 +68,7 @@ gchar * PointParam::param_writeSVGValue() const
{
Inkscape::SVGOStringStream os;
- os << pointwdg->getPoint()->getXValue() << "," << pointwdg->getPoint()->getYValue();
+ os << (*this)[0] << "," << (*this)[1];
gchar * str = g_strdup(os.str().c_str());
return str;
}
@@ -79,7 +79,7 @@ PointParam::param_getWidget() if (!_widget) {
pointwdg = new Inkscape::UI::Widget::RegisteredPoint();
pointwdg->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
- pointwdg->setValue(0.1, 0.2);
+ pointwdg->setValue( (*this)[0], (*this)[1] );
pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
@@ -108,7 +108,8 @@ void PointParam::param_setValue(Geom::Point newpoint)
{
*dynamic_cast<Geom::Point *>( this ) = newpoint;
- pointwdg->setValue(newpoint[0], newpoint[1]);
+ if (pointwdg)
+ pointwdg->setValue(newpoint[0], newpoint[1]);
}
@@ -150,9 +151,9 @@ PointParam::on_button_click() }
}
-}; /* namespace LivePathEffect */
+} /* namespace LivePathEffect */
-}; /* namespace Inkscape */
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 1240ea3d1..368ab63ed 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -27,7 +27,12 @@ namespace LivePathEffect { class PointParam : public Geom::Point, public Parameter {
public:
- PointParam(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);;
+ PointParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ Geom::Point defvalue = Geom::Point(0,0));
~PointParam();
Gtk::Widget * param_getWidget();
@@ -50,8 +55,8 @@ private: };
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; //namespace Inkscape
+} //namespace Inkscape
#endif
|
