mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-31 09:18:12 +00:00
- All menu screens (Tools, Bot, Settings) now derive item height from display.getLineHeight() instead of hardcoded constants, preventing item overflow on 64px OLED displays - ToolsScreen caps rendered items to screen height so Char Test is visible - FullscreenMsgView word-wrap now uses display.getTextWidth() per candidate line instead of fixed char count, correctly handles variable-width and multi-byte UTF-8 glyphs; FS_CHARS_MAX increased 32→80 - CharTestScreen: fix v-arrow y-position; remove stale "→ blocks █" comments Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
#pragma once
|
|
// Custom screen — not part of upstream UITask.cpp
|
|
// Included by UITask.cpp just before HomeScreen.
|
|
|
|
class ToolsScreen : public UIScreen {
|
|
UITask* _task;
|
|
int _sel;
|
|
|
|
static const int ITEM_COUNT = 5;
|
|
static const char* ITEMS[ITEM_COUNT];
|
|
|
|
public:
|
|
ToolsScreen(UITask* task) : _task(task), _sel(0) {}
|
|
|
|
int render(DisplayDriver& display) override {
|
|
display.setTextSize(1);
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
display.drawTextCentered(display.width() / 2, 0, "TOOLS");
|
|
display.fillRect(0, 10, display.width(), 1);
|
|
|
|
const int lineH = display.getLineHeight();
|
|
const int itemH = lineH + 1;
|
|
const int startY = 12;
|
|
const int visible = (display.height() - startY) / itemH;
|
|
for (int i = 0; i < ITEM_COUNT && i < visible; i++) {
|
|
int y = startY + i * itemH;
|
|
bool sel = (i == _sel);
|
|
if (sel) {
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
display.fillRect(0, y - 1, display.width(), itemH);
|
|
display.setColor(DisplayDriver::DARK);
|
|
} else {
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
}
|
|
display.setCursor(0, y);
|
|
display.print(sel ? ">" : " ");
|
|
display.setCursor(display.getCharWidth() + 3, y);
|
|
display.print(ITEMS[i]);
|
|
}
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
return 500;
|
|
}
|
|
|
|
bool handleInput(char c) override {
|
|
if (c == KEY_UP && _sel > 0) { _sel--; return true; }
|
|
if (c == KEY_DOWN && _sel < ITEM_COUNT - 1) { _sel++; return true; }
|
|
if (c == KEY_CANCEL || c == KEY_CONTEXT_MENU) { _task->gotoHomeScreen(); return true; }
|
|
if (c == KEY_ENTER) {
|
|
if (_sel == 0) { _task->gotoRingtoneEditor(); return true; }
|
|
if (_sel == 1) { _task->gotoBotScreen(); return true; }
|
|
if (_sel == 2) { _task->gotoNearbyScreen(); return true; }
|
|
if (_sel == 3) { _task->gotoAutoAdvertScreen(); return true; }
|
|
if (_sel == 4) { _task->gotoCharTestScreen(); return true; }
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
const char* ToolsScreen::ITEMS[5] = { "Ringtone Editor", "Auto-Reply Bot", "Nearby Nodes", "Auto-Advert", "Char Test" };
|