]> git.tdb.fi Git - libs/gltk.git/blob - source/draghandle.cpp
c9e7c58d9102970c498ba0a75bce6f1b70c345e1
[libs/gltk.git] / source / draghandle.cpp
1 #include "container.h"
2 #include "draghandle.h"
3
4 namespace Msp {
5 namespace GLtk {
6
7 void DragHandle::button_press(int x, int y, unsigned btn)
8 {
9         if(btn==1 && parent)
10         {
11                 dragging = true;
12                 drag_x = x;
13                 drag_y = y;
14         }
15 }
16
17 void DragHandle::button_release(int, int, unsigned btn)
18 {
19         if(btn==1)
20                 dragging = false;
21 }
22
23 void DragHandle::pointer_motion(int x, int y)
24 {
25         if(dragging)
26         {
27                 const Geometry &pgeom = parent->get_geometry();
28                 parent->set_position(pgeom.x+x-drag_x, pgeom.y+y-drag_y);
29         }
30 }
31
32 void DragHandle::on_reparent()
33 {
34         dragging = false;
35 }
36
37 } // namespace GLtk
38 } // namespace Msp