]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/hslider.cpp
Rework how widget ownership works in Container
[libs/gltk.git] / source / hslider.cpp
diff --git a/source/hslider.cpp b/source/hslider.cpp
deleted file mode 100644 (file)
index 8a9cbb8..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <msp/gl/matrix.h>
-#include <msp/gl/transform.h>
-#include "graphic.h"
-#include "hslider.h"
-#include "part.h"
-#include "style.h"
-
-namespace Msp {
-namespace GLtk {
-
-HSlider::HSlider(const Resources &r):
-       Slider(r),
-       dragging(false)
-{
-       update_style();
-}
-
-void HSlider::button_press(int x, int y, unsigned btn)
-{
-       if(geom.is_inside(x, y))
-       {
-               int sw=get_slider_width();
-               int sx=geom.x+static_cast<int>((geom.w-sw)*(value-min)/(max-min));
-               if(btn==1 && x>=sx && x<sx+sw)
-               {
-                       dragging=true;
-                       state=ACTIVE;
-                       drag_start_x=x;
-                       drag_start_value=value;
-               }
-       }
-}
-
-void HSlider::button_release(int, int, unsigned btn)
-{
-       if(btn==1)
-       {
-               dragging=false;
-               state=NORMAL;
-       }
-}
-
-void HSlider::pointer_motion(int x, int)
-{
-       if(dragging)
-       {
-               set_value(drag_start_value+(x-drag_start_x)*(max-min)/(geom.w-get_slider_width()));
-       }
-}
-
-void HSlider::render_part(const Part &part) const
-{
-       if(part.get_name()=="slider")
-       {
-               unsigned gw=part.get_width();
-               unsigned gh=(part.get_fill_y() ? geom.h : part.get_height());
-               GL::push_matrix();
-               GL::translate((geom.w-gw)*(value-min)/(max-min), (geom.h-gh)*(part.get_alignment().y+1)/2, 0);
-               const Graphic *graphic=part.get_graphic(state);
-               graphic->render(gw, gh);
-               GL::pop_matrix();
-       }
-       else
-               Widget::render_part(part);
-}
-
-unsigned HSlider::get_slider_width() const
-{
-       for(PartSeq::const_iterator i=style->get_parts().begin(); i!=style->get_parts().end(); ++i)
-               if(i->get_name()=="slider")
-                       return i->get_width();
-
-       return 0;
-}
-
-} // namespace GLtk
-} // namespace Msp