X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdraghandle.cpp;fp=source%2Fdraghandle.cpp;h=067a515c2b533e39bc31dca4f60c872056719c81;hb=31e9ee682f8a9cd77c97ed9dc142283559ddaacc;hp=0000000000000000000000000000000000000000;hpb=a122a209782e5b5400b5a70bd23ce4feadc6b36b;p=libs%2Fgltk.git diff --git a/source/draghandle.cpp b/source/draghandle.cpp new file mode 100644 index 0000000..067a515 --- /dev/null +++ b/source/draghandle.cpp @@ -0,0 +1,44 @@ +#include "container.h" +#include "draghandle.h" + +namespace Msp { +namespace GLtk { + +DragHandle::DragHandle(): + dragging(false), + drag_x(0), + drag_y(0) +{ } + +void DragHandle::button_press(int x, int y, unsigned btn) +{ + if(btn==1 && parent) + { + dragging = true; + drag_x = x; + drag_y = y; + } +} + +void DragHandle::button_release(int, int, unsigned btn) +{ + if(btn==1) + dragging = false; +} + +void DragHandle::pointer_motion(int x, int y) +{ + if(dragging) + { + const Geometry &pgeom = parent->get_geometry(); + parent->set_position(pgeom.x+x-drag_x, pgeom.y+y-drag_y); + } +} + +void DragHandle::on_reparent() +{ + dragging = false; +} + +} // namespace GLtk +} // namespace Msp