Add widget kit, input layer with Compose Key, Launcher and demo apps

Steps 5 and 6 of M0.
- lib/ui (host-tested): ListModel, LineEditor (UTF-8, byte-limited),
  wrapText, ToastQueue, DialogModel
- lib/input (host-tested): KeyMapper turns keyboard state into logical
  keys (Fn arrows, ` Back, Fn+` Home) and composes accents with opt
- src/ui: off-screen 16-bit frame pushed in one transfer (fixes the
  flicker), Status Bar, list, text, line editor, dialog, Toast widgets,
  Notifier (Toast + beep + LED), vendored public-domain Latin-1 fonts
- Apps: minimal Launcher, Widget demo, Diagnostics (SD erase now
  behind a confirmation dialog)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-02 10:35:48 +02:00
co-authored by Claude Opus 5.5
parent 36ebd23417
commit 879cb0d0b6
39 changed files with 2119 additions and 92 deletions
+53
View File
@@ -0,0 +1,53 @@
#pragma once
#include <functional>
#include <string>
#include <vector>
#include "canvas.h"
#include "dialog_model.h"
#include "line_editor.h"
#include "list_model.h"
#include "text_wrap.h"
#include "theme.h"
#include "toast_queue.h"
namespace roro {
struct StatusInfo {
std::string title;
int batteryPercent = -1; // -1: unknown
std::string clock = "--:--";
bool sdPresent = false;
int sdLevel = 0; // StorageMonitor level
char compose = 0; // pending Compose Key state
bool operator==(const StatusInfo& o) const {
return title == o.title && batteryPercent == o.batteryPercent && clock == o.clock &&
sdPresent == o.sdPresent && sdLevel == o.sdLevel && compose == o.compose;
}
bool operator!=(const StatusInfo& o) const { return !(*this == o); }
};
namespace widgets {
// Width in pixels of text in the body font.
MeasureText bodyMeasure(Canvas& canvas);
void statusBar(Canvas& c, const StatusInfo& info);
// A selectable list; `label(i)` gives row i's text.
void list(Canvas& c, const ListModel& model, theme::Rect area, const std::function<std::string(int)>& label);
// Pre-wrapped lines starting at `firstLine`, with a scroll indicator when they don't all fit.
void textLines(Canvas& c, const std::vector<std::string>& lines, int firstLine, theme::Rect area);
// One line of editable text with a cursor; scrolls horizontally to keep the cursor visible.
void lineEditor(Canvas& c, const LineEditor& editor, theme::Rect area);
void dialog(Canvas& c, const std::string& title, const std::string& message, const DialogModel& model);
void toast(Canvas& c, const Toast& t);
} // namespace widgets
} // namespace roro