aboutsummaryrefslogtreecommitdiff
path: root/mwe/events/include/uiObject.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-10-28 11:06:21 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-10-28 11:06:21 +0100
commit29f9a26046e35c7eb0157df92757ce8e39f1ec74 (patch)
tree18be4912561c2fcc9a57b99466c74977e11f2abf /mwe/events/include/uiObject.h
parentf1b2c5a38f49bb319babf11bf64c420a63e104f2 (diff)
iMouseListener and iKeyListener implementation
Diffstat (limited to 'mwe/events/include/uiObject.h')
-rw-r--r--mwe/events/include/uiObject.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/mwe/events/include/uiObject.h b/mwe/events/include/uiObject.h
new file mode 100644
index 0000000..46d32be
--- /dev/null
+++ b/mwe/events/include/uiObject.h
@@ -0,0 +1,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;
+};