Files
roro9stack/src/ui/screen.cpp
T
twislaandClaude Opus 5.5 7fe8b3d22a
CI / build (pull_request) Successful in 7m22s
Site / build (pull_request) Successful in 14s
Help: Fn+h lists the keys of the screen you're on, and no screen names its keys any more (#69)
Fn+h on any screen, text fields included, and ? outside Text Entry, open a
panel over the content area: the screen's own keys, then the ones that work
everywhere. Every App declares its keys for the state it is in (pages,
viewers, dialogs and text fields answer for themselves); the App manager
opens the panel and takes every key while it is open.

About 30 hint lines are gone, from every App. What stays on a screen is
state. The first-start Setup keeps its hints and teaches the key; a device
set up before gets one Toast, once. The guide and the FAQ open with it.
`key help` over the consoles.

476 host tests (8 new). Checked on the device with key help and screenshots:
the Launcher, all nine Apps and several of their states. 8.5 KB of flash and
40 bytes of static RAM. Decisions Q196 to Q203 in docs/milestones/U1.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
2026-10-07 01:29:51 +02:00

47 lines
1.7 KiB
C++

#include "screen.h"
#include <M5Cardputer.h>
#include "fonts.h"
namespace roro {
bool Screen::begin() {
canvas_.setColorDepth(8); // RGB332: saves 32 KB of RAM (M1 Q46); theme colours are converted
canvas_.setPsram(false);
return canvas_.createSprite(theme::kWidth, theme::kHeight) != nullptr;
}
void Screen::render(AppManager& apps, const StatusInfo& status, const Toast* toast) {
canvas_.fillSprite(theme::kBackground);
const auto& area = theme::kContent;
canvas_.setClipRect(area.x, area.y, area.w, area.h);
apps.foreground().draw(canvas_);
if (apps.help().isOpen()) widgets::help(canvas_, apps.help()); // over the App, under the Status Bar
canvas_.clearClipRect();
widgets::statusBar(canvas_, status);
if (toast) widgets::toast(canvas_, *toast);
canvas_.pushSprite(&M5Cardputer.Display, 0, 0);
}
void Screen::renderUpdate(const std::string& title, const std::string& detail, int percent) {
canvas_.fillSprite(theme::kBackground);
canvas_.setTextDatum(top_center);
canvas_.setFont(&fonts::bold);
canvas_.setTextColor(theme::kAccent);
canvas_.drawString(title.c_str(), theme::kWidth / 2, 34);
canvas_.setFont(&fonts::body);
canvas_.setTextColor(theme::kText);
canvas_.drawString(detail.c_str(), theme::kWidth / 2, 56);
if (percent >= 0) {
const int x = 20, y = 82, w = theme::kWidth - 40, h = 12;
canvas_.drawRect(x, y, w, h, theme::kMuted);
canvas_.fillRect(x + 1, y + 1, (w - 2) * percent / 100, h - 2, theme::kAccent);
canvas_.drawString((std::to_string(percent) + "%").c_str(), theme::kWidth / 2, y + 18);
}
canvas_.setTextDatum(top_left);
canvas_.pushSprite(&M5Cardputer.Display, 0, 0);
}
} // namespace roro