]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/arrangement.h
Replace the derived layout classes with a more flexible design
[libs/gltk.git] / source / arrangement.h
diff --git a/source/arrangement.h b/source/arrangement.h
new file mode 100644 (file)
index 0000000..284d3f7
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef MSP_GLTK_ARRANGEMENT_H_
+#define MSP_GLTK_ARRANGEMENT_H_
+
+#include <list>
+#include "layout.h"
+
+namespace Msp {
+namespace GLtk {
+
+class Widget;
+
+class Arrangement
+{
+protected:
+       enum Side
+       {
+               TOP,
+               RIGHT,
+               BOTTOM,
+               LEFT
+       };
+
+       struct Edge
+       {
+               std::list<Widget *> widgets;
+               bool aligned;
+
+               Edge();
+
+               bool empty() { return widgets.empty(); }
+               void clear();
+               void add(Widget &, bool);
+       };
+
+       Layout &layout;
+       Arrangement *parent;
+       Edge edges[4];
+
+       Arrangement(Layout &);
+public:
+       virtual ~Arrangement();
+
+       void arrange(Widget &);
+       void arrange(Arrangement &);
+
+protected:
+       virtual void process_widget(Widget &, Side, bool) = 0;
+       virtual void finish_widget(Widget &) = 0;
+       virtual void finish_slot() = 0;
+       const Edge &get_edge(Side s) const { return edges[s]; }
+       void add_constraint(Widget &, Layout::ConstraintType, Side);
+       void add_constraint(Widget &, Layout::ConstraintType, const Edge &);
+};
+
+} // namespace GLtk
+} // namespace Msp
+
+#endif