]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/arrangement.h
Use nullptr instead of 0 for pointers
[libs/gltk.git] / source / arrangement.h
index ed1798b8a74856fcd18d2fc96bb9a9d12051a509..2decb3eb4fc5ef71513fe9985b86462e5cf04425 100644 (file)
@@ -4,20 +4,21 @@
 #include <list>
 #include <stdexcept>
 #include "layout.h"
+#include "mspgltk_api.h"
 
 namespace Msp {
 namespace GLtk {
 
 class Widget;
 
-class arrangement_error: public std::logic_error
+class MSPGLTK_API arrangement_error: public std::logic_error
 {
 public:
        arrangement_error(const std::string &w): std::logic_error(w) { }
        virtual ~arrangement_error() throw() { }
 };
 
-class Arrangement
+class MSPGLTK_API Arrangement
 {
 protected:
        enum Side
@@ -31,17 +32,16 @@ protected:
        struct Edge
        {
                std::list<Widget *> widgets;
-               bool aligned;
-
-               Edge();
+               bool aligned = false;
 
                bool empty() { return widgets.empty(); }
                void clear();
                void add(Widget &, bool);
+               void align();
        };
 
        Layout &layout;
-       Arrangement *parent;
+       Arrangement *parent = nullptr;
        Edge edges[4];
 
        Arrangement(Layout &);
@@ -56,8 +56,11 @@ protected:
        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 &);
+       void add_constraint(Widget &, Layout::ConstraintType, Side, int = -1);
+       void add_constraint(Widget &, Layout::ConstraintType, const Edge &, int = -1);
+
+       static Layout::ConstraintType get_order_constraint(Side, bool);
+       static Layout::ConstraintType get_align_constraint(Side);
 };
 
 } // namespace GLtk