summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d1d9a8)
raw | patch | inline | side by side (parent: 4d1d9a8)
author | JucaBlues <JucaBlues@users.sourceforge.net> | |
Fri, 15 Feb 2008 03:00:10 +0000 (03:00 +0000) | ||
committer | JucaBlues <JucaBlues@users.sourceforge.net> | |
Fri, 15 Feb 2008 03:00:10 +0000 (03:00 +0000) |
index 95b1f371a46843620e985d10f19e682b8ae85938..72218036438f2c657e2bda7f9bc98128e7ed385b 100644 (file)
*
* Authors:
* Nicholas Bishop <nicholasbishop@gmail.org>
+ * Rodrigo Kumpera <kumpera@gmail.com>
+ * Felipe C. da S. Sanches <felipe.sanches@gmail.com>
*
* Copyright (C) 2007 Authors
*
const Glib::ustring& tv, const Glib::ustring& fv,
const SPAttributeEnum a)
: Gtk::CheckButton(label),
- AttrWidget(a),
+ AttrWidget(a, true),//TO-DO: receive a defaultvalue parameter in the constructor
_true_val(tv), _false_val(fv)
{
signal_toggled().connect(signal_attr_changed().make_slot());
set_active(true);
else if(_false_val == val)
set_active(false);
+ } else {
+ set_active(get_default()->as_bool());
}
}
private:
SpinButtonAttr(double lower, double upper, double step_inc,
double climb_rate, int digits, const SPAttributeEnum a)
: Gtk::SpinButton(climb_rate, digits),
- AttrWidget(a)
+ AttrWidget(a, lower)
{
set_range(lower, upper);
set_increments(step_inc, step_inc * 5);
void set_from_attribute(SPObject* o)
{
const gchar* val = attribute_value(o);
- if(val)
+ if(val){
set_value(Glib::Ascii::strtod(val));
+ } else {
+ set_value(get_default()->as_double());
+ }
}
};
public:
DualSpinButton(double lower, double upper, double step_inc,
double climb_rate, int digits, const SPAttributeEnum a)
- : AttrWidget(a),
+ : AttrWidget(a), //TO-DO: receive default num-opt-num as parameter in the constructor
_s1(climb_rate, digits), _s2(climb_rate, digits)
{
_s1.set_range(lower, upper);
virtual void set_from_attribute(SPObject* o)
{
const gchar* val = attribute_value(o);
+ NumberOptNumber n;
if(val) {
- NumberOptNumber n;
n.set(val);
- _s1.set_value(n.getNumber());
- _s2.set_value(n.getOptNumber());
+ } else {
+ n.set("0 0"); //TO-DO: replace this line by the next one that is currently commented out
+// n.set(default_value(o));
}
+ _s1.set_value(n.getNumber());
+ _s2.set_value(n.getOptNumber());
+
}
private:
Gtk::SpinButton _s1, _s2;
{
std::ostringstream os;
const Gdk::Color c = get_color();
- const int r = c.get_red() / 257, g = c.get_green() / 257, b = c.get_blue() / 257;
+ const int r = c.get_red() / 257, g = c.get_green() / 257, b = c.get_blue() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256?
os << "rgb(" << r << "," << g << "," << b << ")";
return os.str();
}
void set_from_attribute(SPObject* o)
{
const gchar* val = attribute_value(o);
+ guint32 i = 0;
if(val) {
- const guint32 i = sp_svg_read_color(val, 0xFFFFFFFF);
- const int r = SP_RGBA32_R_U(i), g = SP_RGBA32_G_U(i), b = SP_RGBA32_B_U(i);
- Gdk::Color col;
- col.set_rgb(r * 257, g * 257, b * 257);
- set_color(col);
+ i = sp_svg_read_color(val, 0xFFFFFFFF);
+ } else {
+ //TO-DO: read from constructor attribute
+ //i = default_value(o);
}
+ const int r = SP_RGBA32_R_U(i), g = SP_RGBA32_G_U(i), b = SP_RGBA32_B_U(i);
+ Gdk::Color col;
+ col.set_rgb(r * 256, g * 256, b * 256);
+ set_color(col);
}
};
const gchar* val = attribute_value(o);
if(val) {
_entry.set_text(val);
+ } else {
+ _entry.set_text("");
}
}
if (!node || !node->matchAttributeName("id")) return;
std::ostringstream xlikhref;
- xlikhref << "#(" << node->attribute("id") << ")";
+ xlikhref << "#" << node->attribute("id");
_entry.set_text(xlikhref.str());
}
FilterEffectsDialog& _dialog;
SetAttrSlot _set_attr_slot;
- std::vector<std::vector<AttrWidget*> > _attrwidgets;
+ std::vector<std::vector< AttrWidget*> > _attrwidgets;
int _current_type, _max_types;
};
index c2fc7ff4202c49892b5253fc58335e26b04ef1f4..b265fe25acd20f3809fe1d501ba24027eaa655d5 100644 (file)
*
* Authors:
* Nicholas Bishop <nicholasbishop@gmail.com>
+ * Rodrigo Kumpera <kumpera@gmail.com>
*
* Copyright (C) 2007 Authors
*
index acf44b2d0cd1ea972f61f7b664647d3c5f117373..c87e860d5da882c6b3dea4eef091b9f6ca6a44d0 100644 (file)
*
* Authors:
* Nicholas Bishop <nicholasbishop@gmail.com>
+ * Rodrigo Kumpera <kumpera@gmail.com>
*
* Copyright (C) 2007 Authors
*
namespace UI {
namespace Widget {
+enum DefaultValueType
+{
+ T_NONE,
+ T_DOUBLE,
+ T_VECT_DOUBLE,
+ T_BOOL
+};
+
+class DefaultValueHolder
+{
+ DefaultValueType type;
+ union {
+ double d_val;
+ std::vector<double>* vt_val;
+ bool b_val;
+ } value;
+
+ //FIXME remove copy ctor and assignment operator as private to avoid double free of the vector
+public:
+ DefaultValueHolder () {
+ type = T_NONE;
+ }
+
+ DefaultValueHolder (double d) {
+ type = T_DOUBLE;
+ value.d_val = d;
+ }
+
+ DefaultValueHolder (std::vector<double>* d) {
+ type = T_VECT_DOUBLE;
+ value.vt_val = d;
+ }
+
+ DefaultValueHolder (bool d) {
+ type = T_BOOL;
+ value.b_val = d;
+ }
+
+ ~DefaultValueHolder() {
+ if (type == T_VECT_DOUBLE)
+ delete value.vt_val;
+ }
+
+ bool as_bool() {
+ g_assert (type == T_BOOL);
+ return value.b_val;
+ }
+
+ double as_double() {
+ g_assert (type == T_DOUBLE);
+ return value.d_val;
+ }
+
+ std::vector<double>* as_vector() {
+ g_assert (type == T_VECT_DOUBLE);
+ return value.vt_val;
+ }
+};
+
class AttrWidget
{
public:
+ AttrWidget(const SPAttributeEnum a, double value)
+ : _attr(a),
+ _default(value)
+ {}
+
+ AttrWidget(const SPAttributeEnum a, bool value)
+ : _attr(a),
+ _default(value)
+ {}
+
AttrWidget(const SPAttributeEnum a)
- : _attr(a)
+ : _attr(a),
+ _default()
{}
virtual ~AttrWidget()
return _signal;
}
protected:
+ DefaultValueHolder* get_default() { return &_default; }
const gchar* attribute_value(SPObject* o) const
{
const gchar* name = (const gchar*)sp_attribute_name(_attr);
private:
const SPAttributeEnum _attr;
+ DefaultValueHolder _default;
sigc::signal<void> _signal;
};
index 15cd5ea1b881946b207ac7f3b7e49f64dad360ab..799f5c3fba2c2ac40111844648e283d3862589f1 100644 (file)
*
* Author:
* Nicholas Bishop <nicholasbishop@gmail.com>
+ * Felipe C. da S. Sanches <felipe.sanches@gmail.com>
*
* Copyright (C) 2007 Author
*
SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc,
double climb_rate, int digits, const SPAttributeEnum a)
- : AttrWidget(a), _adjustment(value, lower, upper, step_inc),
+ : AttrWidget(a, value), _adjustment(value, lower, upper, step_inc),
_scale(_adjustment), _spin(_adjustment, climb_rate, digits)
{
signal_value_changed().connect(signal_attr_changed().make_slot());
const gchar* val = attribute_value(o);
if(val)
_adjustment.set_value(Glib::Ascii::strtod(val));
+ else
+ _adjustment.set_value(get_default()->as_double());
}
Glib::SignalProxy0<void> SpinSlider::signal_value_changed()