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:
Jakub
2026-05-24 20:33:02 +02:00
parent 52a7081a13
commit d981f93e6e
9 changed files with 25 additions and 86 deletions

View File

@@ -491,13 +491,7 @@ public:
for (int i = 0; i < 3; i++) {
int y = start_y + i * item_h;
bool sel = (i == _mode_sel);
if (sel) {
display.setColor(DisplayDriver::LIGHT);
display.fillRect(0, y - 1, display.width(), item_h - 1);
display.setColor(DisplayDriver::DARK);
} else {
display.setColor(DisplayDriver::LIGHT);
}
display.drawSelectionRow(0, y - 1, display.width(), item_h - 1, sel);
display.setCursor(0, y);
display.print(sel ? ">" : " ");
display.setCursor(cw + 2, y);
@@ -527,13 +521,7 @@ public:
bool sel = (list_idx == _contact_sel);
int y = start_y + i * item_h;
if (sel) {
display.setColor(DisplayDriver::LIGHT);
display.fillRect(0, y - 1, display.width(), item_h - 1);
display.setColor(DisplayDriver::DARK);
} else {
display.setColor(DisplayDriver::LIGHT);
}
display.drawSelectionRow(0, y - 1, display.width(), item_h - 1, sel);
ContactInfo c;
if (the_mesh.getContactByIdx(mesh_idx, c)) {
@@ -576,13 +564,7 @@ public:
bool sel = (list_idx == _channel_sel);
int y = start_y + i * item_h;
if (sel) {
display.setColor(DisplayDriver::LIGHT);
display.fillRect(0, y - 1, display.width(), item_h - 1);
display.setColor(DisplayDriver::DARK);
} else {
display.setColor(DisplayDriver::LIGHT);
}
display.drawSelectionRow(0, y - 1, display.width(), item_h - 1, sel);
display.setCursor(0, y);
display.print(sel ? ">" : " ");
ChannelDetails ch;
@@ -855,13 +837,7 @@ public:
bool sel = (idx == _msg_sel);
int y = start_y + i * item_h;
if (sel) {
display.setColor(DisplayDriver::LIGHT);
display.fillRect(0, y - 1, display.width(), item_h - 1);
display.setColor(DisplayDriver::DARK);
} else {
display.setColor(DisplayDriver::LIGHT);
}
display.drawSelectionRow(0, y - 1, display.width(), item_h - 1, sel);
display.setCursor(0, y);
display.print(sel ? ">" : " ");