@native-sdk/cli 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +91 -2
- package/build.zig +756 -5
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +19 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +416 -9
- package/packages/core/sdk/core.ts +706 -5
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +3187 -264
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +42 -4
- package/skill-data/ts-core/SKILL.md +13 -3
- package/src/app_runner/root.zig +112 -10
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/tests.zig +119 -1
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +639 -16
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +351 -7
- package/src/platform/macos/appkit_host.h +152 -8
- package/src/platform/macos/appkit_host.m +1816 -100
- package/src/platform/macos/cef_host.mm +372 -11
- package/src/platform/macos/root.zig +379 -11
- package/src/platform/null_platform.zig +696 -9
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +42 -0
- package/src/platform/types.zig +524 -18
- package/src/platform/windows/root.zig +432 -9
- package/src/platform/windows/webview2_host.cpp +482 -45
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +535 -12
- package/src/primitives/canvas/ui_markup.zig +253 -36
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
- package/src/primitives/canvas/ui_markup_contract.zig +89 -6
- package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +178 -9
- package/src/primitives/canvas/ui_markup_view.zig +220 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
- package/src/primitives/canvas/ui_schema.zig +110 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -10
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +23 -0
- package/src/runtime/api.zig +76 -5
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +8 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +240 -24
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +131 -13
- package/src/runtime/effects.zig +8136 -180
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +167 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +42 -4
- package/src/runtime/gpu_surface_events.zig +473 -13
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +36 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +432 -62
- package/src/runtime/session_record.zig +43 -2
- package/src/runtime/session_replay.zig +556 -20
- package/src/runtime/session_tests.zig +2087 -1
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +8 -0
- package/src/runtime/ts_core_host.zig +1320 -45
- package/src/runtime/ts_core_host_tests.zig +1100 -1
- package/src/runtime/ts_ui_app.zig +23 -5
- package/src/runtime/ui_app.zig +2444 -69
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +736 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +77 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +62 -1
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +244 -8
|
@@ -111,8 +111,8 @@ pub const AttrInfo = struct {
|
|
|
111
111
|
/// How an event's payload reaches the Msg: `message` events take a tag
|
|
112
112
|
/// with an optional `{binding}` payload; the others require a bare tag
|
|
113
113
|
/// whose payload the RUNTIME supplies (TextInputEvent, ScrollState, the
|
|
114
|
-
/// split fraction).
|
|
115
|
-
pub const EventPayload = enum { message, text_input, scroll_state, fraction };
|
|
114
|
+
/// split fraction, TerminalState).
|
|
115
|
+
pub const EventPayload = enum { message, text_input, scroll_state, fraction, terminal_state };
|
|
116
116
|
|
|
117
117
|
pub const EventInfo = struct {
|
|
118
118
|
/// Stable code, assigned at birth, never reused. Nonzero.
|
|
@@ -320,6 +320,39 @@ pub const elements = [_]ElementInfo{
|
|
|
320
320
|
// binding shape, never a markup literal. Display-only like image
|
|
321
321
|
// and chart (presses fall through); pictorial for the a11y lint.
|
|
322
322
|
.{ .code = 66, .name = "media-surface", .widget_kind = "media_surface", .hit_target = false, .a11y_name = .image },
|
|
323
|
+
// The image leaf: draws a RUNTIME-REGISTERED image by its
|
|
324
|
+
// model-owned u64 ImageId — the id `Cmd.imageLoad` /
|
|
325
|
+
// `fx.loadImage` / `fx.registerImageBytes` registered pixels
|
|
326
|
+
// under. Its `image` attribute is the avatar binding shape exactly
|
|
327
|
+
// (attr 38, scope broadened): one {binding}, never a markup
|
|
328
|
+
// literal; 0 draws nothing (the image-leaf convention — an avatar
|
|
329
|
+
// falls back to initials instead). Display-only like media-surface
|
|
330
|
+
// and chart (presses fall through); pictorial for the a11y lint.
|
|
331
|
+
.{ .code = 67, .name = "image", .widget_kind = "image", .hit_target = false, .a11y_name = .image },
|
|
332
|
+
// The video playback element: a leaf compositing the app's SINGLE
|
|
333
|
+
// video playback (decoded platform-side into the framework-owned
|
|
334
|
+
// playback surface, `canvas.video_playback_surface_id`) with
|
|
335
|
+
// optional house transport chrome. `src` declares the source — an
|
|
336
|
+
// app-assets path or an http(s) URL, the loadVideo cascade's
|
|
337
|
+
// resolution order — `controls` composes the house chrome
|
|
338
|
+
// (play/pause, elapsed, seek, duration), and autoplay/loop/muted
|
|
339
|
+
// shape the fresh playback. A composite: it lowers through
|
|
340
|
+
// `Ui.video` to existing widgets (media-surface plus the chrome
|
|
341
|
+
// row), so its rule hook owns the closed attribute set. Pictorial
|
|
342
|
+
// for the a11y lint, like media-surface and image.
|
|
343
|
+
.{ .code = 68, .name = "video", .rule_hook = "video", .hit_target = false, .a11y_name = .image },
|
|
344
|
+
// The terminal leaf: paints the framework-owned emulator session
|
|
345
|
+
// behind a MODEL-OWNED pty effect key and routes input to it when
|
|
346
|
+
// focused. Its `pty` attribute is the runtime-id binding shape
|
|
347
|
+
// (surface/image precedent): one {binding} to the u64 key the app's
|
|
348
|
+
// ptySpawn named — ids are model data, never markup literals; 0 is
|
|
349
|
+
// the unbound sentinel (an empty surface). `scrollback` echoes the
|
|
350
|
+
// app-visible view state back (the scroll `value` source-wins
|
|
351
|
+
// precedent) and `on-terminal` delivers it (a TerminalState
|
|
352
|
+
// record). An interactive control for the a11y lint: focused, it
|
|
353
|
+
// owns the keyboard, so it must carry a name — the runtime then
|
|
354
|
+
// announces the live screen text as its content.
|
|
355
|
+
.{ .code = 69, .name = "terminal", .widget_kind = "terminal", .a11y_name = .control },
|
|
323
356
|
};
|
|
324
357
|
|
|
325
358
|
// ------------------------------------------------------------- attributes
|
|
@@ -371,6 +404,10 @@ pub const attrs = [_]AttrInfo{
|
|
|
371
404
|
// Element-scoped specials.
|
|
372
405
|
.{ .code = 36, .name = "name", .class = .icon, .group = .element },
|
|
373
406
|
.{ .code = 37, .name = "icon", .class = .icon, .group = .element },
|
|
407
|
+
// The runtime-image binding (avatar and image; the validator
|
|
408
|
+
// scopes it): one {binding} to the model-owned u64 ImageId the app
|
|
409
|
+
// registered at runtime — ids are model data, never markup
|
|
410
|
+
// literals; 0 is the no-image sentinel.
|
|
374
411
|
.{ .code = 38, .name = "image", .class = .binding_only, .group = .element },
|
|
375
412
|
.{ .code = 39, .name = "anchor", .class = .option, .group = .element },
|
|
376
413
|
.{ .code = 40, .name = "anchor-alignment", .class = .option, .group = .element },
|
|
@@ -391,6 +428,10 @@ pub const attrs = [_]AttrInfo{
|
|
|
391
428
|
.{ .code = 53, .name = "test", .class = .flag, .group = .structure },
|
|
392
429
|
.{ .code = 54, .name = "template", .class = .text, .group = .structure },
|
|
393
430
|
.{ .code = 55, .name = "args", .class = .text, .group = .structure },
|
|
431
|
+
// Attribute NAMES are unique by registry law, so `src` is stated
|
|
432
|
+
// once and scoped per element: `<import src>` names the imported
|
|
433
|
+
// markup file, and the video element's rule hook reuses it for the
|
|
434
|
+
// playback's source string (an app-assets path or http(s) URL).
|
|
394
435
|
.{ .code = 56, .name = "src", .class = .text, .group = .structure },
|
|
395
436
|
.{ .code = 57, .name = "kind", .class = .text, .group = .structure },
|
|
396
437
|
// Chart composite attributes (fresh codes, assigned at birth).
|
|
@@ -480,6 +521,38 @@ pub const attrs = [_]AttrInfo{
|
|
|
480
521
|
// like an image leaf with id 0), and usable ids stay below the
|
|
481
522
|
// reserved namespace bit (bit 63), which acquire refuses.
|
|
482
523
|
.{ .code = 81, .name = "surface", .class = .binding_only, .group = .element },
|
|
524
|
+
// Video element attributes (the <video> composite; its rule hook
|
|
525
|
+
// owns the closed set): controls composes the house transport
|
|
526
|
+
// chrome, autoplay/loop/muted shape the fresh playback the
|
|
527
|
+
// element's src declares. All flags — bare presence, a literal
|
|
528
|
+
// true/false, or a {binding} to a bool.
|
|
529
|
+
.{ .code = 82, .name = "controls", .class = .flag, .group = .composite },
|
|
530
|
+
.{ .code = 83, .name = "autoplay", .class = .flag, .group = .composite },
|
|
531
|
+
.{ .code = 84, .name = "loop", .class = .flag, .group = .composite },
|
|
532
|
+
.{ .code = 85, .name = "muted", .class = .flag, .group = .composite },
|
|
533
|
+
// Scroll axis declaration (scroll only; the validator scopes it):
|
|
534
|
+
// vertical (the default — every pre-axis document keeps its exact
|
|
535
|
+
// behavior), horizontal, or both. A closed vocabulary mirroring
|
|
536
|
+
// `canvas.ScrollAxes`, the overscroll pattern.
|
|
537
|
+
.{ .code = 86, .name = "axis", .class = .option, .group = .option, .field = "axis" },
|
|
538
|
+
// The horizontal scroll offset (scroll only, and only beside a
|
|
539
|
+
// horizontal-capable axis; the validator scopes both): the sideways
|
|
540
|
+
// counterpart of `value`, following the same source-wins reconcile
|
|
541
|
+
// rule — echo `on-scroll`'s offset_x back here and user scrolling
|
|
542
|
+
// survives rebuilds; move it model-side to scroll programmatically.
|
|
543
|
+
.{ .code = 87, .name = "value-x", .class = .number, .group = .option, .field = "value_x" },
|
|
544
|
+
// The terminal's pty rendezvous (terminal only; the validator
|
|
545
|
+
// scopes and REQUIRES it): one {binding} to the model-owned u64 pty
|
|
546
|
+
// effect key `ptySpawn` named — the media-surface `surface` shape
|
|
547
|
+
// exactly. A terminal without it is dead markup, taught rather than
|
|
548
|
+
// rendered inert.
|
|
549
|
+
.{ .code = 88, .name = "pty", .class = .binding_only, .group = .element },
|
|
550
|
+
// The terminal's scrollback offset in rows above the live screen
|
|
551
|
+
// (terminal only; the validator scopes it): the scroll `value`
|
|
552
|
+
// source-wins reconcile rule — echo `on-terminal`'s `scrollback`
|
|
553
|
+
// back here and user scrollback survives rebuilds; move it
|
|
554
|
+
// model-side to scroll programmatically. 0 is pinned to the bottom.
|
|
555
|
+
.{ .code = 89, .name = "scrollback", .class = .whole, .group = .option, .field = "scrollback" },
|
|
483
556
|
};
|
|
484
557
|
|
|
485
558
|
// ----------------------------------------------------------------- events
|
|
@@ -495,6 +568,24 @@ pub const events = [_]EventInfo{
|
|
|
495
568
|
.{ .code = 8, .name = "hold" },
|
|
496
569
|
.{ .code = 9, .name = "resize", .payload = .fraction, .only_on_element = "split" },
|
|
497
570
|
.{ .code = 10, .name = "reach-end", .only_on_element = "scroll" },
|
|
571
|
+
// The pointer-hover pair (the Elm onMouseEnter/onMouseLeave
|
|
572
|
+
// convention): hover-enter dispatches when the pointer enters a
|
|
573
|
+
// bound element's hit region, hover-leave when it exits — discrete
|
|
574
|
+
// containment edges, never per-move. Binding either makes the
|
|
575
|
+
// element hover-hittable the way a bound press makes any element
|
|
576
|
+
// pressable (so both stay legal everywhere, like the press family)
|
|
577
|
+
// WITHOUT claiming presses, painting a wash, or adding an
|
|
578
|
+
// accessibility action. Hover comes from mouse/trackpad pointers
|
|
579
|
+
// only — touch input never synthesizes it.
|
|
580
|
+
.{ .code = 11, .name = "hover-enter" },
|
|
581
|
+
.{ .code = 12, .name = "hover-leave" },
|
|
582
|
+
// The terminal's view-state echo: dispatched with a TerminalState
|
|
583
|
+
// record (scrollback, history, cols, rows) after every
|
|
584
|
+
// runtime-applied view-state change — wheel and keyboard scrollback,
|
|
585
|
+
// and the layout-derived grid resize — so the model can echo
|
|
586
|
+
// `scrollback` back (the on-scroll reconcile shape) and render
|
|
587
|
+
// honest status. Emulator internals never ride it.
|
|
588
|
+
.{ .code = 13, .name = "terminal", .payload = .terminal_state, .only_on_element = "terminal" },
|
|
498
589
|
};
|
|
499
590
|
|
|
500
591
|
// ------------------------------------------------------- token vocabulary
|
|
@@ -530,16 +621,16 @@ pub const control_size_value_names = [_][]const u8{ "default", "sm", "lg", "icon
|
|
|
530
621
|
pub const text_size_value_names = [_][]const u8{ "heading", "display" };
|
|
531
622
|
|
|
532
623
|
pub const icon_names = [_][]const u8{
|
|
533
|
-
"alert", "archive",
|
|
534
|
-
"check", "check-circle",
|
|
535
|
-
"chevron-up", "circle-dot",
|
|
536
|
-
"edit", "ellipsis",
|
|
537
|
-
"folder", "folder-open",
|
|
538
|
-
"info", "menu",
|
|
539
|
-
"panel-right", "pause",
|
|
540
|
-
"repeat", "save",
|
|
541
|
-
"shuffle", "skip-back",
|
|
542
|
-
"trash", "volume",
|
|
624
|
+
"alert", "archive", "arrow-down", "arrow-right", "arrow-up",
|
|
625
|
+
"check", "check-circle", "chevron-down", "chevron-left", "chevron-right",
|
|
626
|
+
"chevron-up", "circle-dot", "clock", "copy", "download",
|
|
627
|
+
"edit", "ellipsis", "external-link", "eye", "file-text",
|
|
628
|
+
"folder", "folder-open", "git-branch", "git-merge", "git-pull-request",
|
|
629
|
+
"info", "menu", "moon", "music", "panel-left",
|
|
630
|
+
"panel-right", "pause", "play", "plus", "refresh-cw",
|
|
631
|
+
"repeat", "save", "search", "send", "settings",
|
|
632
|
+
"shuffle", "skip-back", "skip-forward", "sun", "terminal",
|
|
633
|
+
"trash", "volume", "wrench", "x", "x-circle",
|
|
543
634
|
};
|
|
544
635
|
|
|
545
636
|
/// The semantic role vocabulary the `role` attribute accepts: the field
|
|
@@ -564,14 +655,16 @@ pub const container_role_names = [_][]const u8{
|
|
|
564
655
|
};
|
|
565
656
|
|
|
566
657
|
/// Whether markup can put element children inside this element: text
|
|
567
|
-
/// leaves hold a single text run and the icon
|
|
568
|
-
/// enforced by the validator), so a container role there is
|
|
569
|
-
/// misuse. Other leaves (separator, value controls)
|
|
570
|
-
/// children, so the lint stays quiet about them.
|
|
658
|
+
/// leaves hold a single text run, and the icon and terminal leaves hold
|
|
659
|
+
/// nothing (all enforced by the validator), so a container role there is
|
|
660
|
+
/// provably misuse. Other leaves (separator, value controls)
|
|
661
|
+
/// structurally accept children, so the lint stays quiet about them.
|
|
571
662
|
pub fn elementHoldsChildren(entry: *const ElementInfo) bool {
|
|
572
663
|
if (entry.takes_children) return true;
|
|
573
664
|
if (entry.takes_text) return false;
|
|
574
|
-
|
|
665
|
+
if (std.mem.eql(u8, entry.name, "icon")) return false;
|
|
666
|
+
if (std.mem.eql(u8, entry.name, "terminal")) return false;
|
|
667
|
+
return true;
|
|
575
668
|
}
|
|
576
669
|
|
|
577
670
|
// ---------------------------------------------------------------- lookups
|
|
@@ -21,13 +21,15 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
21
21
|
// (append or slot them anywhere — order carries no meaning) and pin
|
|
22
22
|
// the new fingerprint ONLY for additions; renames/renumbers are
|
|
23
23
|
// schema-version-bump events, not silent edits.
|
|
24
|
-
try testing.expectEqual(@as(usize,
|
|
25
|
-
try testing.expectEqual(@as(usize,
|
|
26
|
-
try testing.expectEqual(@as(usize,
|
|
24
|
+
try testing.expectEqual(@as(usize, 69), schema.elements.len);
|
|
25
|
+
try testing.expectEqual(@as(usize, 89), schema.attrs.len);
|
|
26
|
+
try testing.expectEqual(@as(usize, 13), schema.events.len);
|
|
27
27
|
// The element table runs through the span composite (64), the
|
|
28
|
-
// bubble-reactions composite (65),
|
|
28
|
+
// bubble-reactions composite (65), the media surface (66), the
|
|
29
|
+
// runtime-image leaf (67), the video playback composite (68), and
|
|
30
|
+
// the terminal leaf (69).
|
|
29
31
|
try testing.expectEqual(
|
|
30
|
-
@as(u64,
|
|
32
|
+
@as(u64, 0x439b5e520bedc352),
|
|
31
33
|
tableFingerprint(schema.ElementInfo, &schema.elements),
|
|
32
34
|
);
|
|
33
35
|
// The attr table runs through the split layout-tween attributes
|
|
@@ -36,14 +38,20 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
36
38
|
// the later span additions scale (76) and underline (77), the
|
|
37
39
|
// split enter-from attribute resize-origin (78), the quiet-surface
|
|
38
40
|
// hover knob quiet-hover (79), the anchored-tooltip hover-intent
|
|
39
|
-
// delay tooltip-delay (80),
|
|
40
|
-
//
|
|
41
|
+
// delay tooltip-delay (80), the media-surface producer rendezvous
|
|
42
|
+
// surface (81), the video element attributes controls (82),
|
|
43
|
+
// autoplay (83), loop (84), and muted (85), the scroll-axis
|
|
44
|
+
// attributes axis (86) and value-x (87), and the terminal
|
|
45
|
+
// attributes pty (88) and scrollback (89).
|
|
41
46
|
try testing.expectEqual(
|
|
42
|
-
@as(u64,
|
|
47
|
+
@as(u64, 0x60e430e0cf2cc4f9),
|
|
43
48
|
tableFingerprint(schema.AttrInfo, &schema.attrs),
|
|
44
49
|
);
|
|
50
|
+
// The event table runs through the pointer-hover containment pair
|
|
51
|
+
// hover-enter (11) and hover-leave (12) and the terminal view-state
|
|
52
|
+
// echo terminal (13).
|
|
45
53
|
try testing.expectEqual(
|
|
46
|
-
@as(u64,
|
|
54
|
+
@as(u64, 0x62d715c2db7951d6),
|
|
47
55
|
tableFingerprint(schema.EventInfo, &schema.events),
|
|
48
56
|
);
|
|
49
57
|
}
|
|
@@ -90,7 +98,7 @@ test "registry event scoping names registry elements" {
|
|
|
90
98
|
test "derived name lists mirror the registry" {
|
|
91
99
|
// The derivations are the vocabulary every consumer reads; hold them
|
|
92
100
|
// to the registry's own predicates.
|
|
93
|
-
try testing.expectEqual(@as(usize,
|
|
101
|
+
try testing.expectEqual(@as(usize, 56), schema.element_names.len);
|
|
94
102
|
for (schema.element_names) |name| {
|
|
95
103
|
try testing.expect(schema.elementByName(name).?.rule_hook == null);
|
|
96
104
|
}
|
|
@@ -476,12 +476,12 @@ test "payload-carrying handlers build messages from edits and values" {
|
|
|
476
476
|
};
|
|
477
477
|
const feed = findByKind(scroll_tree.root, .scroll_view).?;
|
|
478
478
|
const scrolled = scroll_tree.msgForScroll(feed.id, .{
|
|
479
|
-
.
|
|
480
|
-
.
|
|
481
|
-
.
|
|
479
|
+
.offset_y = 64,
|
|
480
|
+
.viewport_extent_y = 72,
|
|
481
|
+
.content_extent_y = 200,
|
|
482
482
|
}).?.feed_scrolled;
|
|
483
|
-
try testing.expectEqual(@as(f32, 64), scrolled.
|
|
484
|
-
try testing.expectEqual(@as(f32, 128), scrolled.maxOffset());
|
|
483
|
+
try testing.expectEqual(@as(f32, 64), scrolled.offset_y);
|
|
484
|
+
try testing.expectEqual(@as(f32, 128), scrolled.axis(.vertical).maxOffset());
|
|
485
485
|
try testing.expectEqual(@as(?Msg, null), tree.msgForScroll(slider.id, .{}));
|
|
486
486
|
|
|
487
487
|
// Widgets without payload handlers dispatch nothing for edits.
|
|
@@ -1184,6 +1184,139 @@ test "a bound press handler makes layout containers hit targets" {
|
|
|
1184
1184
|
try testing.expectEqual(@as(u32, 7), tree.msgForPointer(row.id, .up).?.toggle);
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
+
test "Ui.video records the declaration last-wins, formats times, and disables chrome when inactive" {
|
|
1188
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1189
|
+
defer arena_state.deinit();
|
|
1190
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
1191
|
+
|
|
1192
|
+
// Inactive channel (the default outside an app loop): the chrome
|
|
1193
|
+
// renders disabled at the play glyph with zeroed readouts.
|
|
1194
|
+
const idle = ui.video(.{ .src = "assets/clips/one.mp4", .controls = true, .width = 320, .height = 180 });
|
|
1195
|
+
const idle_surface = idle.nodes[0];
|
|
1196
|
+
try testing.expectEqual(canvas.WidgetKind.media_surface, idle_surface.widget.kind);
|
|
1197
|
+
try testing.expectEqual(canvas.video_playback_surface_id, idle_surface.widget.image_id);
|
|
1198
|
+
const idle_row = idle.nodes[1];
|
|
1199
|
+
const idle_button = idle_row.nodes[0];
|
|
1200
|
+
try testing.expectEqual(canvas.VideoControlVerb.toggle, idle_button.widget.video_control);
|
|
1201
|
+
try testing.expect(idle_button.widget.state.disabled);
|
|
1202
|
+
try testing.expectEqualStrings("play", idle_button.widget.icon);
|
|
1203
|
+
try testing.expectEqualStrings("0:00", idle_row.nodes[1].widget.text);
|
|
1204
|
+
const idle_slider = idle_row.nodes[2];
|
|
1205
|
+
try testing.expectEqual(canvas.VideoControlVerb.scrub, idle_slider.widget.video_control);
|
|
1206
|
+
try testing.expect(idle_slider.widget.state.disabled);
|
|
1207
|
+
try testing.expectEqual(@as(f32, 0), idle_slider.widget.value);
|
|
1208
|
+
try testing.expectEqualStrings("0:00", idle_row.nodes[3].widget.text);
|
|
1209
|
+
try testing.expectEqualStrings("assets/clips/one.mp4", ui.video_declaration.?.src);
|
|
1210
|
+
|
|
1211
|
+
// A live stamped snapshot: the pause glyph, h:mm:ss past the hour,
|
|
1212
|
+
// and the seek fraction from position over duration.
|
|
1213
|
+
ui.video_state = .{ .active = true, .playing = true, .position_ms = 3_725_000, .duration_ms = 7_200_000 };
|
|
1214
|
+
const live = ui.video(.{ .src = "assets/clips/two.mp4", .controls = true, .loop = true });
|
|
1215
|
+
const live_row = live.nodes[1];
|
|
1216
|
+
const live_button = live_row.nodes[0];
|
|
1217
|
+
try testing.expect(!live_button.widget.state.disabled);
|
|
1218
|
+
try testing.expectEqualStrings("pause", live_button.widget.icon);
|
|
1219
|
+
try testing.expectEqualStrings("1:02:05", live_row.nodes[1].widget.text);
|
|
1220
|
+
try testing.expectApproxEqAbs(@as(f32, 3_725_000.0 / 7_200_000.0), live_row.nodes[2].widget.value, 0.0001);
|
|
1221
|
+
try testing.expect(!live_row.nodes[2].widget.state.disabled);
|
|
1222
|
+
try testing.expectEqualStrings("2:00:00", live_row.nodes[3].widget.text);
|
|
1223
|
+
|
|
1224
|
+
// The last declaration wins (loadVideo's replace semantics: one
|
|
1225
|
+
// player is the whole surface).
|
|
1226
|
+
try testing.expectEqualStrings("assets/clips/two.mp4", ui.video_declaration.?.src);
|
|
1227
|
+
try testing.expect(ui.video_declaration.?.loop);
|
|
1228
|
+
|
|
1229
|
+
// A src-less video records nothing: it is surface-only chrome over
|
|
1230
|
+
// whatever playback the app loaded itself.
|
|
1231
|
+
var chrome_ui = InboxUi.init(arena_state.allocator());
|
|
1232
|
+
_ = chrome_ui.video(.{ .controls = true });
|
|
1233
|
+
try testing.expect(chrome_ui.video_declaration == null);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
test "Ui stamps contain fit and stream geometry on video-fed media surfaces" {
|
|
1237
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1238
|
+
defer arena_state.deinit();
|
|
1239
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
1240
|
+
|
|
1241
|
+
// The framework `<video>` surface is ALWAYS contain — pre-LOADED it
|
|
1242
|
+
// simply carries no stream geometry yet (no fit math to run).
|
|
1243
|
+
const idle = ui.video(.{ .src = "assets/clips/one.mp4", .controls = true });
|
|
1244
|
+
try testing.expectEqual(canvas.ImageFit.contain, idle.nodes[0].widget.image_fit);
|
|
1245
|
+
try testing.expectEqual(@as(?geometry.SizeF, null), idle.nodes[0].widget.stream_size);
|
|
1246
|
+
|
|
1247
|
+
// The LOADED report stamps the fitted-draw geometry on the surface
|
|
1248
|
+
// the active playback FEEDS — here an app-claimed custom surface.
|
|
1249
|
+
ui.video_state = .{ .active = true, .playing = true, .surface = 0x7601, .width = 427, .height = 240 };
|
|
1250
|
+
const custom = ui.mediaSurface(.{ .image = 0x7601, .grow = 1 });
|
|
1251
|
+
try testing.expectEqual(canvas.ImageFit.contain, custom.widget.image_fit);
|
|
1252
|
+
try testing.expectEqual(
|
|
1253
|
+
@as(?geometry.SizeF, geometry.SizeF.init(427, 240)),
|
|
1254
|
+
custom.widget.stream_size,
|
|
1255
|
+
);
|
|
1256
|
+
|
|
1257
|
+
// A source-less `<video>` shown WHILE that custom playback runs
|
|
1258
|
+
// must not borrow the unrelated stream's geometry: contain (it is
|
|
1259
|
+
// the video surface by convention), but no dimensions — the
|
|
1260
|
+
// placeholder fills the frame.
|
|
1261
|
+
const bystander = ui.video(.{ .controls = true });
|
|
1262
|
+
try testing.expectEqual(canvas.ImageFit.contain, bystander.nodes[0].widget.image_fit);
|
|
1263
|
+
try testing.expectEqual(@as(?geometry.SizeF, null), bystander.nodes[0].widget.stream_size);
|
|
1264
|
+
|
|
1265
|
+
// A producer surface the video channel does NOT feed keeps its own
|
|
1266
|
+
// geometry: no stamp, the default stretch, `image_src` untouched.
|
|
1267
|
+
const camera = ui.mediaSurface(.{ .image = 0x9902, .grow = 1 });
|
|
1268
|
+
try testing.expectEqual(canvas.ImageFit.stretch, camera.widget.image_fit);
|
|
1269
|
+
try testing.expectEqual(@as(?geometry.SizeF, null), camera.widget.stream_size);
|
|
1270
|
+
|
|
1271
|
+
// The declarative playback feeding the framework surface stamps
|
|
1272
|
+
// dimensions on the `<video>` element itself.
|
|
1273
|
+
ui.video_state = .{ .active = true, .playing = true, .surface = canvas.video_playback_surface_id, .width = 1280, .height = 720 };
|
|
1274
|
+
const house = ui.video(.{ .src = "assets/clips/one.mp4", .controls = true });
|
|
1275
|
+
try testing.expectEqual(
|
|
1276
|
+
@as(?geometry.SizeF, geometry.SizeF.init(1280, 720)),
|
|
1277
|
+
house.nodes[0].widget.stream_size,
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
test "Ui.video with controls keeps the media surface's zero-intrinsic contract" {
|
|
1282
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1283
|
+
defer arena_state.deinit();
|
|
1284
|
+
|
|
1285
|
+
// A hug-sized container and no declared width/height/grow: the
|
|
1286
|
+
// element measures zero exactly like the bare surface — the
|
|
1287
|
+
// transport bar must not size it into a controls-only strip.
|
|
1288
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
1289
|
+
const tree = try ui.finalize(ui.column(.{ .cross = .start }, .{
|
|
1290
|
+
ui.video(.{ .src = "assets/clips/one.mp4", .controls = true }),
|
|
1291
|
+
}));
|
|
1292
|
+
const element = tree.root.children[0];
|
|
1293
|
+
try testing.expect(element.layout.zero_intrinsic);
|
|
1294
|
+
try testing.expect(element.layout.clip_content);
|
|
1295
|
+
var layout_nodes: [32]canvas.WidgetLayoutNode = undefined;
|
|
1296
|
+
const layout = try canvas.layoutWidgetTree(tree.root, geometry.RectF.init(0, 0, 400, 300), &layout_nodes);
|
|
1297
|
+
const frame = layout.findById(element.id).?.frame;
|
|
1298
|
+
try testing.expectEqual(@as(f32, 0), frame.width);
|
|
1299
|
+
try testing.expectEqual(@as(f32, 0), frame.height);
|
|
1300
|
+
|
|
1301
|
+
// Declared sizes stay definite: the same element sized 320x180
|
|
1302
|
+
// carries the surface above the transport bar, which keeps its
|
|
1303
|
+
// intrinsic height inside the declared box.
|
|
1304
|
+
var sized_ui = InboxUi.init(arena_state.allocator());
|
|
1305
|
+
const sized_tree = try sized_ui.finalize(sized_ui.column(.{ .cross = .start }, .{
|
|
1306
|
+
sized_ui.video(.{ .src = "assets/clips/one.mp4", .controls = true, .width = 320, .height = 180 }),
|
|
1307
|
+
}));
|
|
1308
|
+
const sized_element = sized_tree.root.children[0];
|
|
1309
|
+
var sized_nodes: [32]canvas.WidgetLayoutNode = undefined;
|
|
1310
|
+
const sized_layout = try canvas.layoutWidgetTree(sized_tree.root, geometry.RectF.init(0, 0, 400, 300), &sized_nodes);
|
|
1311
|
+
const sized_frame = sized_layout.findById(sized_element.id).?.frame;
|
|
1312
|
+
try testing.expectEqual(@as(f32, 320), sized_frame.width);
|
|
1313
|
+
try testing.expectEqual(@as(f32, 180), sized_frame.height);
|
|
1314
|
+
const surface_frame = sized_layout.findById(sized_element.children[0].id).?.frame;
|
|
1315
|
+
const bar_frame = sized_layout.findById(sized_element.children[1].id).?.frame;
|
|
1316
|
+
try testing.expect(bar_frame.height > 0);
|
|
1317
|
+
try testing.expectApproxEqAbs(@as(f32, 180), surface_frame.height + bar_frame.height, 0.5);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1187
1320
|
test "chart builder copies, downsamples, and summarizes series" {
|
|
1188
1321
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1189
1322
|
defer arena_state.deinit();
|
|
@@ -1308,8 +1441,8 @@ test "virtualWindow resolves the runtime state and virtualList builds only the w
|
|
|
1308
1441
|
|
|
1309
1442
|
// Typed dispatch: the scroll observation and the approach-end signal
|
|
1310
1443
|
// both resolve through the container's handlers.
|
|
1311
|
-
const state = canvas.ScrollState{ .
|
|
1312
|
-
try testing.expectEqual(@as(f32, 25_000), tree.msgForScroll(tree.root.id, state).?.feed_scrolled.
|
|
1444
|
+
const state = canvas.ScrollState{ .offset_y = 25_000, .viewport_extent_y = 90, .content_extent_y = 2_499_975 };
|
|
1445
|
+
try testing.expectEqual(@as(f32, 25_000), tree.msgForScroll(tree.root.id, state).?.feed_scrolled.offset_y);
|
|
1313
1446
|
try testing.expectEqual(Msg.load_more, tree.msgForReachEnd(tree.root.id).?);
|
|
1314
1447
|
}
|
|
1315
1448
|
|
|
@@ -1360,7 +1493,6 @@ test "virtualWindow without a source falls back to the request viewport" {
|
|
|
1360
1493
|
try testing.expect(ui.virtualWindow(options).isEmpty());
|
|
1361
1494
|
}
|
|
1362
1495
|
|
|
1363
|
-
|
|
1364
1496
|
test "widget kind codes are pinned: assigned at birth, declaration-order-independent" {
|
|
1365
1497
|
// The FULL golden table. `structuralId` hashes `widgetKindCode`, so
|
|
1366
1498
|
// this table IS the id vocabulary persisted state references:
|
|
@@ -1433,6 +1565,7 @@ test "widget kind codes are pinned: assigned at birth, declaration-order-indepen
|
|
|
1433
1565
|
.{ .kind = .tree, .code = 59 },
|
|
1434
1566
|
.{ .kind = .input_group, .code = 60 },
|
|
1435
1567
|
.{ .kind = .media_surface, .code = 61 },
|
|
1568
|
+
.{ .kind = .terminal, .code = 62 },
|
|
1436
1569
|
};
|
|
1437
1570
|
try testing.expectEqual(std.enums.values(canvas.WidgetKind).len, expected.len);
|
|
1438
1571
|
for (expected) |entry| {
|
|
@@ -1460,4 +1593,3 @@ test "structural id goldens: the id algorithm is pinned end to end" {
|
|
|
1460
1593
|
try testing.expectEqual(@as(canvas.ObjectId, 10740830058688169295), canvas.globalWidgetId(.tree, .{ .index = 3 }));
|
|
1461
1594
|
try testing.expectEqual(@as(canvas.ObjectId, 9835495177657875356), canvas.globalWidgetId(.split_divider, canvas.uiKey("divider")));
|
|
1462
1595
|
}
|
|
1463
|
-
|
|
@@ -34,7 +34,10 @@ pub fn cursorForWidgetHit(hit: ?WidgetHit) WidgetCursor {
|
|
|
34
34
|
pub fn cursorForWidgetTarget(kind: WidgetKind, state: WidgetState) WidgetCursor {
|
|
35
35
|
if (state.disabled) return .arrow;
|
|
36
36
|
return switch (kind) {
|
|
37
|
-
|
|
37
|
+
// The terminal joins the editable-text register: a click
|
|
38
|
+
// focuses the session's input, and the I-beam advertises it —
|
|
39
|
+
// the platform terminals' own convention.
|
|
40
|
+
.input, .text_field, .search_field, .combobox, .textarea, .terminal => .text,
|
|
38
41
|
.resizable, .split_divider => .resize_horizontal,
|
|
39
42
|
else => .arrow,
|
|
40
43
|
};
|
|
@@ -76,7 +79,7 @@ pub fn isDragSource(widget: Widget) bool {
|
|
|
76
79
|
pub fn widgetKindHitTarget(kind: WidgetKind) bool {
|
|
77
80
|
return switch (kind) {
|
|
78
81
|
.row, .column, .grid, .data_grid, .table, .data_row, .list, .breadcrumb, .button_group, .pagination, .radio_group, .tabs, .toggle_group, .stack, .tooltip, .icon, .image, .avatar, .badge, .separator, .skeleton, .spinner, .chart, .split, .tree, .input_group, .media_surface => false,
|
|
79
|
-
.scroll_view, .accordion, .alert, .bubble, .card, .dialog, .drawer, .sheet, .resizable, .panel, .popover, .menu_surface, .dropdown_menu, .text, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .menu_item, .list_item, .data_cell, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .split_divider => true,
|
|
82
|
+
.scroll_view, .accordion, .alert, .bubble, .card, .dialog, .drawer, .sheet, .resizable, .panel, .popover, .menu_surface, .dropdown_menu, .text, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .menu_item, .list_item, .data_cell, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .split_divider, .terminal => true,
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -93,6 +96,25 @@ pub fn isHitTarget(widget: Widget) bool {
|
|
|
93
96
|
return widgetKindHitTarget(widget.kind);
|
|
94
97
|
}
|
|
95
98
|
|
|
99
|
+
/// The hover-Msg CONTAINMENT predicate: everything the interactive hit
|
|
100
|
+
/// test sees, plus hover-Msg listeners. Deliberately a separate policy
|
|
101
|
+
/// from `isHitTarget` — a hover-only listener must be resolvable for
|
|
102
|
+
/// enter/leave containment while remaining INVISIBLE to the interactive
|
|
103
|
+
/// pipeline (wash, cursor, press routing, text selection), so binding
|
|
104
|
+
/// hover changes nothing about where washes paint or clicks land, even
|
|
105
|
+
/// for overlapping siblings.
|
|
106
|
+
pub fn isHoverMsgHitTarget(widget: Widget) bool {
|
|
107
|
+
return isHitTarget(widget) or widgetListensForHoverMsgs(widget);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// Whether this widget's bound hover-enter/hover-leave Msgs are LIVE:
|
|
111
|
+
/// the containment walk (`widgetHoverMsgChainFromNode`) collects only
|
|
112
|
+
/// these. Disabled widgets stand down exactly like they do for presses
|
|
113
|
+
/// (the hit test skips them too).
|
|
114
|
+
pub fn widgetListensForHoverMsgs(widget: Widget) bool {
|
|
115
|
+
return widget.id != 0 and !widget.state.disabled and widget.hover_msgs;
|
|
116
|
+
}
|
|
117
|
+
|
|
96
118
|
/// Whether this widget is a live window-drag surface: a press landing
|
|
97
119
|
/// on it (or falling through to it) moves the WINDOW. Disabled widgets
|
|
98
120
|
/// stand down exactly like they do for presses.
|
|
@@ -140,6 +162,10 @@ pub fn widgetKindClaimsPress(kind: WidgetKind) bool {
|
|
|
140
162
|
.popover,
|
|
141
163
|
.menu_surface,
|
|
142
164
|
.dropdown_menu,
|
|
165
|
+
// A click in the terminal focuses the session's input, exactly
|
|
166
|
+
// like a click in a text field places the caret — it must never
|
|
167
|
+
// activate the row or card around it.
|
|
168
|
+
.terminal,
|
|
143
169
|
=> true,
|
|
144
170
|
else => false,
|
|
145
171
|
};
|
|
@@ -73,6 +73,54 @@ test "anchored frame clamps into the window horizontally and by offset" {
|
|
|
73
73
|
try std.testing.expectEqual(@as(f32, 58), frame.y); // 20 + 28 + 10
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
test "point anchor places the surface corner at the point" {
|
|
77
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
78
|
+
// The anchor rect (a wide row's frame) must be ignored: only the
|
|
79
|
+
// point positions the surface.
|
|
80
|
+
const frame = anchoredFrame(
|
|
81
|
+
child,
|
|
82
|
+
.{ .offset = 0, .point = geometry.PointF.init(180, 60) },
|
|
83
|
+
geometry.RectF.init(0, 40, 400, 40),
|
|
84
|
+
);
|
|
85
|
+
try std.testing.expectEqual(@as(f32, 180), frame.x);
|
|
86
|
+
try std.testing.expectEqual(@as(f32, 60), frame.y);
|
|
87
|
+
try std.testing.expectEqual(@as(f32, 140), frame.width);
|
|
88
|
+
try std.testing.expectEqual(@as(f32, 90), frame.height);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
test "point anchor flips above when the surface would cross the bottom edge" {
|
|
92
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
93
|
+
// window is 300 tall: below the point has 300-260 = 40 < 90, above
|
|
94
|
+
// has 260 — flip, bottom edge lands on the point.
|
|
95
|
+
const frame = anchoredFrame(
|
|
96
|
+
child,
|
|
97
|
+
.{ .offset = 0, .point = geometry.PointF.init(50, 260) },
|
|
98
|
+
geometry.RectF.init(0, 0, 400, 300),
|
|
99
|
+
);
|
|
100
|
+
try std.testing.expectEqual(@as(f32, 260 - 90), frame.y);
|
|
101
|
+
try std.testing.expectEqual(@as(f32, 90), frame.height);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
test "point anchor clamps into the window horizontally" {
|
|
105
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
106
|
+
// window is 400 wide: a point near the right edge cannot push the
|
|
107
|
+
// surface off-screen — it clamps to the window's right edge.
|
|
108
|
+
const right = anchoredFrame(
|
|
109
|
+
child,
|
|
110
|
+
.{ .offset = 0, .point = geometry.PointF.init(390, 60) },
|
|
111
|
+
geometry.RectF.init(0, 0, 400, 300),
|
|
112
|
+
);
|
|
113
|
+
try std.testing.expectEqual(@as(f32, 400 - 140), right.x);
|
|
114
|
+
// A point beyond the window clamps into it first (never off-screen
|
|
115
|
+
// left either).
|
|
116
|
+
const left = anchoredFrame(
|
|
117
|
+
child,
|
|
118
|
+
.{ .offset = 0, .point = geometry.PointF.init(-30, 60) },
|
|
119
|
+
geometry.RectF.init(0, 0, 400, 300),
|
|
120
|
+
);
|
|
121
|
+
try std.testing.expectEqual(@as(f32, 0), left.x);
|
|
122
|
+
}
|
|
123
|
+
|
|
76
124
|
test "anchored children consume no flow space and float against the parent" {
|
|
77
125
|
const menu_items = [_]Widget{.{ .id = 4, .kind = .menu_item, .text = "One" }};
|
|
78
126
|
const dropdown = Widget{
|