From e3ad9bfc9912ee6ab8d29245450e911b9fbba176 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 14 Mar 2011 18:03:26 +0100 Subject: Extensions. Slider in Float and Int extension widgets. (bzr r10103) --- src/extension/param/float.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/extension/param/float.cpp') 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 #include +#include #include #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); -- cgit v1.2.3 From 4551234fbfbc5ab5c2ca14a7b56f93775855f6d9 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 23 Mar 2011 19:18:54 +0100 Subject: Filters. Posterize basic tweaks. Extensions. Int and Float adjustment widgets adjustment. (bzr r10125) --- src/extension/param/float.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension/param/float.cpp') diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 9a677a1f9..d94463a5b 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -120,7 +120,7 @@ public: /** \brief Make the adjustment using an extension and the string describing the parameter. */ ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { + Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); return; -- cgit v1.2.3 From cc5c699ce54696232000ab14a64351d696b4b1a9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 16 Apr 2011 23:55:46 +0200 Subject: extensions: use improved spinbutton with math expression evaluation (bzr r10173) --- src/extension/param/float.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extension/param/float.cpp') diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index d94463a5b..4ef816d61 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include "xml/node.h" #include "extension/extension.h" @@ -172,7 +172,7 @@ ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign hbox->pack_start(*scale, false, false); } - Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, _precision)); + Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision)); spin->show(); hbox->pack_start(*spin, false, false); -- cgit v1.2.3 From ec8d0b742153e4715efd13fb19607c3167cc2092 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 6 Aug 2011 20:48:21 +0200 Subject: Extensions. New "indent" attribute to add an indent level to extension elements. Filters. Adding the new "indent" attribute to parameters groups. (bzr r10529) --- src/extension/param/float.cpp | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'src/extension/param/float.cpp') diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 4ef816d61..ea6a70855 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -34,27 +34,31 @@ ParamFloat::ParamFloat (const gchar * name, 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) + _value(0.0), _mode(mode), _indent(0), _min(0.0), _max(10.0) { const gchar * defaultval = NULL; - if (sp_repr_children(xml) != NULL) + if (sp_repr_children(xml) != NULL) { defaultval = sp_repr_children(xml)->content(); + } if (defaultval != NULL) { _value = g_ascii_strtod (defaultval,NULL); } const char * maxval = xml->attribute("max"); - if (maxval != NULL) + if (maxval != NULL) { _max = g_ascii_strtod (maxval,NULL); + } const char * minval = xml->attribute("min"); - if (minval != NULL) + if (minval != NULL) { _min = g_ascii_strtod (minval,NULL); + } _precision = 1; const char * precision = xml->attribute("precision"); - if (precision != NULL) + if (precision != NULL) { _precision = atoi(precision); + } /* We're handling this by just killing both values */ if (_max < _min) { @@ -62,6 +66,11 @@ ParamFloat::ParamFloat (const gchar * name, _min = 0.0; } + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } + gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _value = prefs->getDouble(extension_pref_root + pref_name, _value); @@ -69,8 +78,12 @@ ParamFloat::ParamFloat (const gchar * name, // std::cout << "New Float:: value: " << _value << " max: " << _max << " min: " << _min << std::endl; - if (_value > _max) _value = _max; - if (_value < _min) _value = _min; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } return; } @@ -88,8 +101,12 @@ float ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { _value = in; - if (_value > _max) _value = _max; - if (_value < _min) _value = _min; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } gchar * prefname = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -154,13 +171,15 @@ ParamFloatAdjustment::val_changed (void) Gtk::Widget * ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT)); label->show(); - hbox->pack_start(*label, true, true); + hbox->pack_start(*label, true, true, _indent); ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); -- cgit v1.2.3 From af07ce24271fc904e432cdf77714f49b8cbc8db8 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 18 Dec 2011 22:54:08 -0800 Subject: Const correctness fixes that also correct bug #893146. Fixed bugs: - https://launchpad.net/bugs/893146 (bzr r10783) --- src/extension/param/float.cpp | 64 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'src/extension/param/float.cpp') diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index ea6a70855..2b501a9a4 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould * Johan Engelen * + * Jon A. Cruz * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -23,7 +24,7 @@ namespace Inkscape { namespace Extension { -/** \brief Use the superclass' allocator and set the \c _value */ +/** Use the superclass' allocator and set the \c _value. */ ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, @@ -88,17 +89,18 @@ ParamFloat::ParamFloat (const gchar * name, return; } -/** \brief A function to set the \c _value - \param in The value to set to - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. -*/ -float -ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * @param in The value to set to. + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed. + */ +float ParamFloat::set(float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { _value = in; if (_value > _max) { @@ -116,9 +118,7 @@ ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) return _value; } -/** \brief Return the value as a string */ -void -ParamFloat::string (std::string &string) +void ParamFloat::string(std::string &string) const { char startstring[G_ASCII_DTOSTR_BUF_SIZE]; g_ascii_dtostr(startstring, G_ASCII_DTOSTR_BUF_SIZE, _value); @@ -126,15 +126,15 @@ ParamFloat::string (std::string &string) return; } -/** \brief A class to make an adjustment that uses Extension params */ +/** A class to make an adjustment that uses Extension params. */ class ParamFloatAdjustment : public Gtk::Adjustment { - /** The parameter to adjust */ + /** The parameter to adjust. */ ParamFloat * _pref; SPDocument * _doc; Inkscape::XML::Node * _node; sigc::signal * _changeSignal; public: - /** \brief Make the adjustment using an extension and the string + /** Make the adjustment using an extension and the string describing the parameter. */ ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) : Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { @@ -146,14 +146,13 @@ public: void val_changed (void); }; /* class ParamFloatAdjustment */ -/** \brief A function to respond to the value_changed signal from the - adjustment. - - This function just grabs the value from the adjustment and writes - it to the parameter. Very simple, but yet beautiful. -*/ -void -ParamFloatAdjustment::val_changed (void) +/** + * A function to respond to the value_changed signal from the adjustment. + * + * This function just grabs the value from the adjustment and writes + * it to the parameter. Very simple, but yet beautiful. + */ +void ParamFloatAdjustment::val_changed(void) { //std::cout << "Value Changed to: " << this->get_value() << std::endl; _pref->set(this->get_value(), _doc, _node); @@ -164,14 +163,13 @@ ParamFloatAdjustment::val_changed (void) } /** - \brief Creates a Float Adjustment for a float parameter - - Builds a hbox with a label and a float adjustment in it. -*/ -Gtk::Widget * -ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) + * Creates a Float Adjustment for a float parameter. + * + * Builds a hbox with a label and a float adjustment in it. + */ +Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) { + if (_gui_hidden) { return NULL; } -- cgit v1.2.3