aboutsummaryrefslogtreecommitdiff
path: root/mwe/events/include/uiObject.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-03 13:34:27 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-03 13:34:27 +0100
commit2585dc3cab48ccad0cfa0c63354662d656c86c46 (patch)
tree579851837f35842e5ed682c912c470d68df79183 /mwe/events/include/uiObject.h
parent5deb950619dff9dde8b49520b23e3ce4001afbee (diff)
`make format`
Diffstat (limited to 'mwe/events/include/uiObject.h')
-rw-r--r--mwe/events/include/uiObject.h74
1 files changed, 36 insertions, 38 deletions
diff --git a/mwe/events/include/uiObject.h b/mwe/events/include/uiObject.h
index 893232d..23efe44 100644
--- a/mwe/events/include/uiObject.h
+++ b/mwe/events/include/uiObject.h
@@ -1,70 +1,68 @@
#pragma once
+#include "event.h"
+#include "eventHandler.h"
#include "gameObject.h"
#include <SDL2/SDL.h>
#include <SDL_ttf.h>
-#include "event.h"
-#include "eventHandler.h"
#include <functional>
struct Alignment {
- enum class Horizontal { LEFT, CENTER, RIGHT };
- enum class Vertical { TOP, MIDDLE, BOTTOM };
- enum class PositioningMode { RELATIVE, STATIC,ABSOLUTE };
+ 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;
+ Horizontal horizontal = Horizontal::CENTER;
+ Vertical vertical = Vertical::MIDDLE;
+ PositioningMode mode = PositioningMode::RELATIVE;
- int staticX = 0;
- int staticY = 0;
+ int staticX = 0;
+ int staticY = 0;
- int marginTop = 0;
- int marginBottom = 0;
- int marginLeft = 0;
- int marginRight = 0;
+ int marginTop = 0;
+ int marginBottom = 0;
+ int marginLeft = 0;
+ int marginRight = 0;
};
-struct RGBColor{
+struct RGBColor {
int red;
int green;
int blue;
};
-class UIObject : public GameObject{
- public:
- UIObject(int width,int height);
+class UIObject : public GameObject {
+public:
+ UIObject(int width, int height);
virtual ~UIObject() {}
int width;
int height;
int x;
int y;
};
-class Button : public UIObject{
- public:
- Button(int width,int height);
+class Button : public UIObject {
+public:
+ Button(int width, int height);
RGBColor color;
std::function<void()> onClick;
-
};
-class Text : public UIObject{
- public:
- Text(int width,int height);
+class Text : public UIObject {
+public:
+ Text(int width, int height);
std::string text;
int size;
Alignment alignment;
//font resource
- TTF_Font *font;
+ TTF_Font * font;
RGBColor color;
};
class TextInput : public UIObject {
public:
- TextInput(int width, int height);
- std::string textBuffer;
- std::string placeholder;
- bool isActive = false;
- RGBColor textColor;
- RGBColor backgroundColor;
- size_t maxLength = 100;
- Alignment alignment;
- TTF_Font* font = nullptr;
- std::function<void()> onSubmit;
- std::function<void()> onFocus;
+ TextInput(int width, int height);
+ std::string textBuffer;
+ std::string placeholder;
+ bool isActive = false;
+ RGBColor textColor;
+ RGBColor backgroundColor;
+ size_t maxLength = 100;
+ Alignment alignment;
+ TTF_Font * font = nullptr;
+ std::function<void()> onSubmit;
+ std::function<void()> onFocus;
};
-