mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-30 08:48:12 +00:00
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:
@@ -31,6 +31,16 @@ public:
|
||||
virtual int getCharWidth() const { return 6; } // typical character advance width (px)
|
||||
virtual int getLineHeight() const { return 8; } // pixel rows per text line
|
||||
virtual void setLemonFont(bool) { } // no-op; overridden by displays that support Lemon
|
||||
|
||||
// Layout helpers — derived from font metrics and screen size.
|
||||
// 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
|
||||
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)
|
||||
int valCol() const { return width() - getCharWidth() * 8; }
|
||||
virtual void drawTextCentered(int mid_x, int y, const char* str) { // helper method (override to optimise)
|
||||
int w = getTextWidth(str);
|
||||
setCursor(mid_x - w/2, y);
|
||||
|
||||
Reference in New Issue
Block a user