diff --git a/include/Cubed/ui/chat_box.hpp b/include/Cubed/ui/chat_box.hpp index ef46314..c51666c 100644 --- a/include/Cubed/ui/chat_box.hpp +++ b/include/Cubed/ui/chat_box.hpp @@ -15,6 +15,8 @@ public: ChatBox& set_scale(float scale); ChatBox& set_text_scale(float scale); + // Only the width of TextField can be set; the height is calculated + // dynamically ChatBox& set_width(float width); ChatBox& set_show_lines(int lines); ChatBox& set_spacing(float spacing); diff --git a/src/ui/chat_box.cpp b/src/ui/chat_box.cpp index 93e2b08..23dd11b 100644 --- a/src/ui/chat_box.cpp +++ b/src/ui/chat_box.cpp @@ -5,6 +5,7 @@ namespace Cubed { ChatBox::ChatBox(Widget* parent) : Widget(parent) { m_text_field = std::make_unique(this); + m_text_field->set_anchor(Anchor::BOTTOM_LEFT); } void ChatBox::add_message(ChatMessage& message) { @@ -15,7 +16,7 @@ void ChatBox::add_message(ChatMessage& message) { std::string str = std::format("<{}>{}", message.player, message.text); auto split_str = split_utf8(str, 20); - for (auto it = split_str.rbegin(); it != split_str.rend(); ++it) { + for (auto it = split_str.begin(); it != split_str.end(); ++it) { auto lable = std::make_unique