]> git.tdb.fi Git - libs/gltk.git/blob - source/geometry.h
fdef8ace97d45557d9450f4fca535c3fc2446e01
[libs/gltk.git] / source / geometry.h
1 #ifndef MSP_GLTK_GEOMETRY_H_
2 #define MSP_GLTK_GEOMETRY_H_
3
4 #include <msp/datafile/loader.h>
5
6 namespace Msp {
7 namespace GLtk {
8
9 /**
10 Specifies the position and size of a widget or graphic.
11 */
12 struct Geometry
13 {
14         int x, y;
15         unsigned w, h;
16
17         Geometry(): x(0), y(0), w(1), h(1) { }
18         Geometry(int x_, int y_, unsigned w_, unsigned h_): x(x_), y(y_), w(w_), h(h_) { }
19         bool is_inside(int, int) const;
20 };
21
22 /**
23 Specifies margins on the sides of an element.
24 */
25 struct Sides
26 {
27         class Loader: public DataFile::Loader
28         {
29         public:
30                 Loader(Sides &);
31                 Sides &get_object() { return sides; }
32         private:
33                 Sides &sides;
34         };
35
36         unsigned top;
37         unsigned right;
38         unsigned bottom;
39         unsigned left;
40
41         Sides();
42 };
43
44 } // namespace GLtk
45 } // namespace Msp
46
47 #endif