From 0d1fd345a8737c0fef6ead1a81516a19a7702a54 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Mon, 25 May 2026 13:30:12 +0200 Subject: [PATCH] =?UTF-8?q?fix(ui):=20favourites=20tile=20=E2=80=94=20rese?= =?UTF-8?q?rve=20room=20for=20unread=20badge,=20share=20baseline=20with=20?= =?UTF-8?q?name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- examples/companion_radio/ui-new/UITask.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 57634c24..2341e060 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -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, "+");