@native-sdk/cli 0.5.1 → 0.5.3
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.zig +41 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/events.ts +39 -2
- package/packages/core/src/checker.ts +1 -1
- package/packages/core/src/emitter.ts +39 -3
- package/packages/core/src/infer.ts +53 -7
- package/skill-data/automation/SKILL.md +7 -4
- package/skill-data/core/references/app-model-runtime.md +3 -0
- package/skill-data/native-ui/SKILL.md +3 -2
- package/src/app_runner/root.zig +25 -0
- package/src/automation/protocol.zig +20 -1
- package/src/embed/host.zig +27 -0
- package/src/embed/tests.zig +69 -0
- package/src/embed/ui_host.zig +4 -0
- package/src/platform/macos/appkit_host.h +11 -0
- package/src/platform/macos/appkit_host.m +130 -0
- package/src/platform/macos/root.zig +34 -0
- package/src/platform/null_platform_tests.zig +39 -0
- package/src/platform/root.zig +3 -0
- package/src/platform/types.zig +118 -4
- package/src/primitives/canvas/chart.zig +7 -7
- package/src/primitives/canvas/chart_tests.zig +66 -0
- package/src/primitives/canvas/commands.zig +48 -0
- package/src/primitives/canvas/events.zig +161 -0
- package/src/primitives/canvas/font_ttf.zig +155 -8
- package/src/primitives/canvas/font_ttf_tests.zig +686 -0
- package/src/primitives/canvas/reference.zig +67 -8
- package/src/primitives/canvas/render_fingerprints.zig +8 -0
- package/src/primitives/canvas/root.zig +26 -0
- package/src/primitives/canvas/tokens.zig +170 -7
- package/src/primitives/canvas/ui.zig +62 -7
- package/src/primitives/canvas/ui_markup.zig +51 -4
- package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +49 -4
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +160 -0
- package/src/primitives/canvas/ui_markup_contract.zig +9 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +24 -0
- package/src/primitives/canvas/ui_markup_tests.zig +73 -0
- package/src/primitives/canvas/ui_markup_view.zig +63 -5
- package/src/primitives/canvas/ui_markup_view_tests.zig +151 -2
- package/src/primitives/canvas/ui_schema.zig +31 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -11
- package/src/primitives/canvas/ui_tests.zig +31 -0
- package/src/primitives/canvas/vector.zig +258 -141
- package/src/primitives/canvas/widget_access.zig +1 -1
- package/src/primitives/canvas/widget_builtin_tests.zig +259 -0
- package/src/primitives/canvas/widget_layout.zig +13 -5
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_render.zig +78 -40
- package/src/primitives/canvas/widget_render_controls.zig +15 -4
- package/src/primitives/canvas/widget_semantics.zig +6 -1
- package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
- package/src/primitives/canvas/widget_text_input.zig +118 -10
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +28 -0
- package/src/root.zig +5 -0
- package/src/runtime/api.zig +13 -0
- package/src/runtime/automation_commands.zig +33 -0
- package/src/runtime/automation_widget_dispatch.zig +159 -28
- package/src/runtime/canvas_font_tests.zig +272 -3
- package/src/runtime/canvas_fonts.zig +60 -20
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_frame_helpers.zig +15 -0
- package/src/runtime/canvas_image_tests.zig +26 -0
- package/src/runtime/canvas_images.zig +33 -7
- package/src/runtime/canvas_limits.zig +44 -8
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
- package/src/runtime/canvas_widget_events.zig +1295 -7
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_runtime.zig +24 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +88 -6
- package/src/runtime/canvas_widget_text_tests.zig +277 -0
- package/src/runtime/core.zig +112 -6
- package/src/runtime/flow.zig +51 -1
- package/src/runtime/gpu_surface_events.zig +51 -5
- package/src/runtime/media_surface.zig +726 -0
- package/src/runtime/media_surface_tests.zig +1476 -0
- package/src/runtime/root.zig +9 -0
- package/src/runtime/session_journal.zig +52 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +575 -0
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_ui_app.zig +56 -0
- package/src/runtime/ui_app.zig +64 -1
- package/src/runtime/ui_app_tests.zig +794 -0
- package/src/runtime/view.zig +86 -0
- package/src/runtime/view_widget_text.zig +18 -1
- package/src/runtime/view_widget_tree.zig +339 -20
- package/src/runtime/widget_bridge.zig +26 -0
- package/src/runtime/window_storage.zig +61 -15
- package/src/runtime/window_view_runtime.zig +13 -0
- package/src/runtime/window_views.zig +6 -0
package/src/runtime/view.zig
CHANGED
|
@@ -425,8 +425,85 @@ pub const RuntimeView = struct {
|
|
|
425
425
|
scroll_driver_count: usize = 0,
|
|
426
426
|
canvas_widget_focused_id: canvas.ObjectId = 0,
|
|
427
427
|
canvas_widget_focus_visible_id: canvas.ObjectId = 0,
|
|
428
|
+
/// True when `canvas_widget_focus_visible_id` was written by the
|
|
429
|
+
/// KEYBOARD focus contract (`setCanvasWidgetFocusFromKeyboard`) —
|
|
430
|
+
/// the one focus path that reveals tooltips. Every other
|
|
431
|
+
/// focus-visible writer stamps false: pointer focus on editables
|
|
432
|
+
/// (the caret contract), programmatic/automation focus, the
|
|
433
|
+
/// automation key escalation on plain list rows, and the rebuild
|
|
434
|
+
/// and dismissal focus-return seams — all of which deliberately
|
|
435
|
+
/// skip the reveal (Base UI's focus-visible guard against
|
|
436
|
+
/// click-focus opens, and the reveals-are-transition-edges rule).
|
|
437
|
+
/// The layout-adoption reconcile reads this to decide whether a
|
|
438
|
+
/// tooltip newly bound beneath the standing focus-visible owner
|
|
439
|
+
/// inherits the keyboard's immediate reveal or must wait for the
|
|
440
|
+
/// next real focus arrival.
|
|
441
|
+
canvas_widget_focus_visible_keyboard: bool = false,
|
|
428
442
|
canvas_widget_hovered_id: canvas.ObjectId = 0,
|
|
429
443
|
canvas_widget_pressed_id: canvas.ObjectId = 0,
|
|
444
|
+
/// Hover-intent state for ANCHORED tooltips — runtime-owned
|
|
445
|
+
/// presentation chrome; the model never hears hover. `armed` is
|
|
446
|
+
/// the tooltip whose trigger is hovered while its show delay runs;
|
|
447
|
+
/// `shown` is the tooltip currently painted; `warm_until` is the
|
|
448
|
+
/// shared warm window after a pointer-hovered tooltip hides on
|
|
449
|
+
/// pointer leave (reaching another
|
|
450
|
+
/// trigger before it passes shows that tooltip immediately, the
|
|
451
|
+
/// dense-toolbar polish). Every timestamp lives on the RECORDED
|
|
452
|
+
/// input/frame clock (`canvasRenderAnimationStartNsForView` at
|
|
453
|
+
/// pointer dispatch, `GpuSurfaceFrameEvent.timestamp_ns` at frame
|
|
454
|
+
/// advance — never a wall clock), so a recorded hover-dwell
|
|
455
|
+
/// session replays its tooltip show/hide frames byte-identically.
|
|
456
|
+
canvas_tooltip_armed_id: canvas.ObjectId = 0,
|
|
457
|
+
canvas_tooltip_deadline_ns: u64 = 0,
|
|
458
|
+
canvas_tooltip_shown_id: canvas.ObjectId = 0,
|
|
459
|
+
canvas_tooltip_warm_until_ns: u64 = 0,
|
|
460
|
+
/// The TRIGGER each intent slot was earned through (the hover
|
|
461
|
+
/// target that armed the delay / the widget whose hover or
|
|
462
|
+
/// focus-visible showed the tooltip). Ownership is a live claim,
|
|
463
|
+
/// not a memento: a rebuild that removes, rekeys, disables, or
|
|
464
|
+
/// re-parents the owner invalidates the slot in
|
|
465
|
+
/// `pruneCanvasTooltipIntent` — the tooltip node alone surviving
|
|
466
|
+
/// is not enough to keep explaining a control that no longer
|
|
467
|
+
/// exists.
|
|
468
|
+
canvas_tooltip_armed_owner_id: canvas.ObjectId = 0,
|
|
469
|
+
canvas_tooltip_shown_owner_id: canvas.ObjectId = 0,
|
|
470
|
+
/// The pointer's last position while it held the shown tooltip —
|
|
471
|
+
/// on the owning trigger (seeded at arm/show) or inside the shown
|
|
472
|
+
/// tooltip's own frame. It is the apex of the transit corridor
|
|
473
|
+
/// (`canvasTooltipTravelRegionContains`) a leave-move is judged
|
|
474
|
+
/// against, so the corridor always fans out from where the pointer
|
|
475
|
+
/// actually left. Meaningful only while a pointer-shown tooltip is
|
|
476
|
+
/// up; every value it is compared against comes from journaled
|
|
477
|
+
/// pointer events, so replay sees identical corridors.
|
|
478
|
+
canvas_tooltip_pointer_from: geometry.PointF = geometry.PointF.zero(),
|
|
479
|
+
/// Nonzero while the pointer has left both the trigger and the
|
|
480
|
+
/// shown tooltip's frame but is still inside the transit corridor
|
|
481
|
+
/// between them: the deadline (recorded clock) by which it must
|
|
482
|
+
/// arrive. Each in-corridor move re-arms it, so slow deliberate
|
|
483
|
+
/// transits stay open (WCAG 1.4.13 hoverable content) while a
|
|
484
|
+
/// pointer that parks in the gap resolves deterministically on the
|
|
485
|
+
/// frame clock. 0 means no transit is in flight.
|
|
486
|
+
canvas_tooltip_transit_deadline_ns: u64 = 0,
|
|
487
|
+
/// True when the shown tooltip was revealed by keyboard
|
|
488
|
+
/// focus-visible rather than pointer hover. Focus-shown tooltips
|
|
489
|
+
/// follow shadcn's Base UI-backed defaults: they open instantly on
|
|
490
|
+
/// focus-visible, hide on blur, ignore pointer hover leaving OTHER
|
|
491
|
+
/// triggers, and never open the pointer's warm window when they
|
|
492
|
+
/// hide (deliberate keyboard motion is not a pointer sweep).
|
|
493
|
+
canvas_tooltip_shown_from_focus: bool = false,
|
|
494
|
+
/// The pointer's last JOURNALED position over this view — every
|
|
495
|
+
/// phase that carries a trustworthy point (hover, move, down, up,
|
|
496
|
+
/// wheel) updates it; null before the first pointer event and after
|
|
497
|
+
/// a `.cancel` (the pointer-exit AppKit/GTK/Win32 hosts emit, and
|
|
498
|
+
/// gesture cancels). Point-blind scroll reconciliation (kinetic
|
|
499
|
+
/// steps, native drivers, keyboard scrolling) re-hit-tests this
|
|
500
|
+
/// position against the post-scroll tree — the pointer did not
|
|
501
|
+
/// move, so where it last stood is where it still is — and a null
|
|
502
|
+
/// here means those paths must CLOSE pointer tooltip intent rather
|
|
503
|
+
/// than guess (see
|
|
504
|
+
/// reconcileCanvasWidgetRenderStateAfterScrollWithTooltipIntent).
|
|
505
|
+
/// Journaled input only, so replay sees identical positions.
|
|
506
|
+
canvas_last_pointer_position: ?geometry.PointF = null,
|
|
430
507
|
/// Pointer position while the hovered widget draws hover-detail
|
|
431
508
|
/// chrome (a `.chart` with hover details opted in); null everywhere
|
|
432
509
|
/// else. Feeds `WidgetRenderState.hover_point`, so the display list
|
|
@@ -612,6 +689,15 @@ pub const RuntimeView = struct {
|
|
|
612
689
|
pub const canvasWidgetDismissibleSurfaceIndexForTarget = CanvasWidgetTreeMethods.canvasWidgetDismissibleSurfaceIndexForTarget;
|
|
613
690
|
pub const canvasWidgetAnchoredDismissibleChildIndex = CanvasWidgetTreeMethods.canvasWidgetAnchoredDismissibleChildIndex;
|
|
614
691
|
pub const canvasWidgetOwnedMenuSurfaceIndex = CanvasWidgetTreeMethods.canvasWidgetOwnedMenuSurfaceIndex;
|
|
692
|
+
pub const canvasWidgetOwnedTooltipIndex = CanvasWidgetTreeMethods.canvasWidgetOwnedTooltipIndex;
|
|
693
|
+
pub const canvasWidgetOwnedTooltipIdForOwner = CanvasWidgetTreeMethods.canvasWidgetOwnedTooltipIdForOwner;
|
|
694
|
+
pub const applyCanvasTooltipVisibility = CanvasWidgetTreeMethods.applyCanvasTooltipVisibility;
|
|
695
|
+
pub const applyCanvasTooltipVisibilityToNodes = CanvasWidgetTreeMethods.applyCanvasTooltipVisibilityToNodes;
|
|
696
|
+
pub const applyCanvasTooltipVisibilityToNodesForShownId = CanvasWidgetTreeMethods.applyCanvasTooltipVisibilityToNodesForShownId;
|
|
697
|
+
pub const pruneCanvasTooltipIntent = CanvasWidgetTreeMethods.pruneCanvasTooltipIntent;
|
|
698
|
+
pub const pruneCanvasTooltipIntentForLayout = CanvasWidgetTreeMethods.pruneCanvasTooltipIntentForLayout;
|
|
699
|
+
pub const canvasTooltipShownIdSurvivingLayout = CanvasWidgetTreeMethods.canvasTooltipShownIdSurvivingLayout;
|
|
700
|
+
pub const canvasTooltipIntentArmed = CanvasWidgetTreeMethods.canvasTooltipIntentArmed;
|
|
615
701
|
pub const canvasWidgetMenuSurfaceEntryId = CanvasWidgetTreeMethods.canvasWidgetMenuSurfaceEntryId;
|
|
616
702
|
pub const canvasWidgetAnchorTriggerFocusId = CanvasWidgetTreeMethods.canvasWidgetAnchorTriggerFocusId;
|
|
617
703
|
pub const canvasWidgetTopmostAnchoredDismissibleIndex = CanvasWidgetTreeMethods.canvasWidgetTopmostAnchoredDismissibleIndex;
|
|
@@ -63,7 +63,24 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
63
63
|
return newline_edit;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
// On a CLOSED combobox these same arrows are the trigger's
|
|
67
|
+
// OPEN keys (`widgetKeyboardControlIntent`'s menu-open
|
|
68
|
+
// mapping, which the app dispatch resolves BEFORE any
|
|
69
|
+
// stamped edit): platform convention is that opening wins
|
|
70
|
+
// and the caret does not move, so the derivation yields no
|
|
71
|
+
// edit and the retained editor agrees with the model's "no
|
|
72
|
+
// edit" verdict. The app-side fallback derivation for
|
|
73
|
+
// events that never crossed the runtime
|
|
74
|
+
// (`textEditEvent()`'s generic keymap) has no ArrowUp/Down
|
|
75
|
+
// arm at all, so both derivations stay in agreement. Once
|
|
76
|
+
// the picker is OPEN the focus step walks the arrows into
|
|
77
|
+
// the mounted menu before routing reaches the trigger; an
|
|
78
|
+
// arrow that still lands on an EXPANDED trigger (no
|
|
79
|
+
// focusable menu entry mounted) keeps the caret jump — the
|
|
80
|
+
// control resolver ignores it there, so both sides hear
|
|
81
|
+
// the same move.
|
|
82
|
+
const arrow_opens_combobox = widget.kind == .combobox and !(widget.state.expanded orelse false);
|
|
83
|
+
if (!arrow_opens_combobox and canvasWidgetSingleLineTextKind(widget.kind) and keyboard.phase == .key_down and keyboard.text.len == 0 and !keyboard.modifiers.hasNavigationModifier()) {
|
|
67
84
|
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowup")) return .{ .move_caret = .{ .direction = .start, .extend = keyboard.modifiers.shift } };
|
|
68
85
|
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowdown")) return .{ .move_caret = .{ .direction = .end, .extend = keyboard.modifiers.shift } };
|
|
69
86
|
}
|
|
@@ -295,6 +295,14 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
295
295
|
self.widget_tokens,
|
|
296
296
|
);
|
|
297
297
|
|
|
298
|
+
// Anchored-tooltip hover intent survives the rebuild the way
|
|
299
|
+
// hover/press ids do: drop state whose tooltip unmounted,
|
|
300
|
+
// then re-stamp runtime-owned visibility BEFORE semantics
|
|
301
|
+
// collect, so the a11y snapshot (and the replay fingerprint
|
|
302
|
+
// riding it) always reflects the intent machine.
|
|
303
|
+
self.pruneCanvasTooltipIntent();
|
|
304
|
+
self.applyCanvasTooltipVisibility();
|
|
305
|
+
|
|
298
306
|
const semantics = try self.widgetLayoutTree().collectSemantics(&self.widget_semantics_nodes);
|
|
299
307
|
applyCanvasWidgetSourceScrollSemantics(self.widget_semantics_nodes[0..semantics.len], &index_scratch.semantics);
|
|
300
308
|
self.widget_semantics_node_count = semantics.len;
|
|
@@ -302,9 +310,15 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
302
310
|
const return_id = if (focus_return_id != 0 and self.widgetLayoutTree().focusTargetById(focus_return_id) != null) focus_return_id else 0;
|
|
303
311
|
self.canvas_widget_focused_id = return_id;
|
|
304
312
|
self.canvas_widget_focus_visible_id = return_id;
|
|
313
|
+
// The focus-return ring is not a keyboard ARRIVAL:
|
|
314
|
+
// reveals fire only on focus-visible transitions (the
|
|
315
|
+
// dismissal seam's rule), so the returned ring never
|
|
316
|
+
// grants adoption-time tooltip reveals either.
|
|
317
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
305
318
|
}
|
|
306
319
|
if (self.canvas_widget_focus_visible_id != 0 and (self.canvas_widget_focus_visible_id != self.canvas_widget_focused_id or self.widgetLayoutTree().focusTargetById(self.canvas_widget_focus_visible_id) == null)) {
|
|
307
320
|
self.canvas_widget_focus_visible_id = 0;
|
|
321
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
308
322
|
}
|
|
309
323
|
if (self.canvas_widget_hovered_id != 0 and !canvasWidgetInteractionTargetExists(self.widgetLayoutTree(), self.canvas_widget_hovered_id)) {
|
|
310
324
|
self.canvas_widget_hovered_id = 0;
|
|
@@ -367,9 +381,11 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
367
381
|
if (self.canvas_widget_focused_id != 0 and layout.focusTargetById(self.canvas_widget_focused_id) == null) {
|
|
368
382
|
self.canvas_widget_focused_id = 0;
|
|
369
383
|
self.canvas_widget_focus_visible_id = 0;
|
|
384
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
370
385
|
}
|
|
371
386
|
if (self.canvas_widget_focus_visible_id != 0 and (self.canvas_widget_focus_visible_id != self.canvas_widget_focused_id or layout.focusTargetById(self.canvas_widget_focus_visible_id) == null)) {
|
|
372
387
|
self.canvas_widget_focus_visible_id = 0;
|
|
388
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
373
389
|
}
|
|
374
390
|
|
|
375
391
|
var next_hovered_id = self.canvas_widget_hovered_id;
|
|
@@ -407,6 +423,10 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
407
423
|
/// would leave Escape dead. A focused editable with live IME
|
|
408
424
|
/// composition always wins: Escape cancels the composition and
|
|
409
425
|
/// never dismisses a surface, not even through the fallback.
|
|
426
|
+
/// With SEVERAL surfaces anchored on one stack (the select
|
|
427
|
+
/// trigger's focus-shown tooltip floating over its open menu),
|
|
428
|
+
/// each Escape peels exactly one, topmost (last-mounted) first —
|
|
429
|
+
/// the tooltip goes, then the menu.
|
|
410
430
|
pub fn dismissCanvasWidgetSurfaceFromEscape(self: *RuntimeView, focused_id: canvas.ObjectId) anyerror!?CanvasWidgetSurfaceDismissal {
|
|
411
431
|
if (focused_id != 0) {
|
|
412
432
|
if (self.canvasWidgetNodeIndexById(focused_id)) |focused_index| {
|
|
@@ -424,12 +444,14 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
424
444
|
/// transient choice, so moving the keyboard on closes it WITHOUT
|
|
425
445
|
/// committing, exactly like a click outside. Scoped to menu
|
|
426
446
|
/// surfaces only: Tab through a persistent popover's form fields
|
|
427
|
-
/// must not tear the popover down.
|
|
447
|
+
/// must not tear the popover down. The lookup scans FOR menu
|
|
448
|
+
/// kinds rather than kind-checking whatever floats topmost — a
|
|
449
|
+
/// trigger can anchor a tooltip beside its menu, and the
|
|
450
|
+
/// focus-visible tooltip shadowing the open menu left Tab unable
|
|
451
|
+
/// to close it.
|
|
428
452
|
pub fn dismissCanvasWidgetMenuSurfaceForFocusDeparture(self: *RuntimeView, focused_id: canvas.ObjectId) anyerror!?CanvasWidgetSurfaceDismissal {
|
|
429
453
|
const focused_index = self.canvasWidgetNodeIndexById(focused_id) orelse return null;
|
|
430
|
-
const surface_index = self.
|
|
431
|
-
const kind = self.widget_layout_nodes[surface_index].widget.kind;
|
|
432
|
-
if (kind != .menu_surface and kind != .dropdown_menu) return null;
|
|
454
|
+
const surface_index = canvasWidgetSurfaceIndexForTargetInScope(self, focused_index, .menu) orelse return null;
|
|
433
455
|
return self.dismissCanvasWidgetSurfaceAtIndex(surface_index);
|
|
434
456
|
}
|
|
435
457
|
|
|
@@ -443,9 +465,16 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
443
465
|
return self.dismissCanvasWidgetSurfaceAtIndex(surface_index);
|
|
444
466
|
}
|
|
445
467
|
|
|
468
|
+
/// Outside-click light dismissal targets INTERACTIVE surfaces
|
|
469
|
+
/// only. A tooltip's whole lifecycle already belongs to the
|
|
470
|
+
/// intent machine's own causes on any outside down — hover
|
|
471
|
+
/// leave, focus moving with the click, the press itself — so
|
|
472
|
+
/// letting the topmost tooltip absorb this gesture would both
|
|
473
|
+
/// double-cover those and leave the menu beneath it floating
|
|
474
|
+
/// after the user clicked away.
|
|
446
475
|
pub fn dismissCanvasWidgetSurfaceForPointerOutsideFocusedTarget(self: *RuntimeView, focused_id: canvas.ObjectId, route: []const canvas.WidgetEventRouteEntry) anyerror!?CanvasWidgetSurfaceDismissal {
|
|
447
476
|
const focused_index = self.canvasWidgetNodeIndexById(focused_id) orelse return null;
|
|
448
|
-
const surface_index = self.
|
|
477
|
+
const surface_index = canvasWidgetSurfaceIndexForTargetInScope(self, focused_index, .interactive) orelse return null;
|
|
449
478
|
if (self.canvasWidgetRouteDescendsFromIndex(route, surface_index)) return null;
|
|
450
479
|
// Clicking the ANCHOR region of an anchored surface (the
|
|
451
480
|
// trigger, or the stack that wraps trigger + surface) is the
|
|
@@ -466,6 +495,46 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
466
495
|
if (surface.semantics.hidden) return null;
|
|
467
496
|
const dirty = self.canvasWidgetDirtyBounds(surface_index, surface.frame) orelse surface.frame;
|
|
468
497
|
self.widget_layout_nodes[surface_index].widget.semantics.hidden = true;
|
|
498
|
+
// A dismissed anchored tooltip leaves the intent machine too,
|
|
499
|
+
// or the next visibility stamp would undo the dismissal. No
|
|
500
|
+
// warm window: Escape is a deliberate dismissal, not the
|
|
501
|
+
// pointer moving on to the next trigger.
|
|
502
|
+
if (surface.kind == .tooltip) {
|
|
503
|
+
if (self.canvas_tooltip_shown_id == surface.id) {
|
|
504
|
+
// Covers the focus-shown path too: Escape on the
|
|
505
|
+
// focused trigger clears the reason flag with the
|
|
506
|
+
// slot, and focus (still on the trigger) does not
|
|
507
|
+
// re-reveal — reveals fire only on focus-visible
|
|
508
|
+
// TRANSITIONS, so tabbing away and back re-earns it.
|
|
509
|
+
// The one non-transition reveal — the adoption
|
|
510
|
+
// binding-reconcile, which honors a STANDING
|
|
511
|
+
// keyboard ring when a rebuild swaps the tooltip it
|
|
512
|
+
// owns — is blocked by consuming that standing
|
|
513
|
+
// intent here: when the ring rests on the dismissed
|
|
514
|
+
// tooltip's owner, the dismissal spends
|
|
515
|
+
// `canvas_widget_focus_visible_keyboard` (its only
|
|
516
|
+
// readers are the tooltip reveal gates; the ring
|
|
517
|
+
// itself renders from `canvas_widget_focus_visible_id`
|
|
518
|
+
// and stays painted), so a rebuild that rekeys the
|
|
519
|
+
// tooltip cannot resurrect it one frame after
|
|
520
|
+
// Escape. Same design as the keyboard-activation
|
|
521
|
+
// dismissal seam in canvas_widget_events.zig.
|
|
522
|
+
if (self.canvas_widget_focus_visible_id != 0 and
|
|
523
|
+
self.canvas_widget_focus_visible_id == self.canvas_tooltip_shown_owner_id)
|
|
524
|
+
{
|
|
525
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
526
|
+
}
|
|
527
|
+
self.canvas_tooltip_shown_id = 0;
|
|
528
|
+
self.canvas_tooltip_shown_owner_id = 0;
|
|
529
|
+
self.canvas_tooltip_transit_deadline_ns = 0;
|
|
530
|
+
self.canvas_tooltip_shown_from_focus = false;
|
|
531
|
+
}
|
|
532
|
+
if (self.canvas_tooltip_armed_id == surface.id) {
|
|
533
|
+
self.canvas_tooltip_armed_id = 0;
|
|
534
|
+
self.canvas_tooltip_armed_owner_id = 0;
|
|
535
|
+
self.canvas_tooltip_deadline_ns = 0;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
469
538
|
if (self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_focused_id, surface_index)) {
|
|
470
539
|
// A dismissal that swallows the focus returns it to the
|
|
471
540
|
// surface's own trigger when the surface is anchored (the
|
|
@@ -474,8 +543,15 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
474
543
|
const return_id = self.canvasWidgetAnchorTriggerFocusId(surface_index) orelse 0;
|
|
475
544
|
self.canvas_widget_focused_id = return_id;
|
|
476
545
|
self.canvas_widget_focus_visible_id = return_id;
|
|
546
|
+
// Same rule as the rebuild's focus return: a returned
|
|
547
|
+
// ring is not a keyboard arrival, so it earns no
|
|
548
|
+
// reveal — here or at a later layout adoption.
|
|
549
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
550
|
+
}
|
|
551
|
+
if (self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_focus_visible_id, surface_index)) {
|
|
552
|
+
self.canvas_widget_focus_visible_id = 0;
|
|
553
|
+
self.canvas_widget_focus_visible_keyboard = false;
|
|
477
554
|
}
|
|
478
|
-
if (self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_focus_visible_id, surface_index)) self.canvas_widget_focus_visible_id = 0;
|
|
479
555
|
if (self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_hovered_id, surface_index)) {
|
|
480
556
|
self.canvas_widget_hovered_id = 0;
|
|
481
557
|
self.canvas_widget_cursor = .arrow;
|
|
@@ -487,20 +563,59 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
487
563
|
return .{ .id = surface.id, .dirty = dirty };
|
|
488
564
|
}
|
|
489
565
|
|
|
566
|
+
/// Which anchored dismissible surfaces a lookup means to see. A
|
|
567
|
+
/// widget stack can anchor SEVERAL surfaces at once (a select
|
|
568
|
+
/// trigger with both its dropdown-menu and a tooltip), so every
|
|
569
|
+
/// consumer names the population it is really after — grabbing
|
|
570
|
+
/// "the anchored child" and kind-checking the winner let a
|
|
571
|
+
/// focus-visible tooltip shadow the open menu mounted before it.
|
|
572
|
+
pub const CanvasWidgetAnchoredSurfaceScope = enum {
|
|
573
|
+
/// Every dismissible surface, tooltips included. Escape and
|
|
574
|
+
/// the automation/accessibility dismiss actions peel
|
|
575
|
+
/// whatever floats TOPMOST, one surface per gesture.
|
|
576
|
+
any,
|
|
577
|
+
/// Surfaces that can hold interaction and keyboard focus —
|
|
578
|
+
/// everything but tooltips, which are hover chrome the
|
|
579
|
+
/// intent machine owns: outside-click dismissal and focus
|
|
580
|
+
/// scoping.
|
|
581
|
+
interactive,
|
|
582
|
+
/// Menu surfaces only (`menu_surface`/`dropdown_menu`): the
|
|
583
|
+
/// open-select keymap and Tab's focus-departure close.
|
|
584
|
+
menu,
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
fn canvasWidgetAnchoredSurfaceKindInScope(kind: canvas.WidgetKind, comptime scope: CanvasWidgetAnchoredSurfaceScope) bool {
|
|
588
|
+
if (!canvasWidgetDismissibleSurfaceKind(kind)) return false;
|
|
589
|
+
return switch (scope) {
|
|
590
|
+
.any => true,
|
|
591
|
+
.interactive => kind != .tooltip,
|
|
592
|
+
.menu => kind == .menu_surface or kind == .dropdown_menu,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
|
|
490
596
|
pub fn canvasWidgetDismissibleSurfaceIndexForTarget(self: *const RuntimeView, target_index: usize) ?usize {
|
|
597
|
+
return canvasWidgetSurfaceIndexForTargetInScope(self, target_index, .any);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/// The nearest in-scope surface up the target's chain: the first
|
|
601
|
+
/// visible dismissible ancestor, or an in-scope anchored surface
|
|
602
|
+
/// HANGING OFF an ancestor (the ancestor is its anchor) — Escape
|
|
603
|
+
/// on the focused trigger, or on the stack wrapping trigger +
|
|
604
|
+
/// surface, closes its own menu even though the surface is a
|
|
605
|
+
/// descendant, not an ancestor, of the focus. A visible ancestor
|
|
606
|
+
/// surface OUTSIDE the scope shields rather than defers: the
|
|
607
|
+
/// keyboard living in a persistent popover must not reach past
|
|
608
|
+
/// it to a menu further out.
|
|
609
|
+
fn canvasWidgetSurfaceIndexForTargetInScope(self: *const RuntimeView, target_index: usize, comptime scope: CanvasWidgetAnchoredSurfaceScope) ?usize {
|
|
491
610
|
if (target_index >= self.widget_layout_node_count) return null;
|
|
492
611
|
var current: ?usize = target_index;
|
|
493
612
|
while (current) |index| {
|
|
494
613
|
if (index >= self.widget_layout_node_count) return null;
|
|
495
614
|
const widget = self.widget_layout_nodes[index].widget;
|
|
496
|
-
if (canvasWidgetDismissibleSurfaceKind(widget.kind) and !widget.semantics.hidden)
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
// the stack wrapping trigger + surface — closes its own
|
|
501
|
-
// menu even though the surface is a descendant, not an
|
|
502
|
-
// ancestor, of the focus.
|
|
503
|
-
if (self.canvasWidgetAnchoredDismissibleChildIndex(index)) |surface_index| return surface_index;
|
|
615
|
+
if (canvasWidgetDismissibleSurfaceKind(widget.kind) and !widget.semantics.hidden) {
|
|
616
|
+
return if (canvasWidgetAnchoredSurfaceKindInScope(widget.kind, scope)) index else null;
|
|
617
|
+
}
|
|
618
|
+
if (canvasWidgetAnchoredChildIndexInScope(self, index, scope)) |surface_index| return surface_index;
|
|
504
619
|
current = self.widget_layout_nodes[index].parent_index;
|
|
505
620
|
}
|
|
506
621
|
return null;
|
|
@@ -509,11 +624,19 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
509
624
|
/// The topmost (last-mounted) visible anchored dismissible surface
|
|
510
625
|
/// whose anchor is `anchor_index`, or null.
|
|
511
626
|
pub fn canvasWidgetAnchoredDismissibleChildIndex(self: *const RuntimeView, anchor_index: usize) ?usize {
|
|
627
|
+
return canvasWidgetAnchoredChildIndexInScope(self, anchor_index, .any);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/// The topmost visible anchored child of `anchor_index` whose
|
|
631
|
+
/// kind is IN SCOPE — the scope filters DURING the scan, so an
|
|
632
|
+
/// out-of-scope sibling mounted later (the tooltip above the
|
|
633
|
+
/// menu) never masks the surface the caller asked for.
|
|
634
|
+
fn canvasWidgetAnchoredChildIndexInScope(self: *const RuntimeView, anchor_index: usize, comptime scope: CanvasWidgetAnchoredSurfaceScope) ?usize {
|
|
512
635
|
var found: ?usize = null;
|
|
513
636
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
|
|
514
637
|
if (node.parent_index != anchor_index) continue;
|
|
515
638
|
if (!canvas.widgetIsAnchored(node.widget)) continue;
|
|
516
|
-
if (!
|
|
639
|
+
if (!canvasWidgetAnchoredSurfaceKindInScope(node.widget.kind, scope)) continue;
|
|
517
640
|
if (node.widget.semantics.hidden) continue;
|
|
518
641
|
found = index;
|
|
519
642
|
}
|
|
@@ -533,10 +656,164 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
533
656
|
}
|
|
534
657
|
|
|
535
658
|
fn canvasWidgetAnchoredMenuChildIndex(self: *const RuntimeView, anchor_index: usize) ?usize {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
659
|
+
return canvasWidgetAnchoredChildIndexInScope(self, anchor_index, .menu);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/// The anchored tooltip a trigger owns: the last-mounted anchored
|
|
663
|
+
/// `.tooltip` child of the trigger itself or of its parent — the
|
|
664
|
+
/// stack wrapping trigger + tooltip, mirroring the anchored-menu
|
|
665
|
+
/// ownership shape. Deliberately IGNORES the hidden flag: the
|
|
666
|
+
/// runtime itself stamps non-shown anchored tooltips hidden, and
|
|
667
|
+
/// arming must find them to show them.
|
|
668
|
+
pub fn canvasWidgetOwnedTooltipIndex(self: *const RuntimeView, trigger_index: usize) ?usize {
|
|
669
|
+
return canvasWidgetOwnedTooltipIndexInNodes(self.widget_layout_nodes[0..self.widget_layout_node_count], trigger_index);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/// The ID of the anchored tooltip `owner_id` owns in the
|
|
673
|
+
/// CURRENT retained tree, or 0 (no such owner / no owned
|
|
674
|
+
/// tooltip). The layout-adoption reconcile compares this value
|
|
675
|
+
/// across a rebuild — captured against the outgoing tree in
|
|
676
|
+
/// `setCanvasWidgetLayout`, re-read against the adopted one —
|
|
677
|
+
/// to see a binding that changed beneath a STABLE owner: a
|
|
678
|
+
/// tooltip mounted, replaced, rekeyed, or reparented under a
|
|
679
|
+
/// trigger whose own ID survived produces no hover or focus
|
|
680
|
+
/// delta, so only this comparison can arm (or reveal) it.
|
|
681
|
+
pub fn canvasWidgetOwnedTooltipIdForOwner(self: *const RuntimeView, owner_id: canvas.ObjectId) canvas.ObjectId {
|
|
682
|
+
if (owner_id == 0) return 0;
|
|
683
|
+
const owner_index = self.canvasWidgetNodeIndexById(owner_id) orelse return 0;
|
|
684
|
+
const tooltip_index = self.canvasWidgetOwnedTooltipIndex(owner_index) orelse return 0;
|
|
685
|
+
return self.widget_layout_nodes[tooltip_index].widget.id;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/// Stamp hover-intent visibility onto every ANCHORED tooltip
|
|
689
|
+
/// node: hidden unless it is the intent machine's shown tooltip.
|
|
690
|
+
/// Anchored tooltips are runtime-owned chrome, so the stamp
|
|
691
|
+
/// overrides authored visibility; static (non-anchored) tooltips
|
|
692
|
+
/// are never touched. Runs at tree adoption (each rebuild) and
|
|
693
|
+
/// after every intent transition.
|
|
694
|
+
pub fn applyCanvasTooltipVisibility(self: *RuntimeView) void {
|
|
695
|
+
self.applyCanvasTooltipVisibilityToNodes(self.widget_layout_nodes[0..self.widget_layout_node_count]);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/// The same stamp over an arbitrary node slice, against the
|
|
699
|
+
/// view's LIVE shown register.
|
|
700
|
+
pub fn applyCanvasTooltipVisibilityToNodes(self: *const RuntimeView, nodes: []canvas.WidgetLayoutNode) void {
|
|
701
|
+
applyCanvasTooltipVisibilityToNodesForShownId(self, nodes, self.canvas_tooltip_shown_id);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/// The stamp against an EXPLICIT shown id. The rebuild path
|
|
705
|
+
/// normalizes the RECONCILED scratch tree with it BEFORE diffing
|
|
706
|
+
/// against the retained tree (see `setCanvasWidgetLayout`),
|
|
707
|
+
/// passing the PROSPECTIVE prune verdict from
|
|
708
|
+
/// `canvasTooltipShownIdSurvivingLayout` rather than mutating
|
|
709
|
+
/// the live registers first: the retained side carries the
|
|
710
|
+
/// intent machine's hidden stamps while the source declares
|
|
711
|
+
/// authored visibility, so diffing them un-normalized reported
|
|
712
|
+
/// the runtime's own stamp as a spurious visibility
|
|
713
|
+
/// invalidation on every rebuild that contained a hidden
|
|
714
|
+
/// anchored tooltip — and mutating the registers before the
|
|
715
|
+
/// fallible adoption steps left a FAILED adoption with the old
|
|
716
|
+
/// tree stamped visible and cleared registers (an unhideable
|
|
717
|
+
/// tooltip).
|
|
718
|
+
pub fn applyCanvasTooltipVisibilityToNodesForShownId(self: *const RuntimeView, nodes: []canvas.WidgetLayoutNode, shown_id: canvas.ObjectId) void {
|
|
719
|
+
_ = self;
|
|
720
|
+
for (nodes) |*node| {
|
|
721
|
+
if (node.widget.kind != .tooltip) continue;
|
|
722
|
+
if (!canvas.widgetIsAnchored(node.widget)) continue;
|
|
723
|
+
node.widget.semantics.hidden = node.widget.id == 0 or node.widget.id != shown_id;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/// Drop intent state whose tooltip OR owning trigger left the
|
|
728
|
+
/// tree on a rebuild — the interaction-id pruning policy
|
|
729
|
+
/// hovered/pressed ids follow, applied to both ends of the
|
|
730
|
+
/// tooltip binding. The tooltip node surviving is not enough:
|
|
731
|
+
/// a trigger that vanished, was rekeyed (a new id is a new
|
|
732
|
+
/// widget), re-parented away from its tooltip, or disabled
|
|
733
|
+
/// (disabled widgets leave both hover and focus routing, so
|
|
734
|
+
/// nothing could ever hide the tooltip again) invalidates the
|
|
735
|
+
/// slot, and the pruned slot re-stamps hidden through the
|
|
736
|
+
/// `applyCanvasTooltipVisibility` call that follows adoption.
|
|
737
|
+
/// The warm window survives rebuilds that keep the bindings
|
|
738
|
+
/// alive (warmth belongs to the pointer, not to any one
|
|
739
|
+
/// widget), but a pruned binding closes it: instant re-shows
|
|
740
|
+
/// earned against widgets the rebuild replaced are not earned
|
|
741
|
+
/// at all.
|
|
742
|
+
pub fn pruneCanvasTooltipIntent(self: *RuntimeView) void {
|
|
743
|
+
self.pruneCanvasTooltipIntentForLayout(self.widgetLayoutTree());
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/// The same prune against an arbitrary layout. Runs inside
|
|
747
|
+
/// `copyWidgetLayoutTree` against the freshly retained tree —
|
|
748
|
+
/// AFTER every fallible adoption step has succeeded, which is
|
|
749
|
+
/// what keeps the registers transactional: the rebuild path's
|
|
750
|
+
/// pre-diff stamp reads only the VERDICT
|
|
751
|
+
/// (`canvasTooltipShownIdSurvivingLayout`) so a failed adoption
|
|
752
|
+
/// leaves both the old tree and the registers that can hide its
|
|
753
|
+
/// tooltip intact.
|
|
754
|
+
pub fn pruneCanvasTooltipIntentForLayout(self: *RuntimeView, layout: canvas.WidgetLayoutTree) void {
|
|
755
|
+
if (self.canvas_tooltip_armed_id != 0 and !canvasTooltipIntentBindingAlive(layout, self.canvas_tooltip_armed_id, self.canvas_tooltip_armed_owner_id, false)) {
|
|
756
|
+
self.canvas_tooltip_armed_id = 0;
|
|
757
|
+
self.canvas_tooltip_armed_owner_id = 0;
|
|
758
|
+
self.canvas_tooltip_deadline_ns = 0;
|
|
759
|
+
self.canvas_tooltip_warm_until_ns = 0;
|
|
760
|
+
}
|
|
761
|
+
if (self.canvas_tooltip_shown_id != 0 and !canvasTooltipIntentBindingAlive(layout, self.canvas_tooltip_shown_id, self.canvas_tooltip_shown_owner_id, self.canvas_tooltip_shown_from_focus)) {
|
|
762
|
+
self.canvas_tooltip_shown_id = 0;
|
|
763
|
+
self.canvas_tooltip_shown_owner_id = 0;
|
|
764
|
+
self.canvas_tooltip_shown_from_focus = false;
|
|
765
|
+
self.canvas_tooltip_warm_until_ns = 0;
|
|
766
|
+
self.canvas_tooltip_transit_deadline_ns = 0;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/// The shown-tooltip prune VERDICT against a prospective
|
|
771
|
+
/// layout, WITHOUT the register mutation: the shown id that
|
|
772
|
+
/// would survive adopting `layout`, or 0 when the rebuild kills
|
|
773
|
+
/// the binding. `setCanvasWidgetLayout` stamps the reconciled
|
|
774
|
+
/// scratch tree with this ahead of the diff (so the diff
|
|
775
|
+
/// reports the hide a binding-breaking rebuild really causes,
|
|
776
|
+
/// and an unchanged rebuild diffs clean) while the live
|
|
777
|
+
/// registers stay untouched until the fallible adoption steps —
|
|
778
|
+
/// the diff itself and the retained-pool validation/copy —
|
|
779
|
+
/// succeed; `copyWidgetLayoutTree`'s own prune then applies the
|
|
780
|
+
/// same verdict for real. A failed adoption therefore leaves
|
|
781
|
+
/// the OLD tree with the registers that own its stamps: the
|
|
782
|
+
/// tooltip that is still painted is still hideable.
|
|
783
|
+
pub fn canvasTooltipShownIdSurvivingLayout(self: *const RuntimeView, layout: canvas.WidgetLayoutTree) canvas.ObjectId {
|
|
784
|
+
if (self.canvas_tooltip_shown_id == 0) return 0;
|
|
785
|
+
if (!canvasTooltipIntentBindingAlive(layout, self.canvas_tooltip_shown_id, self.canvas_tooltip_shown_owner_id, self.canvas_tooltip_shown_from_focus)) return 0;
|
|
786
|
+
return self.canvas_tooltip_shown_id;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/// Both ends of a tooltip intent slot are still live: the
|
|
790
|
+
/// tooltip node exists and is anchored, its recorded owner
|
|
791
|
+
/// still exists AND still resolves to this very tooltip
|
|
792
|
+
/// (`canvasWidgetOwnedTooltipIndex`, the inverse of the arming
|
|
793
|
+
/// walk), and the owner remains reachable by the routing that
|
|
794
|
+
/// earned the slot — focus targeting for focus-shown tooltips,
|
|
795
|
+
/// hover/interaction targeting for pointer ones. Both
|
|
796
|
+
/// predicates already reject disabled and hidden widgets, so
|
|
797
|
+
/// "the trigger can no longer be left" implies "the tooltip
|
|
798
|
+
/// must not stay".
|
|
799
|
+
fn canvasTooltipIntentBindingAlive(layout: canvas.WidgetLayoutTree, tooltip_id: canvas.ObjectId, owner_id: canvas.ObjectId, from_focus: bool) bool {
|
|
800
|
+
const tooltip_index = canvasWidgetNodeIndexByIdInNodes(layout.nodes, tooltip_id) orelse return false;
|
|
801
|
+
const tooltip_widget = layout.nodes[tooltip_index].widget;
|
|
802
|
+
if (tooltip_widget.kind != .tooltip or !canvas.widgetIsAnchored(tooltip_widget)) return false;
|
|
803
|
+
const owner_index = canvasWidgetNodeIndexByIdInNodes(layout.nodes, owner_id) orelse return false;
|
|
804
|
+
const owned_index = canvasWidgetOwnedTooltipIndexInNodes(layout.nodes, owner_index) orelse return false;
|
|
805
|
+
if (owned_index != tooltip_index) return false;
|
|
806
|
+
if (from_focus) return layout.focusTargetById(owner_id) != null;
|
|
807
|
+
return canvasWidgetInteractionTargetExists(layout, owner_id);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/// True while the intent machine needs presented frames to keep
|
|
811
|
+
/// coming: an armed show delay and a running transit grace both
|
|
812
|
+
/// fire only on a frame timestamp, so the frame pump
|
|
813
|
+
/// re-invalidates until they resolve (the render-animation
|
|
814
|
+
/// pump's policy exactly).
|
|
815
|
+
pub fn canvasTooltipIntentArmed(self: *const RuntimeView) bool {
|
|
816
|
+
return self.canvas_tooltip_armed_id != 0 or self.canvas_tooltip_transit_deadline_ns != 0;
|
|
540
817
|
}
|
|
541
818
|
|
|
542
819
|
/// Keyboard entry point into an anchored menu surface: the marked
|
|
@@ -611,9 +888,14 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
611
888
|
return false;
|
|
612
889
|
}
|
|
613
890
|
|
|
891
|
+
/// Tab cycling scopes to the INTERACTIVE surface around the
|
|
892
|
+
/// focus: a tooltip can never hold a focus target, so scoping to
|
|
893
|
+
/// one (the trigger's visible tooltip shadowing its popover or
|
|
894
|
+
/// menu) would always come up empty and spill the keyboard out
|
|
895
|
+
/// of the trap into the page's global walk.
|
|
614
896
|
pub fn canvasWidgetScopedFocusTarget(self: *const RuntimeView, current_id: canvas.ObjectId, direction: canvas.WidgetFocusDirection) ?canvas.WidgetFocusTarget {
|
|
615
897
|
const current_index = self.canvasWidgetNodeIndexById(current_id) orelse return null;
|
|
616
|
-
const surface_index = self.
|
|
898
|
+
const surface_index = canvasWidgetSurfaceIndexForTargetInScope(self, current_index, .interactive) orelse return null;
|
|
617
899
|
return self.canvasWidgetFocusTargetInScope(surface_index, current_index, direction);
|
|
618
900
|
}
|
|
619
901
|
|
|
@@ -841,3 +1123,40 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
841
1123
|
}
|
|
842
1124
|
};
|
|
843
1125
|
}
|
|
1126
|
+
|
|
1127
|
+
/// Node index by widget id over a bare node slice — the retained
|
|
1128
|
+
/// tree's `canvasWidgetNodeIndexById` generalized so the tooltip
|
|
1129
|
+
/// binding checks can run against the RECONCILED scratch tree before
|
|
1130
|
+
/// adoption (the pre-diff visibility normalization) exactly as they
|
|
1131
|
+
/// run against the retained one.
|
|
1132
|
+
fn canvasWidgetNodeIndexByIdInNodes(nodes: []const canvas.WidgetLayoutNode, id: canvas.ObjectId) ?usize {
|
|
1133
|
+
if (id == 0) return null;
|
|
1134
|
+
for (nodes, 0..) |node, index| {
|
|
1135
|
+
if (node.widget.id == id) return index;
|
|
1136
|
+
}
|
|
1137
|
+
return null;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/// The anchored tooltip a trigger owns, over a bare node slice: the
|
|
1141
|
+
/// last-mounted anchored `.tooltip` child of the trigger itself or of
|
|
1142
|
+
/// its parent — the stack-wraps-trigger-plus-tooltip ownership shape,
|
|
1143
|
+
/// mirroring the anchored-menu walk. Deliberately IGNORES the hidden
|
|
1144
|
+
/// flag: the runtime itself stamps non-shown anchored tooltips hidden,
|
|
1145
|
+
/// and arming must find them to show them.
|
|
1146
|
+
fn canvasWidgetOwnedTooltipIndexInNodes(nodes: []const canvas.WidgetLayoutNode, trigger_index: usize) ?usize {
|
|
1147
|
+
if (trigger_index >= nodes.len) return null;
|
|
1148
|
+
if (canvasWidgetAnchoredTooltipChildIndexInNodes(nodes, trigger_index)) |tooltip_index| return tooltip_index;
|
|
1149
|
+
const parent_index = nodes[trigger_index].parent_index orelse return null;
|
|
1150
|
+
return canvasWidgetAnchoredTooltipChildIndexInNodes(nodes, parent_index);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
fn canvasWidgetAnchoredTooltipChildIndexInNodes(nodes: []const canvas.WidgetLayoutNode, anchor_index: usize) ?usize {
|
|
1154
|
+
var found: ?usize = null;
|
|
1155
|
+
for (nodes, 0..) |node, index| {
|
|
1156
|
+
if (node.parent_index != anchor_index) continue;
|
|
1157
|
+
if (node.widget.kind != .tooltip) continue;
|
|
1158
|
+
if (!canvas.widgetIsAnchored(node.widget)) continue;
|
|
1159
|
+
found = index;
|
|
1160
|
+
}
|
|
1161
|
+
return found;
|
|
1162
|
+
}
|
|
@@ -223,6 +223,32 @@ pub fn canvasWidgetAccessibilityActionKindFromPlatform(action: platform.WidgetAc
|
|
|
223
223
|
.decrement => .decrement,
|
|
224
224
|
.set_text => .set_text,
|
|
225
225
|
.set_selection => .set_selection,
|
|
226
|
+
.set_composition => .set_composition,
|
|
227
|
+
.commit_composition => .commit_composition,
|
|
228
|
+
.cancel_composition => .cancel_composition,
|
|
229
|
+
.select => .select,
|
|
230
|
+
.drag => .drag,
|
|
231
|
+
.drop_files => .drop_files,
|
|
232
|
+
.dismiss => .dismiss,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/// The inverse of `canvasWidgetAccessibilityActionKindFromPlatform`: the
|
|
237
|
+
/// direct verb surfaces (embed hosts, automation `widget_action`
|
|
238
|
+
/// commands) reach the dispatch without a platform event, and the
|
|
239
|
+
/// session journal needs one to record the verb outer-wins.
|
|
240
|
+
pub fn platformWidgetAccessibilityActionKindFromCanvas(action: CanvasWidgetAccessibilityActionKind) platform.WidgetAccessibilityActionKind {
|
|
241
|
+
return switch (action) {
|
|
242
|
+
.focus => .focus,
|
|
243
|
+
.press => .press,
|
|
244
|
+
.toggle => .toggle,
|
|
245
|
+
.increment => .increment,
|
|
246
|
+
.decrement => .decrement,
|
|
247
|
+
.set_text => .set_text,
|
|
248
|
+
.set_selection => .set_selection,
|
|
249
|
+
.set_composition => .set_composition,
|
|
250
|
+
.commit_composition => .commit_composition,
|
|
251
|
+
.cancel_composition => .cancel_composition,
|
|
226
252
|
.select => .select,
|
|
227
253
|
.drag => .drag,
|
|
228
254
|
.drop_files => .drop_files,
|