refactor(ui): shared drawList + header + key-decode helpers

- drawList(): scrollable list skeleton (visible window, keep-sel-in-view,
  scroll-column reserve, per-row callback, indicator). Migrate Tools, Bot,
  Nearby, Waypoints list and the three QuickMsg lists onto it; centralises the
  scroll-clamp/reserve/indicator that each had open-coded (and inconsistently).
- drawCenteredHeader(): centred title + separator, replacing the duplicated
  two-liner across ~10 screens (incl. QuickMsg, which used width()/2 spacing and
  was missed before); unifies the separator at headerH()-sepH().
- keyIsPrev()/keyIsNext() in UIScreen.h for the LEFT||PREV / RIGHT||NEXT idiom;
  applied to 6 screens, behaviour-preserving. Cancel/context-menu stay
  per-screen (they mean different things on different screens).
- rotLabel() dedups the 0/90/180/270 array in Settings.
- Unify selection-row height to lineStep()-1 (Tools/Bot matched the rest).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-06-15 21:23:00 +02:00
co-authored by Claude Opus 4.8
parent 98af868e68
commit 9da730e3b6
13 changed files with 89 additions and 123 deletions
+4 -19
View File
@@ -16,28 +16,13 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.drawTextCentered(display.width() / 2, 0, "TOOLS");
display.fillRect(0, display.headerH() - 1, display.width(), display.sepH());
display.drawCenteredHeader("TOOLS");
int item_h = display.lineStep();
int start_y = display.listStart();
int vis = display.listVisible(item_h);
if (vis < 1) vis = 1;
// Keep the selection in view (short OLED panel can't show all 6 items).
if (_sel < _scroll) _scroll = _sel;
if (_sel >= _scroll + vis) _scroll = _sel - vis + 1;
int reserve = scrollIndicatorReserve(display, ITEM_COUNT, vis);
for (int i = 0; i < vis && (_scroll + i) < ITEM_COUNT; i++) {
int idx = _scroll + i;
int y = start_y + i * item_h;
bool sel = (idx == _sel);
display.drawSelectionRow(0, y - 1, display.width() - reserve, item_h, sel);
drawList(display, ITEM_COUNT, _sel, _scroll, [&](int idx, int y, bool sel, int reserve) {
display.drawSelectionRow(0, y - 1, display.width() - reserve, display.lineStep() - 1, sel);
display.setCursor(2, y);
display.print(ITEMS[idx]);
}
drawScrollIndicator(display, start_y, vis * item_h, ITEM_COUNT, vis, _scroll);
});
return 500;
}