- const Graphic *graphic=part.get_graphic(state);
- const Graphic::Sides &shadow=graphic->get_shadow();
- unsigned gw=graphic->get_slice().w-shadow.left-shadow.right;
- unsigned gh=(part.get_fill_x() ? geom.h, graphic->get_slice().h)-shadow.bottom-shadow.top;
- GL::translate((geom.w-gw)*(value-min)/(max-min), part.get_alignment().y
+ const Graphic *graphic = part.get_graphic(state);
+ if(!graphic || !graphic->get_texture())
+ return;
+
+ Alignment align = part.get_alignment();
+ if(max>min)
+ align.x = (value-min)/(max-min);
+
+ Geometry pgeom = part.get_geometry();
+ align.apply(pgeom, geom, part.get_margin());
+
+ GL::MeshBuilder bld(part_cache.create_mesh(part, *graphic->get_texture()));
+ bld.matrix() *= GL::Matrix::translation(pgeom.x, pgeom.y, 0);
+ graphic->build(pgeom.w, pgeom.h, bld);
+ }
+}
+
+void HSlider::button_press(int x, int, unsigned btn)
+{
+ if(btn==1 && max>min)
+ click(x);
+}
+
+void HSlider::button_release(int, int, unsigned btn)
+{
+ if(btn==1 && dragging)
+ end_drag();
+}
+
+void HSlider::pointer_motion(int x, int)
+{
+ if(dragging)
+ drag(x);
+}
+
+void HSlider::on_size_change()
+{
+ drag_area_size = geom.w-total_margin;
+}
+
+void HSlider::on_style_change()
+{
+ if(!style)
+ return;
+
+ if(const Part *slider_part = style->get_part("slider"))
+ {
+ slider_size = slider_part->get_geometry().w;
+ const Sides &margin = slider_part->get_margin();
+ drag_area_offset = margin.left;
+ total_margin = margin.left+margin.right;