diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-22 12:16:38 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-22 12:16:38 +0000 |
commit | e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3 (patch) | |
tree | 1612baf22456c0b5a1bef82980177afb34b2756c /ui/uiComponent.cpp | |
parent | Window handles UIComponent rendering (diff) | |
download | ilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.tar.bz2 ilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.tar.xz ilt-e806d41c8703ddc4bcaf2186d0c1701bd1e1ada3.zip |
Initial commit with some basic UI
Diffstat (limited to 'ui/uiComponent.cpp')
-rw-r--r-- | ui/uiComponent.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ui/uiComponent.cpp b/ui/uiComponent.cpp new file mode 100644 index 0000000..ef62db9 --- /dev/null +++ b/ui/uiComponent.cpp @@ -0,0 +1,27 @@ +#include "uiComponent.h" +#include <SDL2/SDL.h> + +UIComponent::UIComponent(Position position) : position {position} { } + +UIComponent::Position +UIComponent::Position::operator+(const Position & parentPos) const +{ + return *this + parentPos.origin; +} + +UIComponent::Position +UIComponent::Position::operator+(const glm::vec2 & parentPos) const +{ + return {origin + parentPos, size}; +} + +bool +UIComponent::Position::operator&(const glm::vec2 & pos) const +{ + return (pos.x >= origin.x && pos.y >= origin.y && pos.x < origin.x + size.x && pos.y < origin.y + size.y); +} +bool +UIComponent::Position::operator&(const SDL_MouseButtonEvent & pos) const +{ + return *this & glm::vec2 {pos.x, pos.y}; +} |