refactor: replace all hardcoded pixel positions with layout helpers

Add lineStep(), headerH(), listStart(), listVisible(), valCol() to
DisplayDriver so layout derives from getLineHeight() instead of fixed
OLED constants. Refactor all screens (SettingsScreen, NearbyScreen,
FullscreenMsgView, QuickMsgScreen, BotScreen, DashboardConfigScreen,
AutoAdvertScreen, RingtoneEditorScreen) and all HomeScreen pages plus
the lock screen and splash screen in UITask.cpp.

On OLED (lh=8) positions are unchanged; on landscape e-ink (lh=16) all
text and widgets now scale correctly to the 250×122 display.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-22 18:05:09 +02:00
co-authored by Claude Sonnet 4.6
parent 18867a85c0
commit 744f263932
10 changed files with 358 additions and 287 deletions
@@ -82,7 +82,8 @@ struct FullscreenMsgView {
}
}
const int header_h = to_nick[0] ? 20 : 10;
const int cw = display.getCharWidth();
const int header_h = to_nick[0] ? (lineH * 2 + 4) : (lineH + 2);
const int startY = header_h + 2;
const int visible = (display.height() - startY - lineH) / lineH;
@@ -94,7 +95,7 @@ struct FullscreenMsgView {
char trans_nick[32], to_label[36];
display.translateUTF8ToBlocks(trans_nick, to_nick, sizeof(trans_nick));
snprintf(to_label, sizeof(to_label), "To: %s", trans_nick);
display.drawTextEllipsized(2, 11, display.width() - 4, to_label);
display.drawTextEllipsized(2, lineH + 3, display.width() - 4, to_label);
}
display.setColor(DisplayDriver::LIGHT);
@@ -111,16 +112,16 @@ struct FullscreenMsgView {
}
if (scroll > 0) {
display.setColor(DisplayDriver::DARK);
display.fillRect(display.width() - 6, startY, 6, lineH);
display.fillRect(display.width() - cw, startY, cw, lineH);
display.setColor(DisplayDriver::LIGHT);
display.setCursor(display.width() - 6, startY);
display.setCursor(display.width() - cw, startY);
display.print("^");
}
if (scroll < max_scroll) {
display.setColor(DisplayDriver::DARK);
display.fillRect(display.width() - 6, startY + (visible - 1) * lineH, 6, lineH);
display.fillRect(display.width() - cw, startY + (visible - 1) * lineH, cw, lineH);
display.setColor(DisplayDriver::LIGHT);
display.setCursor(display.width() - 6, startY + (visible - 1) * lineH);
display.setCursor(display.width() - cw, startY + (visible - 1) * lineH);
display.print("v");
}
const int nav_y = display.height() - lineH;
@@ -129,7 +130,7 @@ struct FullscreenMsgView {
display.print("<");
}
if (has_prev) {
display.setCursor(display.width() - 6, nav_y);
display.setCursor(display.width() - cw, nav_y);
display.print(">");
}
return 2000;