From: johncoswell Date: Sun, 21 Oct 2007 12:04:38 +0000 (+0000) Subject: add precision option to float parameters in extensions X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=60fe8d8de83bb144b3769dd3764e14401bbe6a8f;p=inkscape.git add precision option to float parameters in extensions --- diff --git a/src/extension/paramfloat.cpp b/src/extension/paramfloat.cpp index 85a0bc4b9..2d41720c9 100644 --- a/src/extension/paramfloat.cpp +++ b/src/extension/paramfloat.cpp @@ -41,6 +41,11 @@ ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * if (minval != NULL) _min = atof(minval); + _precision = 1; + const char * precision = xml->attribute("precision"); + if (precision != NULL) + _precision = atoi(precision); + /* We're handling this by just killing both values */ if (_max < _min) { _max = 10.0; @@ -144,7 +149,7 @@ ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign hbox->pack_start(*label, true, true); ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); - Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, 1)); + Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, _precision)); spin->show(); hbox->pack_start(*spin, false, false); diff --git a/src/extension/paramfloat.h b/src/extension/paramfloat.h index ab9d61177..fb8f8d5f8 100644 --- a/src/extension/paramfloat.h +++ b/src/extension/paramfloat.h @@ -22,6 +22,7 @@ private: float _value; float _min; float _max; + int _precision; public: ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); /** \brief Returns \c _value */ @@ -29,6 +30,7 @@ public: float set (float in, SPDocument * doc, Inkscape::XML::Node * node); float max (void) { return _max; } float min (void) { return _min; } + float precision (void) { return _precision; } Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); };