]> Shamusworld >> Repos - apple2/blob - src/gui/elements.h
Added missing files from last commit. :-/
[apple2] / src / gui / elements.h
1 #ifndef __ELEMENTS_H__
2 #define __ELEMENTS_H__
3
4 #include <SDL2/SDL.h>
5 #include <stdint.h>
6
7 enum ObjectType { OTNone = 0, OTCheckBox, OTLineEdit, OTDraggable, OTCount };
8
9 #define OBJECT_COMMON \
10         int type;         \
11         SDL_Rect r;       \
12         bool hovered;
13
14 struct Object {
15         OBJECT_COMMON;
16 };
17
18 struct CheckBox {
19         OBJECT_COMMON;
20         bool * state;
21         const char * text;
22
23         CheckBox(): type(OTCheckBox), hovered(false), state(0), text(0) { r.x = r.y = 0; }
24         CheckBox(int32_t xx, int32_t yy, bool * s = 0, const char * t = 0): type(OTCheckBox), hovered(false), state(s), text(t) { r.x = xx; r.y = yy; }
25 };
26
27 struct LineEdit {
28         OBJECT_COMMON;
29         char * text;
30         uint8_t size;
31         const char * label;
32
33         LineEdit(): type(OTLineEdit), hovered(false), text(0), size(12), label(0) { r.x = r.y = 0; }
34         LineEdit(int32_t xx, int32_t yy, char * t = 0, uint8_t sz = 12, const char * lb = 0): type(OTLineEdit), hovered(false), text(t), size(sz), label(lb) { r.x = xx; r.y = yy; }
35 };
36
37 struct Draggable {
38         OBJECT_COMMON;
39         int32_t homex, homey;
40         bool dragging;
41         SDL_Texture * img;
42         SDL_Rect dest;
43         uint8_t spot;
44
45         Draggable(): type(OTDraggable), hovered(false), homex(0), homey(0), dragging(false), img(0), spot(0) { r.x = r.y = r.w = r.h = 0; }
46         Draggable(int32_t xx, int32_t yy, int32_t w, int32_t h, SDL_Texture * i = 0): type(OTDraggable), hovered(false), homex(xx), homey(yy), dragging(false), img(i), spot(0) { r.x = xx; r.y = yy; r.w = w; r.h = h; }
47 };
48
49 #endif  // __ELEMENTS_H__
50