aboutsummaryrefslogtreecommitdiff
path: root/mwe/events/include/uiObject.h
blob: 46d32becef931dcbc67b53ca2866d545f0267e46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "gameObject.h"
#include <SDL2/SDL.h>
#include <SDL_ttf.h>
#include "event.h"
#include "eventHandler.h"
struct Alignment {
    enum class Horizontal { LEFT, CENTER, RIGHT };
    enum class Vertical { TOP, MIDDLE, BOTTOM };
    enum class PositioningMode { RELATIVE, STATIC,ABSOLUTE };

    Horizontal horizontal = Horizontal::CENTER;
    Vertical vertical = Vertical::MIDDLE;
    PositioningMode mode = PositioningMode::RELATIVE;

    int staticX = 0;
    int staticY = 0;

    int marginTop = 0;
    int marginBottom = 0;
    int marginLeft = 0;
    int marginRight = 0;
};
struct RGBColor{
	int red,
	int green,
	int blue
};
class UIObject : public GameObject{
	public:
	UIObject(int width,int height);
	private:
	int width;
	int height;
};
class Button : public UIObject{
	public:
	Button(int width,int height);
	EventHandler<KeyPressedEvent> onKeyPressed;
	EventHandler<KeyReleasedEvent> onKeyReleased;

};
class Text : public UIObject{
	public:
	Text(int width,int height);
	private:
	std::string text;
	int size;
	Alignment alignment;
	//font resource
	TTF_Font *font;
	RGBColor color;
};
class TextInput : public UIObject{
	public:
	TextInput (int width,int height);
	std::string textBuffer;
    std::string placeholder;
    size_t caretPosition;
    bool isActive;
    RGBColor textColor;
    RGBColor backgroundColor;
    size_t maxLength;
    Alignment alignment;
    TTF_Font* font;
	EventHandler<TextSubmitEvent> onSubmit;
};