aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/Text.cpp')
-rw-r--r--src/graphics/Text.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp
index 7d08c22..dbaa7c1 100644
--- a/src/graphics/Text.cpp
+++ b/src/graphics/Text.cpp
@@ -6,12 +6,21 @@ extern "C" {
}
namespace mgl {
- Text::Text(std::string str, Font &font) : Text(std::move(str), mgl::vec2f(0.0f, 0.0f), font){}
+ Text::Text() : font(nullptr) {
+ mgl_text_init(&text, nullptr, nullptr, 0.0f, 0.0f);
+ }
+
+ Text::Text(std::string str, Font &font) : Text(std::move(str), vec2f(0.0f, 0.0f), font) {}
- Text::Text(std::string str, vec2f position, Font &font) : font(font), str(std::move(str)) {
+ Text::Text(std::string str, vec2f position, Font &font) : font(&font), str(std::move(str)) {
mgl_text_init(&text, font.internal_font(), this->str.c_str(), position.x, position.y);
}
+ Text::Text(const Text &other) {
+ font = other.font;
+ mgl_text_init(&text, font ? font->internal_font() : nullptr, other.str.c_str(), other.text.position.x, other.text.position.y);
+ }
+
Text::~Text() {
mgl_text_deinit(&text);
}
@@ -28,6 +37,29 @@ namespace mgl {
return { text.position.x, text.position.y };
}
+ // TODO: Implement
+ FloatRect Text::get_local_bounds() {
+ return FloatRect();
+ }
+
+ void Text::set_string(std::string str) {
+ this->str = std::move(str);
+ mgl_text_set_string(&text, this->str.c_str());
+ }
+
+ const std::string& Text::get_string() const {
+ return str;
+ }
+
+ // TODO: Implement
+ vec2f Text::find_character_pos(size_t index) {
+ return vec2f();
+ }
+
+ Font* Text::get_font() {
+ return font;
+ }
+
void Text::draw(Window&) {
mgl_text_draw(mgl_get_context(), &text);
}