blob: ef62db9b84888501d7827e9ea7f4043a1ef8c89a (
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
|
#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};
}
|