namespace Msp {
namespace GLtk {
-HSlider::HSlider():
- slider_size(1)
+HSlider::HSlider()
{ }
void HSlider::autosize_special(const Part &part, Geometry &ageom) const
void HSlider::button_press(int x, int, unsigned btn)
{
if(btn==1 && max>min)
- {
- int sx = static_cast<int>((geom.w-slider_size)*(value-min)/(max-min));
- if(x<sx)
- set_value(value-step*10);
- else if(x>=static_cast<int>(sx+slider_size))
- set_value(value+step*10);
- else
- start_drag(x);
- }
+ click(x);
}
void HSlider::button_release(int, int, unsigned btn)
*/
class HSlider: public Slider
{
-private:
- unsigned slider_size;
-
public:
HSlider();
value(0),
step(0.1),
dragging(false),
- drag_area_size(0)
+ drag_area_size(0),
+ slider_size(1)
{ }
void Slider::set_value(double v)
set_value(value);
}
+void Slider::click(int p)
+{
+ int sp = static_cast<int>(drag_area_size*(value-min)/(max-min));
+ if(p<sp)
+ set_value(value-step*10);
+ else if(p>=static_cast<int>(sp+slider_size))
+ set_value(value+step*10);
+ else
+ start_drag(p);
+}
+
void Slider::start_drag(int p)
{
dragging = true;
double drag_start_pos;
double drag_start_value;
unsigned drag_area_size;
+ unsigned slider_size;
Slider();
double get_value() const { return value; }
protected:
+ void click(int);
void start_drag(int);
void drag(int);
void end_drag();
namespace Msp {
namespace GLtk {
-VSlider::VSlider():
- slider_size(1)
+VSlider::VSlider()
{ }
void VSlider::autosize_special(const Part &part, Geometry &ageom) const
void VSlider::button_press(int, int y, unsigned btn)
{
if(btn==1 && max>min)
- {
- int sy = static_cast<int>((geom.h-slider_size)*(value-min)/(max-min));
- if(y<sy)
- set_value(value-step*10);
- else if(y>=static_cast<int>(sy+slider_size))
- set_value(value+step*10);
- else
- start_drag(y);
- }
+ click(y);
}
void VSlider::button_release(int, int, unsigned btn)
class VSlider: public Slider
{
-private:
- unsigned slider_size;
-
public:
VSlider();