mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 10:46:12 +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:
co-authored by
Claude Sonnet 4.6
parent
52a7081a13
commit
d981f93e6e
@@ -109,13 +109,7 @@ struct KeyboardWidget {
|
||||
if (caps && ch >= 'a' && ch <= 'z') ch = ch - 'a' + 'A';
|
||||
char ch_buf[2] = { ch == ' ' ? '_' : ch, '\0' };
|
||||
int cx = c * cell_w;
|
||||
if (sel) {
|
||||
display.setColor(DisplayDriver::LIGHT);
|
||||
display.fillRect(cx, y - 1, cell_w - 1, cell_h);
|
||||
display.setColor(DisplayDriver::DARK);
|
||||
} else {
|
||||
display.setColor(DisplayDriver::LIGHT);
|
||||
}
|
||||
display.drawSelectionRow(cx, y - 1, cell_w - 1, cell_h, sel);
|
||||
display.setCursor(cx + (cell_w - cw) / 2, y);
|
||||
display.print(ch_buf);
|
||||
}
|
||||
@@ -127,13 +121,7 @@ struct KeyboardWidget {
|
||||
bool sel = (row == KB_ROWS_CHAR && col == i);
|
||||
bool active = (i == 0 && caps);
|
||||
int sx = i * spec_w;
|
||||
if (sel || active) {
|
||||
display.setColor(DisplayDriver::LIGHT);
|
||||
display.fillRect(sx, spec_y - 1, spec_w - 1, cell_h);
|
||||
display.setColor(DisplayDriver::DARK);
|
||||
} else {
|
||||
display.setColor(DisplayDriver::LIGHT);
|
||||
}
|
||||
display.drawSelectionRow(sx, spec_y - 1, spec_w - 1, cell_h, sel || active);
|
||||
int tw = display.getTextWidth(spec[i]);
|
||||
display.setCursor(sx + (spec_w - tw) / 2, spec_y);
|
||||
display.print(spec[i]);
|
||||
|
||||
Reference in New Issue
Block a user