From cb3ed21d9891a67f477b3bd62fa9be706941295f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 10 Sep 2024 22:18:18 +0200 Subject: Add Text::set_max_width and Text::set_max_rows --- depends/mgl | 2 +- include/mglpp/graphics/Text.hpp | 7 ++++++- src/graphics/Text.cpp | 12 ++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/depends/mgl b/depends/mgl index b52ed40..2a91f0d 160000 --- a/depends/mgl +++ b/depends/mgl @@ -1 +1 @@ -Subproject commit b52ed4028309fd20e3955c5f1a6adce9aa12c87b +Subproject commit 2a91f0dca320f6be061224cb42ceb31c32a51b6c diff --git a/include/mglpp/graphics/Text.hpp b/include/mglpp/graphics/Text.hpp index 5126eab..84782e8 100644 --- a/include/mglpp/graphics/Text.hpp +++ b/include/mglpp/graphics/Text.hpp @@ -22,9 +22,14 @@ namespace mgl { ~Text(); void set_position(vec2f position) override; - void set_color(Color color) override; vec2f get_position() const override; + void set_color(Color color) override; + // If |max_width| is 0 then the text has no max width + void set_max_width(float max_width); + // If |max_rows| is 0 then the text can display an unlimited amount of rows + void set_max_rows(unsigned int max_rows); + FloatRect get_bounds(); void set_string(std::string str); const std::string& get_string() const; diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp index a30cdf3..e138a28 100644 --- a/src/graphics/Text.cpp +++ b/src/graphics/Text.cpp @@ -47,12 +47,20 @@ namespace mgl { mgl_text_set_position(&text, {position.x, position.y}); } + vec2f Text::get_position() const { + return { text.position.x, text.position.y }; + } + void Text::set_color(Color color) { mgl_text_set_color(&text, {color.r, color.g, color.b, color.a}); } - vec2f Text::get_position() const { - return { text.position.x, text.position.y }; + void Text::set_max_width(float max_width) { + mgl_text_set_max_width(&text, max_width); + } + + void Text::set_max_rows(unsigned int max_rows) { + mgl_text_set_max_rows(&text, max_rows); } FloatRect Text::get_bounds() { -- cgit v1.2.3