]> git.tdb.fi Git - libs/gltk.git/blob - source/image.h
Use the override specifier when overriding a virtual function
[libs/gltk.git] / source / image.h
1 #ifndef MSP_GLTK_IMAGE_H_
2 #define MSP_GLTK_IMAGE_H_
3
4 #include <msp/gl/texture2d.h>
5 #include "mspgltk_api.h"
6 #include "widget.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 /**
12 A widget for displaying images.
13 */
14 class MSPGLTK_API Image: public Widget
15 {
16 public:
17         class Loader: public Msp::DataFile::DerivedObjectLoader<Image, Widget::Loader>
18         {
19         public:
20                 Loader(Image &);
21         };
22
23 private:
24         const GL::Texture2D *image = nullptr;
25         std::string icon_name;
26         bool keep_aspect = true;
27
28 public:
29         Image(const GL::Texture2D * = nullptr);
30
31         const char *get_class() const override { return "image"; }
32
33 private:
34         void autosize_special(const Part &, Geometry &) const override;
35
36 public:
37         void set_image(const GL::Texture2D *);
38         void set_icon(const std::string &);
39         void set_keep_aspect(bool);
40
41 private:
42         void update_icon();
43         void rebuild_special(const Part &) override;
44         void on_style_change() override;
45         void on_reparent() override;
46 };
47
48 } // namespace GLtk
49 } // namespace Msp
50
51 #endif