Public Access
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
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
#include "key_event.h"
|
|
#include "key_help.h"
|
|
|
|
namespace roro {
|
|
|
|
class Canvas; // provided by the widget kit
|
|
|
|
// A foreground, user-facing program (see CONTEXT.md). Exactly one App is on screen at a time.
|
|
class App {
|
|
public:
|
|
virtual ~App() = default;
|
|
|
|
virtual void onEnter() {}
|
|
virtual void onExit() {}
|
|
|
|
// Return true if the key was consumed. An unconsumed Back leaves the App.
|
|
virtual bool onKey(const KeyEvent& event) {
|
|
(void)event;
|
|
return false;
|
|
}
|
|
|
|
// True while the App is editing text: the arrow keys then type ; . , / and need Fn to move.
|
|
virtual bool textEntryActive() const { return false; }
|
|
|
|
// The keys that work right now, for the help panel (Fn+h): the App's own, in the state it's
|
|
// in. Back, Home and the arrows are added for it. No screen names keys any other way.
|
|
virtual void help(std::vector<KeyHelp>& out) const { (void)out; }
|
|
// What the panel is titled with, when the App's name isn't enough ("Notes: editor").
|
|
virtual const char* helpTitle() const { return nullptr; }
|
|
|
|
// Called every main-loop pass while in the foreground (e.g. to refresh live values).
|
|
virtual void update(uint32_t nowMs) { (void)nowMs; }
|
|
|
|
virtual void draw(Canvas& canvas) = 0;
|
|
|
|
void requestRedraw() { redraw_ = true; }
|
|
|
|
bool consumeRedraw() {
|
|
bool r = redraw_;
|
|
redraw_ = false;
|
|
return r;
|
|
}
|
|
|
|
private:
|
|
bool redraw_ = false;
|
|
};
|
|
|
|
} // namespace roro
|