summaryrefslogtreecommitdiff
path: root/ui/uiComponent.h
blob: e7b3a0ba46d9ac8ad3e1dd6f54962b0ef935370f (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
#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;

	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