index e777542e3e3eb79e390939327557cdbd4685692b..b90895df8ec1802317968ca2fb006645b6eb8622 100644 (file)
*
* Author:
* Nicholas Bishop <nicholasbishop@gmail.com>
*
* Author:
* Nicholas Bishop <nicholasbishop@gmail.com>
+ * Felipe C. da S. Sanches <felipe.sanches@gmail.com>
*
* Copyright (C) 2007 Author
*
*
* Copyright (C) 2007 Author
*
*/
#include "glib/gstrfuncs.h"
*/
#include "glib/gstrfuncs.h"
+#include "glibmm/i18n.h"
#include "spin-slider.h"
#include "spin-slider.h"
namespace Widget {
SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc,
namespace Widget {
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),
+ double climb_rate, int digits, const SPAttributeEnum a, char* tip_text)
+ : AttrWidget(a, value), _adjustment(value, lower, upper, step_inc),
_scale(_adjustment), _spin(_adjustment, climb_rate, digits)
{
_scale(_adjustment), _spin(_adjustment, climb_rate, digits)
{
+ signal_value_changed().connect(signal_attr_changed().make_slot());
+
pack_start(_scale);
pack_start(_spin, false, false);
pack_start(_scale);
pack_start(_spin, false, false);
+ if (tip_text){
+ _tt.set_tip(_scale, tip_text);
+ _tt.set_tip(_spin, tip_text);
+ }
_scale.set_draw_value(false);
_scale.set_draw_value(false);
const gchar* val = attribute_value(o);
if(val)
_adjustment.set_value(Glib::Ascii::strtod(val));
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()
}
Glib::SignalProxy0<void> SpinSlider::signal_value_changed()
}
DualSpinSlider::DualSpinSlider(double value, double lower, double upper, double step_inc,
}
DualSpinSlider::DualSpinSlider(double value, double lower, double upper, double step_inc,
- double climb_rate, int digits, const SPAttributeEnum a)
- : AttrWidget(a), _s1(value, lower, upper, step_inc, climb_rate, digits),
- _s2(value, lower, upper, step_inc, climb_rate, digits)
+ double climb_rate, int digits, const SPAttributeEnum a, char* tip_text1, char* tip_text2)
+ : AttrWidget(a),
+ _s1(value, lower, upper, step_inc, climb_rate, digits, SP_ATTR_INVALID, tip_text1),
+ _s2(value, lower, upper, step_inc, climb_rate, digits, SP_ATTR_INVALID, tip_text2),
+ //TRANSLATORS: Only translate the word "Link" - means to _link_ two sliders together
+ _link(Q_("sliders|Link"))
{
{
+ signal_value_changed().connect(signal_attr_changed().make_slot());
+
_s1.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
_s2.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
_s1.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
_s2.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
+ _s1.get_adjustment().signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked));
+ _link.signal_toggled().connect(sigc::mem_fun(*this, &DualSpinSlider::link_toggled));
+
+ Gtk::VBox* vb = Gtk::manage(new Gtk::VBox);
+ vb->add(_s1);
+ vb->add(_s2);
+ pack_start(*vb);
+ pack_start(_link, false, false);
+ _link.set_active(true);
+
+ show_all();
}
Glib::ustring DualSpinSlider::get_as_attribute() const
{
}
Glib::ustring DualSpinSlider::get_as_attribute() const
{
- return _s1.get_as_attribute() + " " + _s2.get_as_attribute();
+ if(_link.get_active())
+ return _s1.get_as_attribute();
+ else
+ return _s1.get_as_attribute() + " " + _s2.get_as_attribute();
}
void DualSpinSlider::set_from_attribute(SPObject* o)
}
void DualSpinSlider::set_from_attribute(SPObject* o)
if(toks[1])
v2 = Glib::Ascii::strtod(toks[1]);
if(toks[1])
v2 = Glib::Ascii::strtod(toks[1]);
+ _link.set_active(toks[1] == 0);
+
_s1.get_adjustment().set_value(v1);
_s2.get_adjustment().set_value(v2);
_s1.get_adjustment().set_value(v1);
_s2.get_adjustment().set_value(v2);
_s2.remove_scale();
}
_s2.remove_scale();
}
+void DualSpinSlider::link_toggled()
+{
+ _s2.set_sensitive(!_link.get_active());
+ update_linked();
+}
+
+void DualSpinSlider::update_linked()
+{
+ if(_link.get_active())
+ _s2.set_value(_s1.get_value());
+}
+
} // namespace Widget
} // namespace UI
} // namespace Inkscape
} // namespace Widget
} // namespace UI
} // namespace Inkscape