mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 23:08:11 +00:00
refactor(ui): drawSelectionRow helper for the 5-line invert/restore pattern
Eight screens repeated the same if/else block to invert the row background for selected items. Add DisplayDriver::drawSelectionRow that sets LIGHT, optionally fills the rect, and leaves the colour as DARK when sel (so the caller's text renders inverted). 61 lines removed across SettingsScreen, KeyboardWidget (cells + special row), ToolsScreen, DashboardConfigScreen, BotScreen, RingtoneEditorScreen (note slots + menu), NearbyScreen, QuickMsgScreen (4 list views). Card-style rows (QuickMsg hist, NearbyScreen discover, RingtoneEditor notes display) keep their original drawRect/partial-fill outline for unselected — they don't match the simple-invert pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -150,6 +150,18 @@ public:
|
||||
translateUTF8Static(dest, src, dest_size);
|
||||
}
|
||||
|
||||
// Common selection-row pattern: when sel, fills (x,y,w,h) with ink and sets
|
||||
// colour to DARK so the next text render appears inverted; when not sel,
|
||||
// just sets ink colour to LIGHT. Replaces the 5-line if/else copy-paste
|
||||
// present in every list-style screen.
|
||||
void drawSelectionRow(int x, int y, int w, int h, bool sel) {
|
||||
setColor(LIGHT);
|
||||
if (sel) {
|
||||
fillRect(x, y, w, h);
|
||||
setColor(DARK);
|
||||
}
|
||||
}
|
||||
|
||||
// Advance a UTF-8 pointer by one codepoint, returning the decoded value.
|
||||
// Invalid sequences return 0xFFFD and consume trailing continuation bytes.
|
||||
static uint32_t decodeCodepoint(const uint8_t*& p) {
|
||||
|
||||
Reference in New Issue
Block a user