From 2136e959d40f1f50a27c49c6fe65cc5fd1aceb67 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:35:51 +0200 Subject: [PATCH] fix(ui): gap below header separator, one method everywhere Content drawn under the title separator touched the line on every standard screen, because listStart() == headerH() (the row right after the separator). Graphical screens worked around it with a hand-rolled hdr+2. Bake a 2px breathing gap into listStart() so every list gains it at once, and switch the screens that hand-rolled the offset (Compass, Nav, Nearby detail) to listStart() so the content top is computed the same way everywhere. Co-Authored-By: Claude Opus 4.8 --- examples/companion_radio/ui-new/CompassScreen.h | 3 +-- examples/companion_radio/ui-new/NavView.h | 2 +- examples/companion_radio/ui-new/NearbyScreen.h | 4 ++-- src/helpers/ui/DisplayDriver.h | 5 ++++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/ui-new/CompassScreen.h b/examples/companion_radio/ui-new/CompassScreen.h index 163dd91c..74611973 100644 --- a/examples/companion_radio/ui-new/CompassScreen.h +++ b/examples/companion_radio/ui-new/CompassScreen.h @@ -33,7 +33,6 @@ public: display.setColor(DisplayDriver::LIGHT); display.drawCenteredHeader("COMPASS"); - const int hdr = display.headerH(); const int cx = display.width() / 2; const int ch = display.getLineHeight(); const int cw = display.getCharWidth(); @@ -41,7 +40,7 @@ public: display.setTextSize(2); const int bigH = display.getLineHeight(); display.setTextSize(1); - const int top = hdr + 2; + const int top = display.listStart(); const int readout_y = display.height() - bigH - 1; // size-2 readout baseline const int mid = (top + readout_y) / 2; diff --git a/examples/companion_radio/ui-new/NavView.h b/examples/companion_radio/ui-new/NavView.h index ff8c67e9..10bea16e 100644 --- a/examples/companion_radio/ui-new/NavView.h +++ b/examples/companion_radio/ui-new/NavView.h @@ -37,7 +37,7 @@ inline void draw(DisplayDriver& d, geo::fmtDist(dist, sizeof(dist), dist_km, imperial); const int step = d.lineStep(); - int y = hdr + 2; + int y = d.listStart(); // Distance — emphasised at size 2. d.setTextSize(2); diff --git a/examples/companion_radio/ui-new/NearbyScreen.h b/examples/companion_radio/ui-new/NearbyScreen.h index db9b9300..961a84d4 100644 --- a/examples/companion_radio/ui-new/NearbyScreen.h +++ b/examples/companion_radio/ui-new/NearbyScreen.h @@ -404,7 +404,7 @@ class NearbyScreen : public UIScreen { // ── detail rendering ────────────────────────────────────────────────────────── void renderStoredDetail(DisplayDriver& display) { const Entry& e = _entries[_sel]; - const int hdr = display.headerH(); + const int hdr = display.listStart(); // content top (gap below the header separator) display.drawInvertedHeader(e.name); int step = display.lineStep(); @@ -434,7 +434,7 @@ class NearbyScreen : public UIScreen { void renderScanDetail(DisplayDriver& display) { const Entry& e = _entries[_sel]; - const int hdr = display.headerH(); + const int hdr = display.listStart(); // content top (gap below the header separator) char label[32]; if (e.name[0]) { strncpy(label, e.name, 31); label[31] = '\0'; } diff --git a/src/helpers/ui/DisplayDriver.h b/src/helpers/ui/DisplayDriver.h index e1eb1c4f..47220db1 100644 --- a/src/helpers/ui/DisplayDriver.h +++ b/src/helpers/ui/DisplayDriver.h @@ -39,7 +39,10 @@ public: // Use these instead of hardcoded pixel values so layouts adapt to any display. int lineStep() const { return getLineHeight() + 2; } // row pitch: text + gap int headerH() const { return getLineHeight() + 3; } // title bar height - int listStart() const { return headerH(); } // y where list items begin + // y where list items begin: a 2px breathing gap below the header separator so + // the first row doesn't touch the line (matches the hand-rolled hdr+2 used by + // the graphical screens). + int listStart() const { return headerH() + 2; } int listVisible(int itemH) const { return (height() - listStart()) / itemH; } int listVisible() const { return listVisible(lineStep()); } // x where a right-side value column starts (leaves ~8 chars for the value)