diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2011-03-14 17:03:26 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2011-03-14 17:03:26 +0000 |
| commit | e3ad9bfc9912ee6ab8d29245450e911b9fbba176 (patch) | |
| tree | e1295c7811d1bfbf4c2f345d522b846ddb429329 /src/extension/param | |
| parent | Filters. Drawing CPF improvement. (diff) | |
| download | inkscape-e3ad9bfc9912ee6ab8d29245450e911b9fbba176.tar.gz inkscape-e3ad9bfc9912ee6ab8d29245450e911b9fbba176.zip | |
Extensions. Slider in Float and Int extension widgets.
(bzr r10103)
Diffstat (limited to 'src/extension/param')
| -rw-r--r-- | src/extension/param/float.cpp | 23 | ||||
| -rw-r--r-- | src/extension/param/float.h | 26 | ||||
| -rw-r--r-- | src/extension/param/int.cpp | 23 | ||||
| -rw-r--r-- | src/extension/param/int.h | 24 | ||||
| -rw-r--r-- | src/extension/param/parameter.cpp | 12 |
5 files changed, 89 insertions, 19 deletions
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 62762b3bb..9a677a1f9 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -11,6 +11,7 @@ #include <gtkmm/adjustment.h> #include <gtkmm/box.h> +#include <gtkmm/scale.h> #include <gtkmm/spinbutton.h> #include "xml/node.h" @@ -23,8 +24,17 @@ namespace Extension { /** \brief Use the superclass' allocator and set the \c _value */ -ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0.0), _min(0.0), _max(10.0) +ParamFloat::ParamFloat (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) : + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(0.0), _mode(mode), _min(0.0), _max(10.0) { const gchar * defaultval = NULL; if (sp_repr_children(xml) != NULL) @@ -153,6 +163,15 @@ 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)); + + if (_mode == FULL) { + Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); + scale->set_draw_value(false); + scale->set_size_request(200, -1); + scale->show(); + hbox->pack_start(*scale, false, false); + } + 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/param/float.h b/src/extension/param/float.h index f105d8f0e..d3e2517f7 100644 --- a/src/extension/param/float.h +++ b/src/extension/param/float.h @@ -17,14 +17,19 @@ namespace Inkscape { namespace Extension { class ParamFloat : public Parameter { -private: - /** \brief Internal value. */ - float _value; - float _min; - float _max; - int _precision; public: - ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); + enum AppearanceMode { + FULL, MINIMAL + }; + ParamFloat (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode); /** \brief Returns \c _value */ float get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } float set (float in, SPDocument * doc, Inkscape::XML::Node * node); @@ -33,6 +38,13 @@ public: float precision (void) { return _precision; } Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); void string (std::string &string); +private: + /** \brief Internal value. */ + float _value; + float _min; + float _max; + int _precision; + AppearanceMode _mode; }; } /* namespace Extension */ diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index ae69d0661..bd89c971d 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -11,6 +11,7 @@ #include <gtkmm/adjustment.h> #include <gtkmm/box.h> +#include <gtkmm/scale.h> #include <gtkmm/spinbutton.h> #include "xml/node.h" @@ -23,8 +24,17 @@ namespace Extension { /** \brief Use the superclass' allocator and set the \c _value */ -ParamInt::ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0), _min(0), _max(10) +ParamInt::ParamInt (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) : + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(0), _mode(mode), _min(0), _max(10) { const char * defaultval = NULL; if (sp_repr_children(xml) != NULL) @@ -138,6 +148,15 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal hbox->pack_start(*label, true, true); ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal)); + + if (_mode == FULL) { + Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); + scale->set_draw_value(false); + scale->set_size_request(200, -1); + scale->show(); + hbox->pack_start(*scale, false, false); + } + Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0)); spin->show(); hbox->pack_start(*spin, false, false); diff --git a/src/extension/param/int.h b/src/extension/param/int.h index a4eb54c81..01e208c46 100644 --- a/src/extension/param/int.h +++ b/src/extension/param/int.h @@ -17,13 +17,19 @@ namespace Inkscape { namespace Extension { class ParamInt : public Parameter { -private: - /** \brief Internal value. */ - int _value; - int _min; - int _max; public: - ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); + enum AppearanceMode { + FULL, MINIMAL + }; + ParamInt (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode); /** \brief Returns \c _value */ int get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } int set (int in, SPDocument * doc, Inkscape::XML::Node * node); @@ -31,6 +37,12 @@ public: int min (void) { return _min; } Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); void string (std::string &string); +private: + /** \brief Internal value. */ + int _value; + int _min; + int _max; + AppearanceMode _mode; }; } /* namespace Extension */ diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 529d5a775..4abfeb231 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -124,9 +124,17 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * if (!strcmp(type, "boolean")) { param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } else if (!strcmp(type, "int")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + if (appearance && !strcmp(appearance, "minimal")) { + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL); + } else { + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::FULL); + } } else if (!strcmp(type, "float")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + if (appearance && !strcmp(appearance, "minimal")) { + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::MINIMAL); + } else { + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::FULL); + } } else if (!strcmp(type, "string")) { param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); const gchar * max_length = in_repr->attribute("max_length"); |
