-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuiElement.cpp
More file actions
54 lines (45 loc) · 935 Bytes
/
GuiElement.cpp
File metadata and controls
54 lines (45 loc) · 935 Bytes
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "GuiElement.h"
GuiElement::GuiElement(sf::Vector2f pos, sf::Vector2f size, sf::Color backC)
{
clicked = false;
enabled = true;
shape.setPosition(pos);
shape.setSize(size);
shape.setFillColor(backC);
}
GuiElement::~GuiElement(void)
{
}
bool GuiElement::isClicked(sf::RenderWindow &window)
{
if(shape.getGlobalBounds().contains(sf::Mouse::getPosition(window).x, sf::Mouse::getPosition(window).y) &&
sf::Mouse::isButtonPressed(sf::Mouse::Left) && enabled == true)
{
clicked = false;
return true;
}
else
{
clicked = true;
return false;
}
}
void GuiElement::draw(sf::RenderWindow &window)
{
window.draw(shape);
}
bool GuiElement::onMousePressed(sf::Vector2i pos)
{
if(shape.getGlobalBounds().contains(pos.x, pos.y))
return true;
else
return false;
}
bool GuiElement::onMouseReleased(sf::RenderWindow &window)
{
return false;
}
bool GuiElement::textEntered(sf::Event &event)
{
return false;
}