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( +