1 #include <msp/gl/matrix.h>
2 #include <msp/gl/transform.h>
11 HSlider::HSlider(const Resources &r):
18 void HSlider::button_press(int x, int y, unsigned btn)
20 if(geom.is_inside(x, y))
22 int sw=get_slider_width();
23 int sx=static_cast<int>((geom.w-sw)*(value-min)/(max-min));
24 if(btn==1 && x>=sx && x<sx+sw)
29 drag_start_value=value;
34 void HSlider::button_release(int, int, unsigned btn)
43 void HSlider::pointer_motion(int x, int)
47 set_value(drag_start_value+(x-drag_start_x)*(max-min)/(geom.w-get_slider_width()));
51 void HSlider::render_part(const Part &part) const
53 if(part.get_name()=="slider")
55 unsigned gw=part.get_width();
56 unsigned gh=(part.get_fill_y() ? geom.h : part.get_height());
58 GL::translate((geom.w-gw)*(value-min)/(max-min), (geom.h-gh)*(part.get_alignment().y+1)/2, 0);
59 const Graphic *graphic=part.get_graphic(state);
60 graphic->render(gw, gh);
64 Widget::render_part(part);
67 unsigned HSlider::get_slider_width() const
69 for(PartSeq::const_iterator i=style->get_parts().begin(); i!=style->get_parts().end(); ++i)
70 if(i->get_name()=="slider")
71 return i->get_width();