summaryrefslogtreecommitdiff
path: root/ui/uiComponent.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-12-22 12:16:38 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-12-22 12:16:38 +0000
commite806d41c8703ddc4bcaf2186d0c1701bd1e1ada3 (patch)
tree1612baf22456c0b5a1bef82980177afb34b2756c /ui/uiComponent.h
parentWindow handles UIComponent rendering (diff)
downloadilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.tar.bz2
ilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.tar.xz
ilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.zip
Initial commit with some basic UI
Diffstat (limited to 'ui/uiComponent.h')
-rw-r--r--ui/uiComponent.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/ui/uiComponent.h b/ui/uiComponent.h
index cd21de3..e7b3a0b 100644
--- a/ui/uiComponent.h
+++ b/ui/uiComponent.h
@@ -1,12 +1,34 @@
#ifndef UICOMPONENT_H
#define UICOMPONENT_H
+#include <functional>
+#include <glm/glm.hpp>
+#include <special_members.hpp>
+
class UIShader;
+union SDL_Event;
+struct SDL_MouseButtonEvent;
+using UIEvent = std::function<void(const SDL_Event &)>;
class UIComponent {
public:
+ struct Position {
+ glm::vec2 origin, size;
+ Position operator+(const Position &) const;
+ Position operator+(const glm::vec2 &) const;
+ bool operator&(const SDL_MouseButtonEvent &) const;
+ bool operator&(const glm::vec2 &) const;
+ };
+ explicit UIComponent(Position);
virtual ~UIComponent() = default;
- virtual void render(const UIShader &) const = 0;
+
+ NO_MOVE(UIComponent);
+ NO_COPY(UIComponent);
+
+ virtual void render(const UIShader &, const Position & parentPos) const = 0;
+ virtual bool handleInput(const SDL_Event &, const Position & parentPos) = 0;
+
+ Position position;
};
#endif