]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/button.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / button.h
index 63159ee2318dcc6cd1ecf81e47d8b22797b2fee9..22426ca5399f6ba9c6f69c866150247f9e584d7a 100644 (file)
@@ -1,14 +1,10 @@
-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_GLTK_BUTTON_H_
 #define MSP_GLTK_BUTTON_H_
 
 #include <sigc++/sigc++.h>
+#include <msp/gl/texture2d.h>
+#include "mspgltk_api.h"
+#include "text.h"
 #include "widget.h"
 
 namespace Msp {
@@ -18,31 +14,47 @@ namespace GLtk {
 A clickable button widget.  Buttons can have a text label, which is displayed
 in a spacial part "text".
 */
-class Button: public Widget
+class MSPGLTK_API Button: public Widget
 {
 public:
-       class Loader: public Widget::Loader
+       class MSPGLTK_API Loader: public DataFile::DerivedObjectLoader<Button, Widget::Loader>
        {
        public:
                Loader(Button &);
-               Button &get_object() const;
+
+       private:
+               void text(const std::string &);
        };
 
+       sigc::signal<void> signal_clicked;
+
 private:
-       std::string text;
-       bool pressed;
+       Text text;
+       const GL::Texture2D *icon = nullptr;
+       bool pressed = false;
 
 public:
-       sigc::signal<void> signal_clicked;
+       Button(const std::string & = std::string());
+
+       const char *get_class() const override { return "button"; }
 
-       Button(const Resources &, const std::string & =std::string());
+private:
+       void autosize_special(const Part &, Geometry &) const override;
+
+public:
        void set_text(const std::string &);
-       virtual void button_press(int, int, unsigned);
-       virtual void button_release(int, int, unsigned);
-       virtual void pointer_leave();
+       void set_icon(const GL::Texture2D *);
+
+private:
+       void rebuild_special(const Part &) override;
+
+public:
+       void button_press(int, int, unsigned) override;
+       void button_release(int, int, unsigned) override;
+       void pointer_motion(int, int) override;
+       bool navigate(Navigation) override;
 private:
-       virtual const char *get_class() const { return "button"; }
-       virtual void render_special(const Part &) const;
+       void on_style_change() override;
 };
 
 } // namespace GLtk