]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/arrangement.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / arrangement.h
index f323a9b232da37389f4285de968380fe427f8e54..26e28a6f10f4967b45b480a8bd76005e84672f22 100644 (file)
@@ -1,23 +1,24 @@
 #ifndef MSP_GLTK_ARRANGEMENT_H_
 #define MSP_GLTK_ARRANGEMENT_H_
 
-#include <list>
 #include <stdexcept>
+#include <vector>
+#include <msp/core/noncopyable.h>
 #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: public NonCopyable
 {
 protected:
        enum Side
@@ -30,10 +31,8 @@ protected:
 
        struct Edge
        {
-               std::list<Widget *> widgets;
-               bool aligned;
-
-               Edge();
+               std::vector<Widget *> widgets;
+               bool aligned = false;
 
                bool empty() { return widgets.empty(); }
                void clear();
@@ -42,7 +41,7 @@ protected:
        };
 
        Layout &layout;
-       Arrangement *parent;
+       Arrangement *parent = nullptr;
        Edge edges[4];
 
        Arrangement(Layout &);
@@ -57,8 +56,8 @@ 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);