--- /dev/null
+#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
--- /dev/null
+#ifndef MSP_GLTK_DRAGHANDLE_H_
+#define MSP_GLTK_DRAGHANDLE_H_
+
+#include "widget.h"
+
+namespace Msp {
+namespace GLtk {
+
+/**
+Moves its parent widget when dragged. This allows turning a Panel or Dialog
+into a movable window.
+*/
+class DragHandle: public Widget
+{
+private:
+ bool dragging;
+ int drag_x;
+ int drag_y;
+
+public:
+ DragHandle();
+
+ virtual const char *get_class() const { return "draghandle"; }
+
+ virtual void button_press(int, int, unsigned);
+ virtual void button_release(int, int, unsigned);
+ virtual void pointer_motion(int, int);
+private:
+ virtual void on_reparent();
+};
+
+} // namespace GLtk
+} // namespace Msp
+
+#endif
#include <msp/core/refptr.h>
#include "button.h"
#include "column.h"
+#include "draghandle.h"
#include "dropdown.h"
#include "entry.h"
#include "grid.h"
add("button", &Loader::child<Button>);
add("column", &Loader::arrangement<Column>);
add("constraint",&Loader::constraint);
+ add("draghandle",&Loader::child<DragHandle>);
add("dropdown", &Loader::child<Dropdown>);
add("entry", &Loader::child<Entry>);
add("expand", &Loader::expand);