From: Mikko Rasa Date: Tue, 10 Jul 2007 19:23:35 +0000 (+0000) Subject: Implement set_range and set_step for Slider X-Git-Tag: 0.9~35 X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=commitdiff_plain;h=bcdbb414c5f1abe860cad6bb67fd5da7c0122cfd Implement set_range and set_step for Slider Only emit signal_value_changed from Slider when it actually changed Use font ascent instead of size to align horizontally --- diff --git a/source/slider.cpp b/source/slider.cpp index cb24c00..11e4c24 100644 --- a/source/slider.cpp +++ b/source/slider.cpp @@ -9,11 +9,25 @@ Slider::Slider(const Resources &r): max(1), value(0), step(0.1) +{ } + +void Slider::set_range(double a, double b) { + min=a; + max=b; + set_value(value); +} + +void Slider::set_step(double s) +{ + step=s; + set_value(value); } void Slider::set_value(double v) { + double old_value=value; + if(vmax) @@ -24,7 +38,8 @@ void Slider::set_value(double v) value=min+steps*step; } - signal_value_changed.emit(value); + if(value!=old_value) + signal_value_changed.emit(value); } } // namespace GLtk diff --git a/source/widget.cpp b/source/widget.cpp index e1aee84..7f153eb 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -76,7 +76,7 @@ void Widget::render_text(const Part &part, const string &text) const GL::push_matrix(); - part.get_alignment().apply(geom, text_w, static_cast(font_size)); + part.get_alignment().apply(geom, text_w, static_cast(font->get_ascent()*font_size)); GL::scale_uniform(font_size); const Color &color=style->get_font_color();