From 4a2bfe59629bb1d78ef6f696a49abc3c98f82c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Benito=20Lamata?= Date: Thu, 19 Dec 2024 18:46:40 +0100 Subject: [PATCH] Center text in field --- DMI/graphics/component.cpp | 2 +- DMI/messages/messages.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DMI/graphics/component.cpp b/DMI/graphics/component.cpp index a2024bed..5bd0d0c6 100755 --- a/DMI/graphics/component.cpp +++ b/DMI/graphics/component.cpp @@ -208,7 +208,7 @@ std::unique_ptr Component::getTextUnique(const string &text, float t->alignment = align; t->aspect = aspect; int v = text.find('\n'); - t->tex = getTextGraphic(text, size, col, aspect, align, width); + t->tex = getTextGraphic(text, size, col, aspect, align&(LEFT|RIGHT), width); float sx = t->tex == nullptr ? 0 : t->tex->size().first; float sy = t->tex == nullptr ? 0 : t->tex->size().second; if (align & UP) y = y + sy / 2; diff --git a/DMI/messages/messages.cpp b/DMI/messages/messages.cpp index 2c056f33..108befcf 100755 --- a/DMI/messages/messages.cpp +++ b/DMI/messages/messages.cpp @@ -152,9 +152,9 @@ void updateMessages() { if(!m.shown && (m.firstGroup || m.ack)) playSinfo(); m.shown = true; - textArea.addText(date, 2, 4 + (line-current)*20, 10, m.fgColor, UP | LEFT, m.firstGroup); + textArea.addText(date, 2, 10 + (line-current)*20 - textArea.sy / 2, 10, m.fgColor, LEFT, m.firstGroup); } - textArea.addText(text.substr(0, last), 2 + clock_size.first, 2 + (line-current)*20, 12, m.fgColor, UP | LEFT, m.firstGroup); + textArea.addText(text.substr(0, last), 2 + clock_size.first, 9 + (line-current)*20 - textArea.sy / 2, 12, m.fgColor, LEFT, m.firstGroup); } ++line; while (last != text.size() && text[last] == ' ') last++;