kui-native 0.1.0-alpha.48

Batteries-included kui runner: winit + wgpu around a Core, App trait, widgets
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
[package]
name = "kui-native"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
keywords.workspace = true
categories.workspace = true
description = "Batteries-included kui runner: winit + wgpu around a Core, App trait, widgets"
readme = "README.md"
publish = ["crates-io", "drydock9"]

[dependencies]
kui-core.workspace = true
kui-wgpu.workspace = true
winit.workspace = true
pollster.workspace = true
# 3.6: the version F84's `exclude_from_*` writes were built and tested
# against — a bare "3" let a resolver pick one without them (RG35).
arboard = "3.6"
# Platform accessibility (UIA / NSAccessibility / AT-SPI) behind AccessKit;
# see docs/adr/0001-accessibility-as-data.md.
accesskit = { version = "0.25", optional = true }
accesskit_winit = { version = "0.34", optional = true }
# The audio device behind the core's audio commands (feature `audio`, on by
# default). Default features are trimmed: no realtime-priority dbus
# (libdbus), no streaming formats — decoding covers wav/ogg/mp3/flac.
kira = { version = "0.12", default-features = false, features = ["cpal", "mp3", "ogg", "vorbis", "flac", "wav", "pcm"], optional = true }
# The platform's Open / Save / folder dialogs (backlog C51), shown by the
# runner when an app asks. On Linux through the XDG desktop portal (no GTK).
rfd = { version = "0.17", default-features = false, features = ["xdg-portal"], optional = true }
# The wallpaper a `Tinted` backdrop draws where the OS has no material
# (`mod ground`, backlog F126): decoded once, off the frame. The version
# arboard already builds, with the formats wallpapers come in.
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "webp", "gif"] }

# The examples' devtools (docs/adr/0021): the dock, the CLI and the
# headless drive every example under examples/rust runs inside. A
# dev-dependency, so the published crate carries none of it; the cycle
# (it depends on this crate) is the kind cargo allows for dev-dependencies.
[dev-dependencies]
kui-devtools.workspace = true
# A GIF frame placed off the origin, for `decode.rs`'s compositing test:
# `image`'s own encoder writes every frame at (0, 0). The version `image` decodes with.
gif = "0.14"

[features]
default = ["audio", "accesskit", "derive", "dialogs"]
# Play sounds through kira/cpal. Off: audio commands are dropped, the UI
# runs the same, and the crate links no audio libraries (ALSA on Linux).
audio = ["dep:kira"]
# `#[derive(Message)]`: a Rust app's own message enum to and from the
# plain-data payload, so `on_click(Msg::Save)` and `ev.message::<Msg>()`
# replace building and picking apart `Value`s by string (backlog C50). On by
# default: the syn it builds on is already in a windowed app's tree.
derive = ["kui-core/derive"]
# Show the file dialogs an app asks for (`request_files`, backlog C51) with
# the platform's own panels through rfd. Off: an ask is answered at once
# with no paths, as a cancelled dialog would be.
dialogs = ["dep:rfd"]
# Expose the core's access tree to screen readers and other assistive
# technology through AccessKit. On by default (an accessibility feature that
# is off by default does not get tested); off for kiosk builds, where the
# core still derives the tree for anyone who asks and nothing reaches the OS.
accesskit = ["dep:accesskit", "dep:accesskit_winit"]
# Honour `KUI_SMOKE_FRAMES` in a build with debug assertions off. The hook
# is always live in a dev build, which is where it is used by hand; this is
# for the smoke round's `--release` (examples/devtools/src/bin/smoke.rs),
# the only reason to want a
# shipping build that closes its own window. See `Launcher::smoke_frames`.
smoke = []

# Same version winit pins, so the tree compiles it once. Dwm and
# Globalization are the accent colour and the locale (`mod system_env`);
# Console is the parent's terminal, attached (`mod windows_console`).
[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.52", features = [
    "Win32_Foundation",
    "Win32_Globalization",
    "Win32_Graphics_Dwm",
    "Win32_Graphics_Gdi",
    "Win32_System_Console",
    # The executable's own icon resource (`mod icon`, backlog RG41).
    "Win32_System_LibraryLoader",
    # A paste's markers (`mod clipboard`, backlog F84): the clipboard's
    # registered formats, and the history format's value behind its handle.
    "Win32_System_DataExchange",
    "Win32_System_Memory",
    # The accent colour DWM keeps in the registry (`mod system_env`).
    "Win32_System_Registry",
    "Win32_UI_Input_KeyboardAndMouse",
    "Win32_UI_Shell",
    # The client area extended under the frame, so a system backdrop shows
    # through it (`mod backdrop`, backlog F126): `MARGINS` lives here.
    "Win32_UI_Controls",
    # The keyboard layout a press is read on (`keys::windows_layout`,
    # backlog F115): `HKL` lives here.
    "Win32_UI_TextServices",
    "Win32_UI_WindowsAndMessaging",
] }

# The OS settings winit has no call for: the accent colour, reduce motion
# and the language list (`mod system_env`). Same versions arboard already
# pulls in, so this adds features to crates the tree compiles anyway rather
# than crates; the feature lists are the four classes we call and nothing
# else.
# The X server's lock state, which winit does not report (`keys::x11_locks`,
# backlog RG104). The version and the `xkb` feature winit's X11 backend
# already builds, so this adds no crate to the tree.
[target.'cfg(not(any(target_os = "macos", target_os = "windows")))'.dependencies]
x11rb = { version = "0.13", features = ["xkb"] }
# A `Blur` backdrop asked of the Wayland compositor (`mod linux_blur`,
# backlog F126): KWin's `org_kde_kwin_blur` and the staging
# `ext-background-effect-v1`, on the display winit opened. The versions
# winit already builds; `staging` is the one feature this adds.
wayland-client = "0.31"
wayland-backend = { version = "0.3", features = ["client_system"] }
wayland-protocols = { version = "0.32", features = ["client", "staging"] }
wayland-protocols-plasma = { version = "0.3", features = ["client"] }

[target.'cfg(target_os = "macos")'.dependencies]
objc2 = "0.6"
objc2-app-kit = { version = "0.3", default-features = false, features = [
    "std",
    "objc2-core-foundation",
    "NSAccessibility",
    "NSColor",
    "NSColorSpace",
    "NSWorkspace",
    # The context menu (ADR 0017 step 3): an NSMenu of NSMenuItems shown
    # over the window's view, which is what `NSResponder` and `NSView` are
    # here for — the menu is popped up *in* a view, and NSView needs its
    # superclass.
    "NSMenu",
    "NSMenuItem",
    # The application menu bar (ADR 0018): `NSApp.mainMenu`, and the
    # checkmark an item's `checked` sets (`NSControlStateValue`, in NSCell).
    "NSApplication",
    "NSCell",
    # The standard bar (ADR 0030): a popup asks its `NSWindow` to stay out
    # of the Window menu's list.
    "NSWindow",
    # The traffic lights' keep-out (`mod macos_chrome`): the standard window
    # buttons are `NSButton`s, asked for their frames.
    "NSButton",
    "NSControl",
    "NSResponder",
    "NSView",
    "NSEvent",
    # Force Touch: asking the view for the deep-click stage (step 5).
    "NSPressureConfiguration",
    # A paste's markers and a secret's copy (`mod clipboard`, backlog F84).
    "NSPasteboard",
    # Frames started by the display (`mod pacer`, C47's follow-up): the
    # view's `displayLinkWithTarget:selector:`.
    "objc2-quartz-core",
    # A row's hint drawn where it binds nothing (backlog F119): its title
    # attributed, with the menu font, a right tab stop and the secondary
    # label colour, measured to place the stop.
    "NSAttributedString",
    "NSFont",
    "NSParagraphStyle",
    "NSStringDrawing",
    "NSText",
    # The window's backdrop (`mod backdrop`, backlog F126): an
    # `NSVisualEffectView` added below the content, which `NSGraphics`'s
    # ordering constant places.
    "NSVisualEffectView",
    "NSGraphics",
    # The titlebar's height under custom chrome (`mod macos_chrome`,
    # backlog W22): an empty toolbar in the style that makes it.
    "NSToolbar",
] }
objc2-quartz-core = { version = "0.3", default-features = false, features = [
    "std",
    "CADisplayLink",
    # The backdrop's layer kept under the one wgpu draws into.
    "CALayer",
    "objc2-core-foundation",
] }
objc2-foundation = { version = "0.3", default-features = false, features = [
    "std",
    "NSArray",
    "NSLocale",
    "NSString",
    # The Look Up panel takes an attributed string (ADR 0017 step 5).
    "NSAttributedString",
    "NSDictionary",
    "NSRange",
    "NSGeometry",
    # The display link's run loop and mode (`mod pacer`).
    "NSRunLoop",
    "NSObjCRuntime",
] }

# Every example in the repo lives under examples/ at the root, one directory
# per binding, rather than being scattered a crate at a time. A binding's
# directory holds the whole example whatever it is written in, so the Rust
# host of a C or Lua panel sits in examples/c or examples/lua next to the
# panel it hosts; examples/rust is the pure-Rust ones. Cargo needs the path
# spelled out because they are outside the package; it also drops them from
# the published tarball, which is what we want - the repo is where you read
# them. See examples/README.md.
#
# One subject per example, and the subject's kind is the directory
# (docs/adr/0021): `apps/` compose, `widgets/` show one element or stock
# widget, `features/` one behaviour with the widgets it touches, `tools/`
# what is registered here for want of a better slot. The target name is the
# file's basename, since every example binary in the workspace lands in one
# flat target/debug/examples. Every one runs inside kui-devtools
# (examples/devtools); `headless` below lists the ones whose `--headless`
# is a self-check with an exit code, which `smoke --headless` runs
# and a test in the devtools crate pins to this list.
#
# The exception is `tutorial/` (docs/adr/0039): the book's graded steps,
# registered at the end of this file as `tutorial_NN_name`, run on the
# shipped launcher alone — no harness, no `--headless` — because the book
# teaches the API an app is written against. They are in the windowed
# smoke round like every `[[example]]`; the step with a `mod tests` is
# under `cargo test` through `test = true`.
[package.metadata.kui]
headless = [
    "transition",
    "spring",
    "hover",
    "drop",
    "focus",
    "drag",
    "tooltip",
    "button",
    "counter",
    "edit",
    "audio",
    "virtual_list",
    "cells",
    "menu_bar",
    "selection",
    "clipboard",
    "context_menu",
    "select",
    "controls",
    "table",
    "image",
    "polygon",
    "path",
    "loaders",
    "fragment",
    "metrics",
    "align",
    "modal",
    "devtools_tab",
    "modal_editor",
    "splitmux",
    "syntax_view",
    "backdrop",
    "backdrop_blur",
    "transform",
    "decode",
]

[[example]]
name = "counter"
path = "../../examples/rust/apps/counter.rs"

[[example]]
name = "splitmux"
path = "../../examples/rust/apps/splitmux.rs"
# Splitmux is the one example that owns its whole keyboard *and* draws
# clickable surfaces inside the sink that owns it, so its chords are where a
# press stealing the keyboard shows up. `test = true` lets its `mod tests`
# drive it headlessly through the `App` trait under `cargo test`.
test = true

[[example]]
name = "modal_editor"
path = "../../examples/rust/apps/modal_editor.rs"

[[example]]
name = "syntax_view"
path = "../../examples/rust/apps/syntax_view.rs"

[[example]]
name = "loaders"
path = "../../examples/rust/apps/loaders.rs"

[[example]]
name = "edit"
path = "../../examples/rust/widgets/edit.rs"

[[example]]
name = "text"
path = "../../examples/rust/widgets/text.rs"

[[example]]
name = "image"
path = "../../examples/rust/widgets/image.rs"

[[example]]
name = "line"
path = "../../examples/rust/widgets/line.rs"

[[example]]
name = "polygon"
path = "../../examples/rust/widgets/polygon.rs"

[[example]]
name = "path"
path = "../../examples/rust/widgets/path.rs"

[[example]]
name = "fragment"
path = "../../examples/rust/widgets/fragment.rs"

[[example]]
name = "virtual_list"
path = "../../examples/rust/widgets/virtual_list.rs"

[[example]]
name = "context_menu"
path = "../../examples/rust/widgets/context_menu.rs"

[[example]]
name = "controls"
path = "../../examples/rust/widgets/controls.rs"

[[example]]
name = "select"
path = "../../examples/rust/widgets/select.rs"

[[example]]
name = "table"
path = "../../examples/rust/widgets/table.rs"

[[example]]
name = "audio"
path = "../../examples/rust/features/audio.rs"

[[example]]
name = "enter_exit"
path = "../../examples/rust/features/enter_exit.rs"

[[example]]
name = "exit_budget"
path = "../../examples/rust/features/exit_budget.rs"

[[example]]
name = "waker"
path = "../../examples/rust/features/waker.rs"

[[example]]
name = "decode"
path = "../../examples/rust/features/decode.rs"

[[example]]
name = "popup"
path = "../../examples/rust/features/popup.rs"

[[example]]
name = "theme"
path = "../../examples/rust/features/theme.rs"

[[example]]
name = "backdrop"
path = "../../examples/rust/features/backdrop.rs"

[[example]]
name = "backdrop_blur"
path = "../../examples/rust/features/backdrop_blur.rs"

[[example]]
name = "transform"
path = "../../examples/rust/features/transform.rs"

[[example]]
name = "metrics"
path = "../../examples/rust/features/metrics.rs"

[[example]]
name = "align"
path = "../../examples/rust/features/align.rs"

[[example]]
name = "modal"
path = "../../examples/rust/features/modal.rs"

[[example]]
name = "devtools_tab"
path = "../../examples/rust/features/devtools_tab.rs"

[[example]]
name = "accessibility"
path = "../../examples/rust/features/accessibility.rs"

[[example]]
name = "cells"
path = "../../examples/rust/widgets/cells.rs"

[[example]]
name = "menu_bar"
path = "../../examples/rust/widgets/menu_bar.rs"

[[example]]
name = "selection"
path = "../../examples/rust/features/selection.rs"

[[example]]
name = "clipboard"
path = "../../examples/rust/features/clipboard.rs"

[[example]]
name = "transition"
path = "../../examples/rust/features/transition.rs"

[[example]]
name = "spring"
path = "../../examples/rust/features/spring.rs"

[[example]]
name = "hover"
path = "../../examples/rust/features/hover.rs"

[[example]]
name = "drop"
path = "../../examples/rust/features/drop.rs"

[[example]]
name = "focus"
path = "../../examples/rust/features/focus.rs"

[[example]]
name = "drag"
path = "../../examples/rust/features/drag.rs"

[[example]]
name = "titlebar"
path = "../../examples/rust/widgets/titlebar.rs"

[[example]]
name = "tooltip"
path = "../../examples/rust/widgets/tooltip.rs"

[[example]]
name = "button"
path = "../../examples/rust/widgets/button.rs"

# The book's tutorial (docs/book, docs/adr/0039): one step per file, each
# the previous plus one concept, and the chapters include them by anchor.

[[example]]
name = "tutorial_01_hello"
path = "../../examples/rust/tutorial/01_hello.rs"

[[example]]
name = "tutorial_02_layout"
path = "../../examples/rust/tutorial/02_layout.rs"

[[example]]
name = "tutorial_03_counter"
path = "../../examples/rust/tutorial/03_counter.rs"

[[example]]
name = "tutorial_04_controls"
path = "../../examples/rust/tutorial/04_controls.rs"

[[example]]
name = "tutorial_05_list"
path = "../../examples/rust/tutorial/05_list.rs"

[[example]]
name = "tutorial_06_keyboard"
path = "../../examples/rust/tutorial/06_keyboard.rs"

[[example]]
name = "tutorial_07_floats"
path = "../../examples/rust/tutorial/07_floats.rs"

[[example]]
name = "tutorial_08_motion"
path = "../../examples/rust/tutorial/08_motion.rs"

[[example]]
name = "tutorial_09_effects"
path = "../../examples/rust/tutorial/09_effects.rs"

[[example]]
name = "tutorial_10_testing"
path = "../../examples/rust/tutorial/10_testing.rs"
# Its `mod tests` drives the app headlessly under `cargo test`.
test = true