Commit e3ad9bfc authored by Nicolas Dufour's avatar Nicolas Dufour Committed by Nicolas Dufour

Extensions. Slider in Float and Int extension widgets.

(bzr r10103)
parent 686ef068
......@@ -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);
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment