Conflicts resolved so that next's changes and this branch's fixes both hold: - keys: next's unfocused-canvas state claims join the key stage's framework claims; the canvas's declared claims stay the host's (egui keeps their presses). - overlay: the app's own modal (`FrameInput::app_modal`) joins next's modal stack at the frame it first showed in. - docking: the tab-pick trial moves key focus into the group with Tab, since a click on a dock tab leaves key focus where it is.
craft-host
The services every Craft library feature reads from the app: who the app is (AppInfo, and its
icon), the catalogs and current language, settings sections, command words and background jobs. The app builds
one Host at startup and installs it on the egui context; features read it with Host::of(ui) and
never take services as parameters.
let host = craft_host::Host::builder(craft_host::AppInfo { id: "photocraft", name: "PhotoCraft", version: "1.0" })
.icon_png(include_bytes!("../assets/icon-128.png"))
.i18n(i18n)
.settings(settings)
.build();
host.install(&ctx); // feature `ui`
Every service has a default, so a test writes Host::builder(app).install(ctx):
| Service | Trait | Default |
|---|---|---|
| Settings sections | SectionStore |
MemorySections |
| Command words | Commands |
NoCommands (English labels) |
| Background work | Jobs |
ThreadJobs; InlineJobs on wasm32 |
| Catalogs | craft_i18n::I18n |
none (English) |
queue::JobQueue runs prioritised background work with one job per key on the host's Jobs.
Stories and tests step it with ManualJobs, which keeps each job until run_next runs it.
Host::install_scoped installs a host until the returned HostScope drops, then puts back the
one installed before. A story swaps in a fake service this way for the time it draws.
Boundaries
- Depends on
craft-i18n,serdeandtomlonly. Implementations depend on this crate:craft-settingsimplementsSectionStore,craft-keymapimplementsCommands. - Feature
uiadds egui forinstallandof. It never depends oncraft-ui. - A settings section is a serde struct saved as one TOML table under
Section::KEY.