aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/Text.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp
index 49829e6..953833b 100644
--- a/src/graphics/Text.cpp
+++ b/src/graphics/Text.cpp
@@ -18,9 +18,26 @@ namespace mgl {
}
Text::Text(const Text &other) {
+ *this = other;
+ }
+
+ Text& Text::operator=(const Text &other) {
font = other.font;
- mgl_text_init(&text, font ? font->internal_font() : nullptr, other.str.c_str(), other.str.size());
+ str = other.str;
+ mgl_text_init(&text, font ? font->internal_font() : nullptr, str.c_str(), str.size());
mgl_text_set_position(&text, { other.text.position.x, other.text.position.y });
+ return *this;
+ }
+
+ Text::Text(Text &&other) {
+ font = std::move(other.font);
+ str = std::move(other.str);
+ text = std::move(other.text);
+ mgl_text_init(&text, font ? font->internal_font() : nullptr, str.c_str(), str.size());
+
+ other.font = nullptr;
+ other.str.clear();
+ mgl_text_deinit(&other.text);
}
Text::~Text() {
@@ -54,6 +71,11 @@ namespace mgl {
return str;
}
+ void Text::append_string(const std::string &str) {
+ this->str += str;
+ mgl_text_set_string(&text, this->str.c_str(), this->str.size());
+ }
+
// TODO: Implement
vec2f Text::find_character_pos(size_t index) {
return vec2f();