]> git.tdb.fi Git - libs/gltk.git/blob - source/button.h
Style and comment updates
[libs/gltk.git] / source / button.h
1 #ifndef MSP_GLTK_BUTTON_H_
2 #define MSP_GLTK_BUTTON_H_
3
4 #include <sigc++/sigc++.h>
5 #include <msp/gl/texture2d.h>
6 #include "mspgltk_api.h"
7 #include "text.h"
8 #include "widget.h"
9
10 namespace Msp {
11 namespace GLtk {
12
13 /**
14 A clickable button widget.  Buttons can have a text label, which is displayed
15 in a spacial part "text".
16 */
17 class MSPGLTK_API Button: public Widget
18 {
19 public:
20         class MSPGLTK_API Loader: public DataFile::DerivedObjectLoader<Button, Widget::Loader>
21         {
22         public:
23                 Loader(Button &);
24
25         private:
26                 void text(const std::string &);
27         };
28
29         sigc::signal<void> signal_clicked;
30
31 private:
32         Text text;
33         const GL::Texture2D *icon = nullptr;
34         bool pressed = false;
35
36 public:
37         Button(const std::string & = std::string());
38
39         const char *get_class() const override { return "button"; }
40
41 private:
42         void autosize_special(const Part &, Geometry &) const override;
43
44 public:
45         void set_text(const std::string &);
46         void set_icon(const GL::Texture2D *);
47
48 private:
49         void rebuild_special(const Part &) override;
50
51 public:
52         void button_press(int, int, unsigned) override;
53         void button_release(int, int, unsigned) override;
54         void pointer_motion(int, int) override;
55         bool navigate(Navigation) override;
56 private:
57         void on_style_change() override;
58 };
59
60 } // namespace GLtk
61 } // namespace Msp
62
63 #endif