From 368f7320e6b86346dd59f74837d8cc9f79f4c0f2 Mon Sep 17 00:00:00 2001 From: explodi Date: Wed, 25 Nov 2026 14:18:29 +0100 Subject: [PATCH] A face the program does not hold yet is read off the UI's thread, messages take default arguments, and a large SVG draws in tiles - With `Ui::Options::holdsAsset`, a face file the program does not hold in memory is read on the UI's reading thread, as pictures already are, and handed to the view when it arrives (`View::faceArrived`). Its text lays out empty until then, and the fallback faces after it are not read meanwhile. - A vector picture that outgrows an atlas page goes into the atlas as tiles. - Text that may break anywhere shrinks to its widest character. - `build_hermes` starts a build tree afresh when its CMake cache names a tool that is gone. - Kit: `I18n.setDefaultArgument` gives every message an argument its call does not pass, and the i18n snapshot is now an object (language and defaults). `Instrument` takes an `anchor`, `Button` a `hitSlop`; `SeverityTile` is exported; an empty capitalized field's placeholder keeps its own case. - Tokens: a dead mark shows on the dark chrome's key; `bureau-print-feed` and four `line-*` chart colours are new; `bureau-fast-blink` is gone. --- docs/integrating.md | 10 ++--- include/bureau/ui.h | 10 ++--- kit/Bureau.tsx | 8 +++- kit/Button.test.tsx | 11 +++++ kit/Instrument.test.tsx | 85 +++++++++++++++++++++++++++++++++++ kit/Instrument.tsx | 28 +++++++----- kit/MessageBox.tsx | 4 +- kit/TextField.test.tsx | 33 ++++++++++++++ kit/TextField.tsx | 7 ++- kit/i18n/i18n.test.ts | 56 ++++++++++++++++++++++++ kit/i18n/i18n.ts | 78 ++++++++++++++++++++++++++++----- kit/tokens.test.ts | 16 +++++++ kit/tokens.ts | 37 ++++++++++------ src/js/ui.cpp | 32 +++++++++----- src/text/paragraph.cpp | 45 ++++++++++++++++--- src/text/paragraph.h | 41 +++++++++++++---- src/view/view.cpp | 10 ++++- src/view/view.h | 16 +++++-- src/view/view_paint.cpp | 45 ++++++++++++------- tests/paragraph_test.cpp | 90 ++++++++++++++++++++++++++++++++++++++ tests/view_test.cpp | 52 +++++++++++++++++++++- tools/build_hermes.test.ts | 34 ++++++++++++++ tools/build_hermes.ts | 26 ++++++++++- 23 files changed, 671 insertions(+), 103 deletions(-) create mode 100644 kit/TextField.test.tsx create mode 100644 tools/build_hermes.test.ts diff --git a/docs/integrating.md b/docs/integrating.md index ba8d518..7828fdd 100644 --- a/docs/integrating.md +++ b/docs/integrating.md @@ -103,11 +103,11 @@ set_target_properties(game PROPERTIES BUILD_RPATH "${BUREAU_HERMES_FRAMEWORKS}") `Options::readAsset` also answers for Bureau's own `assets/`, its fonts and icons, so ship that folder among your game's assets. -A game that reads its pictures into memory ahead of time says which it holds with -`Options::holdsAsset`. A picture it does not hold yet is then read on a thread of -the UI's own and drawn once it arrives, so a slow disk does not hold the interface. -Until then the view lays the picture out at no size: give a picture whose place -matters its `width` and `height`. +A game that reads its pictures and typefaces into memory ahead of time says which it +holds with `Options::holdsAsset`. A file it does not hold yet is then read on a thread +of the UI's own and drawn once it arrives, so a slow disk does not hold the interface. +Until then the view lays the picture out at no size and sets no text in the face: give +a picture whose place matters its `width` and `height`. The bundler knows Bureau's import names by itself. For your editor and type checker, set `bureau/kit/`, `bureau/primitives`, `bureau/host`, `bureau/jsx-runtime`, diff --git a/include/bureau/ui.h b/include/bureau/ui.h index df251de..774b62b 100644 --- a/include/bureau/ui.h +++ b/include/bureau/ui.h @@ -58,13 +58,13 @@ class Ui { /** A file the UI asks for by its path under the game's assets (`/fonts/…`, * pictures); nothing when there is none. On the UI's thread for the * view's faces and pictures, and on a thread of the UI's own for what - * TypeScript reads (`assetText`, `assetBytes`) and pictures `holdsAsset` - * does not hold, so it must be safe to call from both. */ + * TypeScript reads (`assetText`, `assetBytes`) and the faces and pictures + * `holdsAsset` does not hold, so it must be safe to call from both. */ std::function(const std::string& path)> readAsset; /** Whether `readAsset` answers `path` from memory, without waiting on a - * disk. Given, a picture it does not hold is read on the UI's own reading - * thread, and the view lays out and paints without it until it arrives. - * Empty: the view reads each picture on the UI's thread, where it first + * disk. Given, a picture or a face it does not hold is read on the UI's own + * reading thread, and the view lays out and paints without it until it + * arrives. Empty: the view reads each on the UI's thread, where it first * lays it out. Called on the UI's thread. */ std::function holdsAsset; /** The window, in points, and its device pixels per point. */ diff --git a/kit/Bureau.tsx b/kit/Bureau.tsx index df760c5..32d0aac 100644 --- a/kit/Bureau.tsx +++ b/kit/Bureau.tsx @@ -526,6 +526,9 @@ export type ButtonProps = { /** A stop on the pad's walk through its window, in `navigationGrid`. */ navigable?: boolean; navigationGrid?: string; + /** How far past its face a finger still presses it, in points: a small + * key with room around it. Unsaid, the size's own. */ + hitSlop?: number; /** False: the pad and the host focus it, Tab passes it by. */ tabStop?: boolean; /** @@ -1055,6 +1058,7 @@ function Key( onPointerEnter, onHoverChange, onFocusChange, + hitSlop, children, ...rest }: ButtonProps & { @@ -1196,13 +1200,13 @@ function Key( disabled={disabled} pressed={pressed} held={held || inProgress} - hitSlop={isClose + hitSlop={hitSlop ?? (isClose ? CLOSE_KEY_INSET : size === "compact" ? 4 : size === "small" ? 2 - : undefined} + : undefined)} focusable feedback={sound} opacity={withheld ? 0.6 : undefined} diff --git a/kit/Button.test.tsx b/kit/Button.test.tsx index c2cab96..88bd8db 100644 --- a/kit/Button.test.tsx +++ b/kit/Button.test.tsx @@ -50,6 +50,17 @@ Deno.test("a small destructive mark has a 33px face and an expanded hit area", ( ); }); +Deno.test("a key given a hit slop reaches that far past its face", () => { + assertEquals( + drawn( +