fix(ui): favourites tile — reserve room for unread badge, share baseline with name

The badge was rendered at cy + 1 while the name centered around cy + ~8;
on OLED with line_h = 8 the two ended up touching, and the name's
drawTextEllipsized used the full cell width so any "..." would land
under the digit anyway.

Compute the badge width up-front, subtract it (plus a 3 px gap) from
the name's max width, and render both on the same baseline (name_y).
The name now shortens to "Nam…" before the badge instead of running
through it. E-ink with its wider tiles already had room, so this is a
strict improvement there too.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-25 13:30:12 +02:00
parent 8c8f60391c
commit 0d1fd345a8

View File

@@ -860,19 +860,26 @@ public:
char name[24];
if (found) display.translateUTF8ToBlocks(name, ci.name, sizeof(name));
else strncpy(name, "(gone)", sizeof(name) - 1), name[sizeof(name) - 1] = '\0';
int name_y = cy + (cell_h - line_h) / 2;
display.drawTextEllipsized(cx + 2, name_y, cell_w - 4, name);
// Reserve space for the unread badge so the name's ellipsis lands
// before it instead of underneath. Badge and name share one baseline.
char badge[5] = "";
int bw = 0;
if (found) {
uint8_t unread = _task->getDMUnread(ci.id.pub_key);
if (unread > 0) {
char badge[5];
snprintf(badge, sizeof(badge), "%d", unread);
int bw = display.getTextWidth(badge);
display.setCursor(cx + cell_w - bw - 2, cy + 1);
display.print(badge);
bw = display.getTextWidth(badge) + 3; // badge + 3 px gap
}
}
int name_y = cy + (cell_h - line_h) / 2;
int name_max_w = cell_w - 4 - bw;
if (name_max_w < 6) name_max_w = 6;
display.drawTextEllipsized(cx + 2, name_y, name_max_w, name);
if (badge[0]) {
display.setCursor(cx + cell_w - (bw - 3) - 2, name_y);
display.print(badge);
}
} else {
int plus_y = cy + (cell_h - line_h) / 2;
display.drawTextCentered(cx + cell_w / 2, plus_y, "+");