From 29627a93c68b9f3927ee9d1097ed3266777b6a0b Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 7 Nov 2021 06:33:07 +0100 Subject: Fix exit being called when closing window, respond to wm ping, add is_open function to window --- src/graphics/Text.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/graphics/Text.cpp') diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp index b3a32da..49829e6 100644 --- a/src/graphics/Text.cpp +++ b/src/graphics/Text.cpp @@ -7,19 +7,19 @@ extern "C" { namespace mgl { Text::Text() : font(nullptr) { - mgl_text_init(&text, nullptr, nullptr, 0, nullptr); + mgl_text_init(&text, nullptr, nullptr, 0); } 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)) { - mgl_text_init(&text, font.internal_font(), this->str.c_str(), this->str.size(), nullptr); + mgl_text_init(&text, font.internal_font(), this->str.c_str(), this->str.size()); mgl_text_set_position(&text, { 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.str.size(), nullptr); + mgl_text_init(&text, font ? font->internal_font() : nullptr, other.str.c_str(), other.str.size()); mgl_text_set_position(&text, { other.text.position.x, other.text.position.y }); } @@ -39,9 +39,10 @@ namespace mgl { return { text.position.x, text.position.y }; } - // TODO: Implement - FloatRect Text::get_local_bounds() { - return FloatRect(); + FloatRect Text::get_bounds() const { + mgl_vec2f bounds = mgl_text_get_bounds(&text); + FloatRect rect(get_position(), { bounds.x, bounds.y }); + return rect; } void Text::set_string(std::string str) { -- cgit v1.2.3