diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-05 16:12:47 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-05 16:12:47 +0100 |
commit | e36ea050972fcaaf3d85d672755bad4ebb2dcd80 (patch) | |
tree | 5145e0b66650eea1df301106b7d197a586be65f3 /mwe/events/include/uiObject.h | |
parent | 333b07775be1ef20fdb5909672c1e4dcabec1b40 (diff) | |
parent | b770475741b7c33d57331f3139c55a3f237ad274 (diff) |
merge `master` into `loek/savemgr`loek/savemgr
Diffstat (limited to 'mwe/events/include/uiObject.h')
-rw-r--r-- | mwe/events/include/uiObject.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/mwe/events/include/uiObject.h b/mwe/events/include/uiObject.h new file mode 100644 index 0000000..23efe44 --- /dev/null +++ b/mwe/events/include/uiObject.h @@ -0,0 +1,68 @@ +#pragma once +#include "event.h" +#include "eventHandler.h" +#include "gameObject.h" +#include <SDL2/SDL.h> +#include <SDL_ttf.h> +#include <functional> +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); + virtual ~UIObject() {} + int width; + int height; + int x; + int y; +}; +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); + 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; + 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; +}; |