blob: 773c2f9340f7503ad9724edc7720f93ddd69d77b (
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
35
|
#include "../../include/gui/Label.hpp"
#include <mglpp/window/Window.hpp>
namespace gsr {
Label::Label(mgl::Font *font, const char *text, mgl::Color color) : text(text, *font) {
this->text.set_color(color);
}
bool Label::on_event(mgl::Event&, mgl::Window&, mgl::vec2f) {
return true;
}
void Label::draw(mgl::Window &window, mgl::vec2f offset) {
if(!visible)
return;
text.set_position((position + offset).floor());
window.draw(text);
}
void Label::set_text(std::string str) {
text.set_string(std::move(str));
}
const std::string& Label::get_text() const {
return text.get_string();
}
mgl::vec2f Label::get_size() {
if(!visible)
return {0.0f, 0.0f};
return text.get_bounds().size;
}
}
|