mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 03:34:35 +00:00
Limit text string length to fit Text widget rectangle (#1370)
* Limit string length to fit Text rectangle * Update ui_widget.cpp
This commit is contained in:
parent
ff7a9d10cb
commit
e74a9f3b41
@ -365,9 +365,13 @@ void Text::set(std::string_view value) {
|
||||
void Text::paint(Painter& painter) {
|
||||
const auto rect = screen_rect();
|
||||
auto s = has_focus() ? style().invert() : style();
|
||||
auto max_len = (unsigned)rect.width() / s.font.char_width();
|
||||
|
||||
painter.fill_rectangle(rect, s.background);
|
||||
|
||||
if (text.length() > max_len)
|
||||
text.resize(max_len);
|
||||
|
||||
painter.draw_string(
|
||||
rect.location(),
|
||||
s,
|
||||
|
Loading…
Reference in New Issue
Block a user