]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / widget.h
index 9b86691e48343344b723af0ad2d90726d82ff6b6..001da84a891f2bb9743f3d3553cff6cee7ddbf03 100644 (file)
@@ -2,6 +2,7 @@
 #define MSP_GLTK_WIDGET_H_
 
 #include <string>
+#include <msp/core/noncopyable.h>
 #include <msp/datafile/objectloader.h>
 #include <msp/gl/renderer.h>
 #include "geometry.h"
@@ -21,7 +22,7 @@ class Style;
 /**
 Base class for all widgets.
 */
-class MSPGLTK_API Widget
+class MSPGLTK_API Widget: public NonCopyable
 {
        friend class Container;
 
@@ -30,6 +31,7 @@ public:
        {
        public:
                Loader(Widget &);
+
        private:
                void position(int, int);
                void size(unsigned, unsigned);
@@ -47,20 +49,17 @@ public:
 protected:
        Geometry geom;
        std::string style_name;
-       const Style *style = 0;
+       const Style *style = nullptr;
        State state = NORMAL;
        bool visible = true;
        InputType input_type = INPUT_NONE;
-       Container *parent = 0;
+       Container *parent = nullptr;
        std::string tooltip;
        PartCache part_cache;
        bool rebuild_needed = false;
        Time::TimeDelta anim_interval;
 
        Widget() = default;
-private:
-       Widget(const Widget &);
-       Widget &operator=(const Widget &);
 public:
        virtual ~Widget();