@native-sdk/cli 0.9.1 → 0.9.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/app.zig +26 -9
- package/build.zig +124 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/packages/core/sdk/events.d.ts +7 -0
- package/packages/core/sdk/events.ts +26 -5
- package/packages/core/sdk/text.d.ts +4 -0
- package/packages/core/sdk/text.ts +51 -0
- package/packages/core/src/checker.ts +58 -1
- package/packages/core/src/contract.ts +5 -4
- package/packages/core/src/devhost_journal.mjs +2 -2
- package/packages/core/src/diagnostics.ts +2 -2
- package/packages/core/src/service_contract.ts +10 -0
- package/packages/core/src/typed_ast.ts +9 -7
- package/packages/core/src/types.ts +28 -8
- package/skill-data/automation/SKILL.md +4 -3
- package/skill-data/native-ui/SKILL.md +10 -8
- package/skill-data/ts-core/SKILL.md +8 -5
- package/src/app_runner/root.zig +301 -12
- package/src/app_runner/ts_core_main.zig +6 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +119 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +271 -52
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +222 -14
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +129 -1
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +14 -2
- package/src/primitives/canvas/text_interaction.zig +23 -0
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +65 -0
- package/src/primitives/canvas/ui.zig +66 -10
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +67 -6
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +84 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +593 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +33 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/canvas_widget_text_tests.zig +124 -0
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +29 -0
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_journal.zig +21 -2
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ts_ui_app.zig +164 -1
- package/src/runtime/ui_app.zig +100 -21
- package/src/runtime/ui_app_tests.zig +351 -32
- package/src/runtime/ui_app_window_tests.zig +13 -1
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_text.zig +1 -1
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +128 -18
- package/src/tooling/verbs.zig +1 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +31 -12
- package/tools/corewire/emit_facade.zig +57 -2
- package/tools/corewire/shim_rt.zig +20 -0
|
@@ -223,9 +223,21 @@ pub fn restoreCanvasWidgetLayoutScrollOffsets(
|
|
|
223
223
|
nodes: []canvas.WidgetLayoutNode,
|
|
224
224
|
previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
225
225
|
previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
226
|
+
) void {
|
|
227
|
+
restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(nodes, previous_runtime_offsets, previous_source_offsets, null);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
fn restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(
|
|
231
|
+
nodes: []canvas.WidgetLayoutNode,
|
|
232
|
+
previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
233
|
+
previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
234
|
+
anchored_depth: ?usize,
|
|
226
235
|
) void {
|
|
227
236
|
for (nodes, 0..) |node, index| {
|
|
228
237
|
if (node.widget.kind != .scroll_view or node.widget.id == 0) continue;
|
|
238
|
+
if (anchored_depth) |depth| {
|
|
239
|
+
if (canvas.anchoredNestingDepth(nodes, index) != depth) continue;
|
|
240
|
+
}
|
|
229
241
|
const previous_runtime = canvasWidgetSourceScrollEntryById(previous_runtime_offsets, node.widget.id) orelse continue;
|
|
230
242
|
const previous_source = canvasWidgetSourceScrollEntryById(previous_source_offsets, node.widget.id) orelse continue;
|
|
231
243
|
// Each axis reconciles on its own: a programmatic vertical
|
|
@@ -268,10 +280,14 @@ fn clampCanvasWidgetLayoutProgrammaticScrollOffsets(
|
|
|
268
280
|
source: canvas.WidgetLayoutTree,
|
|
269
281
|
previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
270
282
|
previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
283
|
+
anchored_depth: ?usize,
|
|
271
284
|
) void {
|
|
272
285
|
for (nodes, 0..) |node, index| {
|
|
273
286
|
if (node.widget.kind != .scroll_view or node.widget.id == 0) continue;
|
|
274
287
|
if (node.widget.layout.virtualized and !canvas.widgetVirtualRuntimeScrolled(node.widget)) continue;
|
|
288
|
+
if (anchored_depth) |depth| {
|
|
289
|
+
if (canvas.anchoredNestingDepth(nodes, index) != depth) continue;
|
|
290
|
+
}
|
|
275
291
|
|
|
276
292
|
const source_node = source.findById(node.widget.id) orelse continue;
|
|
277
293
|
const previous_runtime = canvasWidgetSourceScrollEntryById(previous_runtime_offsets, node.widget.id);
|
|
@@ -326,11 +342,14 @@ fn previousLayoutHasSelectedTab(previous: canvas.WidgetLayoutTree, id: canvas.Ob
|
|
|
326
342
|
/// viewport. This runs after retained scroll restoration, against final layout
|
|
327
343
|
/// frames, so an already-visible tab preserves the exact offset and a newly
|
|
328
344
|
/// mounted native scroll driver never paints a speculative leading-edge jump.
|
|
329
|
-
fn revealNewlySelectedTabs(previous: canvas.WidgetLayoutTree, nodes: []canvas.WidgetLayoutNode) void {
|
|
345
|
+
fn revealNewlySelectedTabs(previous: canvas.WidgetLayoutTree, nodes: []canvas.WidgetLayoutNode, anchored_depth: ?usize) void {
|
|
330
346
|
for (nodes, 0..) |tab_node, tab_index| {
|
|
331
347
|
const tab = tab_node.widget;
|
|
332
348
|
if (tab.semantics.role != .tab or !tab.state.selected) continue;
|
|
333
349
|
if (tab.id != 0 and previousLayoutHasSelectedTab(previous, tab.id)) continue;
|
|
350
|
+
if (anchored_depth) |depth| {
|
|
351
|
+
if (canvas.anchoredNestingDepth(nodes, tab_index) != depth) continue;
|
|
352
|
+
}
|
|
334
353
|
|
|
335
354
|
var ancestor = tab_node.parent_index;
|
|
336
355
|
while (ancestor) |index| {
|
|
@@ -490,9 +509,9 @@ pub fn canvasWidgetLayoutNodeFrameVisible(layout: canvas.WidgetLayoutTree, node_
|
|
|
490
509
|
if (frame.isEmpty()) return false;
|
|
491
510
|
var current: usize = node_index;
|
|
492
511
|
while (true) {
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
if (canvas.
|
|
512
|
+
// Window-level surfaces render in the hoisted pass and escape
|
|
513
|
+
// ancestor clip regions.
|
|
514
|
+
if (canvas.widgetEscapesAncestorClips(layout.nodes[current].widget)) return true;
|
|
496
515
|
const index = layout.nodes[current].parent_index orelse return true;
|
|
497
516
|
if (index >= layout.nodes.len) return true;
|
|
498
517
|
const ancestor = layout.nodes[index];
|
|
@@ -510,9 +529,9 @@ pub fn canvasWidgetLayoutNodeClippedBounds(layout: canvas.WidgetLayoutTree, node
|
|
|
510
529
|
|
|
511
530
|
var current: usize = node_index;
|
|
512
531
|
while (true) {
|
|
513
|
-
//
|
|
514
|
-
//
|
|
515
|
-
if (canvas.
|
|
532
|
+
// Window-level surfaces escape ancestor clip regions, so dirty
|
|
533
|
+
// bounds under them clip to the window only.
|
|
534
|
+
if (canvas.widgetEscapesAncestorClips(layout.nodes[current].widget)) break;
|
|
516
535
|
const index = layout.nodes[current].parent_index orelse break;
|
|
517
536
|
if (index >= layout.nodes.len) return null;
|
|
518
537
|
const ancestor = layout.nodes[index];
|
|
@@ -531,7 +550,7 @@ pub fn canvasWidgetClipsContent(widget: canvas.Widget) bool {
|
|
|
531
550
|
|
|
532
551
|
pub fn canvasWidgetRuntimeHitTarget(widget: canvas.Widget) bool {
|
|
533
552
|
// Widget-level hit-target-ness lives in one place (canvas
|
|
534
|
-
// widget_access.zig: kind predicate plus bound press/toggle handlers)
|
|
553
|
+
// widget_access.zig: kind predicate plus bound press/toggle/drag handlers)
|
|
535
554
|
// so the runtime, the engines' hit test, and the markup validation of
|
|
536
555
|
// pointer handlers can never drift.
|
|
537
556
|
return canvas.widgetIsHitTarget(widget);
|
|
@@ -1031,11 +1050,19 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1031
1050
|
&text_len,
|
|
1032
1051
|
);
|
|
1033
1052
|
|
|
1034
|
-
//
|
|
1035
|
-
//
|
|
1036
|
-
//
|
|
1037
|
-
//
|
|
1038
|
-
// own
|
|
1053
|
+
// Geometry reconciles in anchored-surface strata. The authored source
|
|
1054
|
+
// layout is first finalized outside every surface, then direct anchored
|
|
1055
|
+
// children are replayed against that final geometry. Runtime-owned
|
|
1056
|
+
// scroll/split/tab state inside those surfaces is restored before their
|
|
1057
|
+
// own nested surfaces replay, and so on. A surface replay can therefore
|
|
1058
|
+
// recover authored intrinsic sizing without erasing already-finalized
|
|
1059
|
+
// descendant state.
|
|
1060
|
+
//
|
|
1061
|
+
// Within each stratum split fractions reconcile FIRST, as a staged copy
|
|
1062
|
+
// of the laid-out tree, so the per-node passes below see final geometry.
|
|
1063
|
+
// Outer splits restore before nested ones (ascending node order), so a
|
|
1064
|
+
// nested split re-laid (or slid) by its ancestor still restores its own
|
|
1065
|
+
// fraction afterwards. Two restore shapes:
|
|
1039
1066
|
// - SETTLED runtime-owned fraction (a past drag, no tween in
|
|
1040
1067
|
// flight): re-run the split's child layout in place — content
|
|
1041
1068
|
// honestly wraps at the restored width;
|
|
@@ -1048,63 +1075,78 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1048
1075
|
// frame at a time (the disclosure doctrine, horizontal).
|
|
1049
1076
|
const staged_nodes = node_buffer[0..next.nodes.len];
|
|
1050
1077
|
@memcpy(staged_nodes, next.nodes);
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1078
|
+
const staged_root_bounds = next.root_bounds orelse if (staged_nodes.len > 0) staged_nodes[0].frame else geometry.RectF.init(0, 0, 0, 0);
|
|
1079
|
+
const max_anchored_depth = canvas.maxAnchoredNestingDepth(staged_nodes);
|
|
1080
|
+
var anchored_depth: usize = 0;
|
|
1081
|
+
while (anchored_depth <= max_anchored_depth) : (anchored_depth += 1) {
|
|
1082
|
+
for (staged_nodes, 0..) |node, index| {
|
|
1083
|
+
if (node.widget.kind != .split or node.widget.id == 0) continue;
|
|
1084
|
+
if (canvas.anchoredNestingDepth(staged_nodes, index) != anchored_depth) continue;
|
|
1085
|
+
const tween_armed = objectIdInList(armed_split_tween_ids, node.widget.id);
|
|
1086
|
+
const previous_runtime = canvasWidgetSourceScrollById(previous_runtime_offsets, node.widget.id) orelse {
|
|
1087
|
+
// A FRESH split (no retained fraction): a declared enter
|
|
1088
|
+
// origin slides the first layout's boundary to the origin
|
|
1089
|
+
// pose — children keep the declared value's (target) wrap —
|
|
1090
|
+
// so the tween armed right after this reconcile eases it in
|
|
1091
|
+
// instead of the mount popping to its value.
|
|
1092
|
+
if (node.widget.resize_duration_ms != 0 and node.widget.resize_origin >= 0 and node.widget.children.len != 0) {
|
|
1093
|
+
canvas.slideSplitChildren(node.frame, node.widget.resize_origin, index, staged_nodes);
|
|
1094
|
+
}
|
|
1095
|
+
continue;
|
|
1096
|
+
};
|
|
1097
|
+
const previous_source = canvasWidgetSourceScrollById(previous_source_scroll_entries, node.widget.id) orelse continue;
|
|
1098
|
+
// Source-wins: the runtime-owned fraction survives rebuilds only
|
|
1099
|
+
// while the SOURCE fraction is unchanged; a source-side change
|
|
1100
|
+
// (the model echoing or driving the fraction) wins — UNLESS the
|
|
1101
|
+
// split declares a layout tween (`resize_duration_ms` nonzero)
|
|
1102
|
+
// or one is already in flight: then the moved source value is a
|
|
1103
|
+
// TARGET, the rendered fraction stays where it is, and the
|
|
1104
|
+
// runtime's tween lowering (armed right after this reconcile
|
|
1105
|
+
// lands, in setCanvasWidgetLayout) eases it there one presented
|
|
1106
|
+
// frame at a time. Reduced motion still snaps: the tween
|
|
1107
|
+
// lowering's snap path applies the target through this same
|
|
1108
|
+
// mutation family in the same rebuild.
|
|
1109
|
+
const source_moved = node.widget.value != previous_source;
|
|
1110
|
+
if (source_moved and node.widget.resize_duration_ms == 0 and !tween_armed) continue;
|
|
1111
|
+
if (node.widget.value == previous_runtime) continue;
|
|
1112
|
+
staged_nodes[index].widget.value = previous_runtime;
|
|
1113
|
+
// Retained trees clear children; a split without them keeps the
|
|
1114
|
+
// value restore only (frames follow on the next full layout).
|
|
1115
|
+
if (node.widget.children.len == 0) continue;
|
|
1116
|
+
// A pressed divider is a live drag: its echo rebuilds must keep
|
|
1117
|
+
// re-wrapping at the dragged width (the pinned drag behavior),
|
|
1118
|
+
// so the slide shape only applies to tween-owned motion.
|
|
1119
|
+
const dragging = pressed_split_id != 0 and node.widget.id == pressed_split_id;
|
|
1120
|
+
if (!dragging and (tween_armed or (source_moved and node.widget.resize_duration_ms != 0))) {
|
|
1121
|
+
canvas.slideSplitChildren(node.frame, previous_runtime, index, staged_nodes);
|
|
1122
|
+
} else {
|
|
1123
|
+
try canvas.relayoutSplitChildren(staged_nodes[index].widget, node.frame, index, node.depth, node_buffer, staged_root_bounds, tokens);
|
|
1062
1124
|
}
|
|
1063
|
-
continue;
|
|
1064
|
-
};
|
|
1065
|
-
const previous_source = canvasWidgetSourceScrollById(previous_source_scroll_entries, node.widget.id) orelse continue;
|
|
1066
|
-
// Source-wins: the runtime-owned fraction survives rebuilds only
|
|
1067
|
-
// while the SOURCE fraction is unchanged; a source-side change
|
|
1068
|
-
// (the model echoing or driving the fraction) wins — UNLESS the
|
|
1069
|
-
// split declares a layout tween (`resize_duration_ms` nonzero)
|
|
1070
|
-
// or one is already in flight: then the moved source value is a
|
|
1071
|
-
// TARGET, the rendered fraction stays where it is, and the
|
|
1072
|
-
// runtime's tween lowering (armed right after this reconcile
|
|
1073
|
-
// lands, in setCanvasWidgetLayout) eases it there one presented
|
|
1074
|
-
// frame at a time. Reduced motion still snaps: the tween
|
|
1075
|
-
// lowering's snap path applies the target through this same
|
|
1076
|
-
// mutation family in the same rebuild.
|
|
1077
|
-
const source_moved = node.widget.value != previous_source;
|
|
1078
|
-
if (source_moved and node.widget.resize_duration_ms == 0 and !tween_armed) continue;
|
|
1079
|
-
if (node.widget.value == previous_runtime) continue;
|
|
1080
|
-
staged_nodes[index].widget.value = previous_runtime;
|
|
1081
|
-
// Retained trees clear children; a split without them keeps the
|
|
1082
|
-
// value restore only (frames follow on the next full layout).
|
|
1083
|
-
if (node.widget.children.len == 0) continue;
|
|
1084
|
-
// A pressed divider is a live drag: its echo rebuilds must keep
|
|
1085
|
-
// re-wrapping at the dragged width (the pinned drag behavior),
|
|
1086
|
-
// so the slide shape only applies to tween-owned motion.
|
|
1087
|
-
const dragging = pressed_split_id != 0 and node.widget.id == pressed_split_id;
|
|
1088
|
-
if (!dragging and (tween_armed or (source_moved and node.widget.resize_duration_ms != 0))) {
|
|
1089
|
-
canvas.slideSplitChildren(node.frame, previous_runtime, index, staged_nodes);
|
|
1090
|
-
} else {
|
|
1091
|
-
try canvas.relayoutSplitChildren(staged_nodes[index].widget, node.frame, index, node.depth, node_buffer, tokens);
|
|
1092
1125
|
}
|
|
1093
|
-
}
|
|
1094
1126
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1127
|
+
// Scroll restore is staged too (after splits, so translated frames
|
|
1128
|
+
// are final geometry): the retained offset comes back WITH its
|
|
1129
|
+
// descendants translated to match. Engine-side clamping happens at
|
|
1130
|
+
// the caller AFTER native scroll drivers are stamped — a rebuild
|
|
1131
|
+
// mid-rubber-band must not clamp an offset the OS scroller owns.
|
|
1132
|
+
restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(
|
|
1133
|
+
staged_nodes,
|
|
1134
|
+
previous_runtime_offsets,
|
|
1135
|
+
previous_source_scroll_entries,
|
|
1136
|
+
anchored_depth,
|
|
1137
|
+
);
|
|
1138
|
+
clampCanvasWidgetLayoutProgrammaticScrollOffsets(
|
|
1139
|
+
staged_nodes,
|
|
1140
|
+
next,
|
|
1141
|
+
previous_runtime_offsets,
|
|
1142
|
+
previous_source_scroll_entries,
|
|
1143
|
+
anchored_depth,
|
|
1144
|
+
);
|
|
1145
|
+
revealNewlySelectedTabs(previous, staged_nodes, anchored_depth);
|
|
1146
|
+
if (anchored_depth < max_anchored_depth) {
|
|
1147
|
+
try canvas.relayoutAnchoredChildrenAtDepth(staged_nodes, staged_root_bounds, tokens, anchored_depth);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1108
1150
|
|
|
1109
1151
|
const index_scratch = canvas_widget_reconcile_index_scratch.get();
|
|
1110
1152
|
index_scratch.controls.build(previous_control_states);
|
|
@@ -1112,7 +1154,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1112
1154
|
index_scratch.texts.build(previous_text_states);
|
|
1113
1155
|
index_scratch.semantics.build(source_semantics);
|
|
1114
1156
|
|
|
1115
|
-
const staged = canvas.WidgetLayoutTree{ .nodes = staged_nodes };
|
|
1157
|
+
const staged = canvas.WidgetLayoutTree{ .nodes = staged_nodes, .root_bounds = next.root_bounds };
|
|
1116
1158
|
for (staged_nodes, 0..) |node, index| {
|
|
1117
1159
|
const text_copy = canvasWidgetLayoutNodeWithTextReconcileState(node, staged, index, &index_scratch.texts);
|
|
1118
1160
|
const control_copy = canvasWidgetLayoutNodeWithControlReconcileState(text_copy, staged, index, &index_scratch.controls, &index_scratch.source_controls);
|
|
@@ -1120,7 +1162,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1120
1162
|
}
|
|
1121
1163
|
const reconciled = node_buffer[0..next.nodes.len];
|
|
1122
1164
|
clampCanvasWidgetLayoutTextOffsets(reconciled, tokens);
|
|
1123
|
-
return .{ .nodes = reconciled };
|
|
1165
|
+
return .{ .nodes = reconciled, .root_bounds = next.root_bounds };
|
|
1124
1166
|
}
|
|
1125
1167
|
|
|
1126
1168
|
pub fn canvasWidgetLayoutNodeWithSourceSemantics(
|
|
@@ -1151,7 +1193,24 @@ pub fn applyCanvasWidgetSourceScrollSemantics(
|
|
|
1151
1193
|
}
|
|
1152
1194
|
}
|
|
1153
1195
|
|
|
1154
|
-
pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, states: ?[]canvas.ScrollState) void {
|
|
1196
|
+
pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, states: ?[]canvas.ScrollState, root_bounds: ?geometry.RectF, tokens: canvas.DesignTokens) anyerror!void {
|
|
1197
|
+
try clampCanvasWidgetLayoutScrollOffsetsImpl(nodes, states, root_bounds, tokens, true);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/// The staged rebuild reconcile already replayed anchored surfaces in
|
|
1201
|
+
/// top-down strata. Its final engine clamp must not replay them a second
|
|
1202
|
+
/// time: at this point their descendants carry restored runtime state.
|
|
1203
|
+
pub fn clampCanvasWidgetLayoutScrollOffsetsAfterReconcile(nodes: []canvas.WidgetLayoutNode, states: ?[]canvas.ScrollState, root_bounds: ?geometry.RectF, tokens: canvas.DesignTokens) anyerror!void {
|
|
1204
|
+
try clampCanvasWidgetLayoutScrollOffsetsImpl(nodes, states, root_bounds, tokens, false);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
fn clampCanvasWidgetLayoutScrollOffsetsImpl(
|
|
1208
|
+
nodes: []canvas.WidgetLayoutNode,
|
|
1209
|
+
states: ?[]canvas.ScrollState,
|
|
1210
|
+
root_bounds: ?geometry.RectF,
|
|
1211
|
+
tokens: canvas.DesignTokens,
|
|
1212
|
+
relayout_anchored: bool,
|
|
1213
|
+
) anyerror!void {
|
|
1155
1214
|
for (nodes, 0..) |node, index| {
|
|
1156
1215
|
if (node.widget.kind != .scroll_view) continue;
|
|
1157
1216
|
// Legacy virtualized containers are model-driven: the source
|
|
@@ -1234,6 +1293,9 @@ pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, st
|
|
|
1234
1293
|
}
|
|
1235
1294
|
}
|
|
1236
1295
|
}
|
|
1296
|
+
if (relayout_anchored and nodes.len > 0) {
|
|
1297
|
+
try canvas.relayoutAnchoredChildrenWithRootBounds(nodes, root_bounds orelse nodes[0].frame, tokens);
|
|
1298
|
+
}
|
|
1237
1299
|
}
|
|
1238
1300
|
|
|
1239
1301
|
pub fn clampCanvasWidgetLayoutTextOffsets(nodes: []canvas.WidgetLayoutNode, tokens: canvas.DesignTokens) void {
|
|
@@ -1273,6 +1335,10 @@ pub fn canvasWidgetLayoutScrollContentExtent(nodes: []const canvas.WidgetLayoutN
|
|
|
1273
1335
|
var bottom = viewport.maxY();
|
|
1274
1336
|
var index = scroll_index + 1;
|
|
1275
1337
|
while (index < nodes.len and nodes[index].depth > scroll_depth) {
|
|
1338
|
+
if (canvas.widgetIsRootRelativeModal(nodes[index].widget)) {
|
|
1339
|
+
index = skipCanvasWidgetSubtree(nodes, index);
|
|
1340
|
+
continue;
|
|
1341
|
+
}
|
|
1276
1342
|
// A subtree anchored DIRECTLY to the scroll region stays
|
|
1277
1343
|
// stationary while content scrolls (its anchor base never
|
|
1278
1344
|
// moves), so `frame + offset` is not a content-space position
|
|
@@ -1296,7 +1362,7 @@ pub fn canvasWidgetLayoutScrollContentExtent(nodes: []const canvas.WidgetLayoutN
|
|
|
1296
1362
|
/// content pins to the viewport width. Three subtree exclusions keep the
|
|
1297
1363
|
/// range honest — each names blank space the user could otherwise scroll
|
|
1298
1364
|
/// to (or live content they otherwise could not reach):
|
|
1299
|
-
/// -
|
|
1365
|
+
/// - WINDOW-LEVEL floating subtrees are out of flow and window-clipped;
|
|
1300
1366
|
/// an open dropdown to the right of the viewport is not content;
|
|
1301
1367
|
/// - a NESTED CLIP SCOPE (scroll view, `clip_content` surface,
|
|
1302
1368
|
/// virtualized container) bounds its own children — its frame is
|
|
@@ -1315,7 +1381,7 @@ pub fn canvasWidgetLayoutScrollContentExtentX(nodes: []const canvas.WidgetLayout
|
|
|
1315
1381
|
var index = scroll_index + 1;
|
|
1316
1382
|
while (index < nodes.len and nodes[index].depth > scroll_depth) {
|
|
1317
1383
|
const node = nodes[index];
|
|
1318
|
-
if (node.widget
|
|
1384
|
+
if (canvas.widgetEscapesAncestorClips(node.widget)) {
|
|
1319
1385
|
index = skipCanvasWidgetSubtree(nodes, index);
|
|
1320
1386
|
continue;
|
|
1321
1387
|
}
|
|
@@ -1341,18 +1407,21 @@ fn skipCanvasWidgetSubtree(nodes: []const canvas.WidgetLayoutNode, index: usize)
|
|
|
1341
1407
|
return next;
|
|
1342
1408
|
}
|
|
1343
1409
|
|
|
1344
|
-
/// Scrolled content carries its descendants — including floating
|
|
1345
|
-
///
|
|
1346
|
-
///
|
|
1347
|
-
/// own frame, which never moves when
|
|
1348
|
-
/// live-scroll translate applies the same
|
|
1410
|
+
/// Scrolled content carries its descendants — including floating surfaces
|
|
1411
|
+
/// anchored to widgets INSIDE it — but root-relative modal surfaces never
|
|
1412
|
+
/// ride content, and a surface anchored to the SCROLL REGION ITSELF stays
|
|
1413
|
+
/// put: its anchor base is the region's own frame, which never moves when
|
|
1414
|
+
/// the content under it does (the live-scroll translate applies the same
|
|
1415
|
+
/// rule).
|
|
1349
1416
|
pub fn translateCanvasWidgetLayoutScrollDescendants(nodes: []canvas.WidgetLayoutNode, scroll_index: usize, offset: geometry.OffsetF) void {
|
|
1350
1417
|
if (scroll_index >= nodes.len) return;
|
|
1351
1418
|
const scroll_depth = nodes[scroll_index].depth;
|
|
1352
1419
|
var index = scroll_index + 1;
|
|
1353
1420
|
while (index < nodes.len and nodes[index].depth > scroll_depth) {
|
|
1354
1421
|
const node = nodes[index];
|
|
1355
|
-
if (node.widget
|
|
1422
|
+
if (canvas.widgetIsRootRelativeModal(node.widget) or
|
|
1423
|
+
node.widget.layout.anchor != null and node.parent_index == scroll_index)
|
|
1424
|
+
{
|
|
1356
1425
|
index = skipCanvasWidgetSubtree(nodes, index);
|
|
1357
1426
|
continue;
|
|
1358
1427
|
}
|
|
@@ -1472,7 +1541,14 @@ pub fn canvasWidgetSpatialFocusAllowed(layout: canvas.WidgetLayoutTree, focused:
|
|
|
1472
1541
|
.data_cell => true,
|
|
1473
1542
|
.list_item, .menu_item => same_parent and (direction == .up or direction == .down),
|
|
1474
1543
|
.segmented_control => same_parent and (direction == .left or direction == .right),
|
|
1475
|
-
.radio =>
|
|
1544
|
+
.radio => blk: {
|
|
1545
|
+
const focused_scope = canvasWidgetRadioGroupScopeIndex(layout, focused.index);
|
|
1546
|
+
const target_scope = canvasWidgetRadioGroupScopeIndex(layout, target.index);
|
|
1547
|
+
if (focused_scope != null or target_scope != null) {
|
|
1548
|
+
break :blk focused_scope != null and focused_scope == target_scope;
|
|
1549
|
+
}
|
|
1550
|
+
break :blk same_parent;
|
|
1551
|
+
},
|
|
1476
1552
|
.button, .icon_button => same_parent and canvasWidgetParentAllowsHorizontalButtonFocus(canvasWidgetFocusParentKind(layout, focused)) and (direction == .left or direction == .right),
|
|
1477
1553
|
.toggle_button => same_parent and canvasWidgetParentAllowsHorizontalToggleFocus(canvasWidgetFocusParentKind(layout, focused)) and (direction == .left or direction == .right),
|
|
1478
1554
|
else => false,
|
|
@@ -1521,6 +1597,7 @@ pub const CanvasWidgetGroupDirection = enum {
|
|
|
1521
1597
|
};
|
|
1522
1598
|
|
|
1523
1599
|
pub fn canvasWidgetGroupDirectionalFocusTarget(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, direction: canvas.WidgetFocusDirection) ?canvas.WidgetFocusTarget {
|
|
1600
|
+
if (canvasWidgetRadioGroupDirectionalFocusTarget(layout, focused, direction)) |target| return target;
|
|
1524
1601
|
if (focused.index >= layout.nodes.len) return null;
|
|
1525
1602
|
const parent_index = layout.nodes[focused.index].parent_index orelse return null;
|
|
1526
1603
|
if (parent_index >= layout.nodes.len) return null;
|
|
@@ -1543,10 +1620,6 @@ pub fn canvasWidgetGroupDirectionForFocus(parent_kind: canvas.WidgetKind, child_
|
|
|
1543
1620
|
canvasWidgetHorizontalGroupDirection(direction)
|
|
1544
1621
|
else
|
|
1545
1622
|
null,
|
|
1546
|
-
.radio_group => if (child_kind == .radio)
|
|
1547
|
-
canvasWidgetAnyAxisGroupDirection(direction)
|
|
1548
|
-
else
|
|
1549
|
-
null,
|
|
1550
1623
|
.list => if (child_kind == .list_item)
|
|
1551
1624
|
canvasWidgetVerticalGroupDirection(direction)
|
|
1552
1625
|
else
|
|
@@ -1559,6 +1632,163 @@ pub fn canvasWidgetGroupDirectionForFocus(parent_kind: canvas.WidgetKind, child_
|
|
|
1559
1632
|
};
|
|
1560
1633
|
}
|
|
1561
1634
|
|
|
1635
|
+
// --------------------------------------------------- radio-group focus
|
|
1636
|
+
//
|
|
1637
|
+
// Radios at ANY depth under their nearest `radio_group` ancestor form
|
|
1638
|
+
// one logical, roving-focus set. Node order is the authored/DFS order;
|
|
1639
|
+
// logical targets intentionally omit only scroll clipping so keyboard
|
|
1640
|
+
// focus can reveal an offscreen radio before committing to it.
|
|
1641
|
+
|
|
1642
|
+
/// Index of the nearest `.radio_group` ancestor, or null for a bare
|
|
1643
|
+
/// radio (and for any other node outside a radio group).
|
|
1644
|
+
pub fn canvasWidgetRadioGroupScopeIndex(layout: canvas.WidgetLayoutTree, node_index: usize) ?usize {
|
|
1645
|
+
if (node_index >= layout.nodes.len) return null;
|
|
1646
|
+
var current = layout.nodes[node_index].parent_index;
|
|
1647
|
+
while (current) |index| {
|
|
1648
|
+
if (index >= layout.nodes.len) return null;
|
|
1649
|
+
if (layout.nodes[index].widget.kind == .radio_group) return index;
|
|
1650
|
+
current = layout.nodes[index].parent_index;
|
|
1651
|
+
}
|
|
1652
|
+
return null;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
/// The radio-scoped form of a future-general roving Tab scope. Keeping
|
|
1656
|
+
/// the scope identity separate from traversal lets tabs/toolbars adopt
|
|
1657
|
+
/// the same entry/exit contract later without changing radio behavior.
|
|
1658
|
+
pub const CanvasWidgetRovingTabScope = struct {
|
|
1659
|
+
kind: enum { radio_group },
|
|
1660
|
+
index: usize,
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
pub fn canvasWidgetRovingTabScope(layout: canvas.WidgetLayoutTree, node_index: usize) ?CanvasWidgetRovingTabScope {
|
|
1664
|
+
if (node_index >= layout.nodes.len or layout.nodes[node_index].widget.kind != .radio) return null;
|
|
1665
|
+
return .{ .kind = .radio_group, .index = canvasWidgetRadioGroupScopeIndex(layout, node_index) orelse return null };
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
fn canvasWidgetRadioGroupFocusTarget(
|
|
1669
|
+
layout: canvas.WidgetLayoutTree,
|
|
1670
|
+
radio_group_index: usize,
|
|
1671
|
+
node_index: usize,
|
|
1672
|
+
) ?canvas.WidgetFocusTarget {
|
|
1673
|
+
if (node_index >= layout.nodes.len or layout.nodes[node_index].widget.kind != .radio) return null;
|
|
1674
|
+
if (canvasWidgetRadioGroupScopeIndex(layout, node_index) != radio_group_index) return null;
|
|
1675
|
+
return canvasWidgetLogicalFocusTarget(layout, node_index);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
/// The group's one Tab entry: selected focusable radio, else first
|
|
1679
|
+
/// focusable radio. Selection may be represented by state or value.
|
|
1680
|
+
pub fn canvasWidgetRovingTabEntryTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
|
|
1681
|
+
if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
|
|
1682
|
+
const scope_depth = layout.nodes[scope.index].depth;
|
|
1683
|
+
var first: ?canvas.WidgetFocusTarget = null;
|
|
1684
|
+
var index = scope.index + 1;
|
|
1685
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
|
|
1686
|
+
const target = canvasWidgetRadioGroupFocusTarget(layout, scope.index, index) orelse continue;
|
|
1687
|
+
if (first == null) first = target;
|
|
1688
|
+
if (canvasWidgetSelectableSelected(layout.nodes[index].widget)) return target;
|
|
1689
|
+
}
|
|
1690
|
+
return first;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/// The flat Tab order position occupied by a radio-group scope. It is
|
|
1694
|
+
/// deliberately the first CURRENTLY VISIBLE radio in authored order,
|
|
1695
|
+
/// rather than the selected entry: selection may live after another
|
|
1696
|
+
/// nested radio group (or an ordinary control) and must not move this
|
|
1697
|
+
/// composite's position around those intervening Tab stops.
|
|
1698
|
+
pub fn canvasWidgetRovingTabStopTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
|
|
1699
|
+
if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
|
|
1700
|
+
const scope_depth = layout.nodes[scope.index].depth;
|
|
1701
|
+
var index = scope.index + 1;
|
|
1702
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
|
|
1703
|
+
if (layout.nodes[index].widget.kind != .radio) continue;
|
|
1704
|
+
if (canvasWidgetRadioGroupScopeIndex(layout, index) != scope.index) continue;
|
|
1705
|
+
if (layout.focusTargetById(layout.nodes[index].widget.id)) |target| return target;
|
|
1706
|
+
}
|
|
1707
|
+
return null;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
/// The group's best CURRENTLY VISIBLE Tab entry. The ordinary entry
|
|
1711
|
+
/// resolver above intentionally admits scroll-clipped logical targets so
|
|
1712
|
+
/// focus can reveal them. Callers use this narrower fallback only after a
|
|
1713
|
+
/// logical target could not be revealed (for example under a fixed
|
|
1714
|
+
/// `clip_content` card), keeping the group reachable without committing
|
|
1715
|
+
/// an invisible focus id.
|
|
1716
|
+
pub fn canvasWidgetRovingTabVisibleEntryTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
|
|
1717
|
+
if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
|
|
1718
|
+
const scope_depth = layout.nodes[scope.index].depth;
|
|
1719
|
+
var first: ?canvas.WidgetFocusTarget = null;
|
|
1720
|
+
var index = scope.index + 1;
|
|
1721
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
|
|
1722
|
+
if (layout.nodes[index].widget.kind != .radio) continue;
|
|
1723
|
+
if (canvasWidgetRadioGroupScopeIndex(layout, index) != scope.index) continue;
|
|
1724
|
+
const target = layout.focusTargetById(layout.nodes[index].widget.id) orelse continue;
|
|
1725
|
+
if (first == null) first = target;
|
|
1726
|
+
if (canvasWidgetSelectableSelected(layout.nodes[index].widget)) return target;
|
|
1727
|
+
}
|
|
1728
|
+
return first;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
pub fn canvasWidgetRadioGroupDirectionalFocusTarget(
|
|
1732
|
+
layout: canvas.WidgetLayoutTree,
|
|
1733
|
+
focused: canvas.WidgetFocusTarget,
|
|
1734
|
+
direction: canvas.WidgetFocusDirection,
|
|
1735
|
+
) ?canvas.WidgetFocusTarget {
|
|
1736
|
+
if (focused.kind != .radio or focused.index >= layout.nodes.len) return null;
|
|
1737
|
+
const scope_index = canvasWidgetRadioGroupScopeIndex(layout, focused.index) orelse return null;
|
|
1738
|
+
const group_direction = canvasWidgetAnyAxisGroupDirection(direction) orelse return null;
|
|
1739
|
+
return canvasWidgetRadioGroupAdjacentRadio(layout, scope_index, focused.index, group_direction) orelse focused;
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
pub fn canvasWidgetRadioGroupFocusEdgeTarget(
|
|
1743
|
+
layout: canvas.WidgetLayoutTree,
|
|
1744
|
+
focused: canvas.WidgetFocusTarget,
|
|
1745
|
+
edge: CanvasWidgetGroupFocusEdge,
|
|
1746
|
+
) ?canvas.WidgetFocusTarget {
|
|
1747
|
+
if (focused.kind != .radio or focused.index >= layout.nodes.len) return null;
|
|
1748
|
+
const scope_index = canvasWidgetRadioGroupScopeIndex(layout, focused.index) orelse return null;
|
|
1749
|
+
if (scope_index >= layout.nodes.len) return null;
|
|
1750
|
+
const scope_depth = layout.nodes[scope_index].depth;
|
|
1751
|
+
var last: ?canvas.WidgetFocusTarget = null;
|
|
1752
|
+
var index = scope_index + 1;
|
|
1753
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
|
|
1754
|
+
const target = canvasWidgetRadioGroupFocusTarget(layout, scope_index, index) orelse continue;
|
|
1755
|
+
if (edge == .first) return target;
|
|
1756
|
+
last = target;
|
|
1757
|
+
}
|
|
1758
|
+
return last;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
fn canvasWidgetRadioGroupAdjacentRadio(
|
|
1762
|
+
layout: canvas.WidgetLayoutTree,
|
|
1763
|
+
scope_index: usize,
|
|
1764
|
+
focused_index: usize,
|
|
1765
|
+
direction: CanvasWidgetGroupDirection,
|
|
1766
|
+
) ?canvas.WidgetFocusTarget {
|
|
1767
|
+
if (scope_index >= layout.nodes.len) return null;
|
|
1768
|
+
const scope_depth = layout.nodes[scope_index].depth;
|
|
1769
|
+
var first: ?canvas.WidgetFocusTarget = null;
|
|
1770
|
+
var last: ?canvas.WidgetFocusTarget = null;
|
|
1771
|
+
var previous: ?canvas.WidgetFocusTarget = null;
|
|
1772
|
+
var saw_focused = false;
|
|
1773
|
+
var index = scope_index + 1;
|
|
1774
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
|
|
1775
|
+
if (index == focused_index) {
|
|
1776
|
+
if (direction == .previous and previous != null) return previous;
|
|
1777
|
+
saw_focused = true;
|
|
1778
|
+
continue;
|
|
1779
|
+
}
|
|
1780
|
+
const target = canvasWidgetRadioGroupFocusTarget(layout, scope_index, index) orelse continue;
|
|
1781
|
+
if (first == null) first = target;
|
|
1782
|
+
last = target;
|
|
1783
|
+
if (direction == .next and saw_focused) return target;
|
|
1784
|
+
if (!saw_focused) previous = target;
|
|
1785
|
+
}
|
|
1786
|
+
return switch (direction) {
|
|
1787
|
+
.previous => last,
|
|
1788
|
+
.next => first,
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1562
1792
|
pub fn canvasWidgetHorizontalGroupDirection(direction: canvas.WidgetFocusDirection) ?CanvasWidgetGroupDirection {
|
|
1563
1793
|
return switch (direction) {
|
|
1564
1794
|
.left => .previous,
|
|
@@ -1642,25 +1872,14 @@ fn canvasWidgetTreeRowFocusTarget(layout: canvas.WidgetLayoutTree, node_index: u
|
|
|
1642
1872
|
return canvasWidgetLogicalFocusTarget(layout, node_index);
|
|
1643
1873
|
}
|
|
1644
1874
|
|
|
1645
|
-
///
|
|
1646
|
-
/// scroll ancestor clips
|
|
1647
|
-
/// other focus gate (identity, disabled/hidden state, hidden
|
|
1648
|
-
/// concealed disclosure content), but deliberately omit only the
|
|
1649
|
-
/// clip check performed by `WidgetLayoutTree.focusTargetById`. The
|
|
1650
|
-
/// scrolls this target into view before
|
|
1651
|
-
fn canvasWidgetLogicalFocusTarget(layout: canvas.WidgetLayoutTree, node_index: usize) ?canvas.WidgetFocusTarget {
|
|
1652
|
-
|
|
1653
|
-
if (canvas.isWidgetHiddenInAncestors(layout, node_index)) return null;
|
|
1654
|
-
if (canvas.isWidgetConcealedByDisclosure(layout, node_index)) return null;
|
|
1655
|
-
const node = layout.nodes[node_index];
|
|
1656
|
-
if (!canvas.widgetIsFocusable(node.widget)) return null;
|
|
1657
|
-
return .{
|
|
1658
|
-
.id = node.widget.id,
|
|
1659
|
-
.kind = node.widget.kind,
|
|
1660
|
-
.bounds = node.frame,
|
|
1661
|
-
.index = node_index,
|
|
1662
|
-
.state = node.widget.state,
|
|
1663
|
-
};
|
|
1875
|
+
/// Keyboard roving and programmatic focus must be able to name a LOGICAL
|
|
1876
|
+
/// target even when a scroll ancestor clips it out of the current viewport.
|
|
1877
|
+
/// Keep every other focus gate (identity, disabled/hidden state, hidden
|
|
1878
|
+
/// ancestors, concealed disclosure content), but deliberately omit only the
|
|
1879
|
+
/// geometry clip check performed by `WidgetLayoutTree.focusTargetById`. The
|
|
1880
|
+
/// shared reveal seam scrolls this target into view before focus commits.
|
|
1881
|
+
pub fn canvasWidgetLogicalFocusTarget(layout: canvas.WidgetLayoutTree, node_index: usize) ?canvas.WidgetFocusTarget {
|
|
1882
|
+
return layout.logicalFocusTargetAtIndex(node_index);
|
|
1664
1883
|
}
|
|
1665
1884
|
|
|
1666
1885
|
/// The tree keymap's focus moves. Up/Down walk the scope's rows in node
|
|
@@ -1796,6 +2015,7 @@ fn canvasWidgetTreeFirstChildRow(layout: canvas.WidgetLayoutTree, tree_index: us
|
|
|
1796
2015
|
}
|
|
1797
2016
|
|
|
1798
2017
|
pub fn canvasWidgetGroupFocusEdgeTarget(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, edge: CanvasWidgetGroupFocusEdge) ?canvas.WidgetFocusTarget {
|
|
2018
|
+
if (canvasWidgetRadioGroupFocusEdgeTarget(layout, focused, edge)) |target| return target;
|
|
1799
2019
|
if (!canvasWidgetGroupHomeEndFocusKind(layout, focused)) return null;
|
|
1800
2020
|
if (focused.index >= layout.nodes.len) return null;
|
|
1801
2021
|
const parent_index = layout.nodes[focused.index].parent_index;
|
|
@@ -845,3 +845,37 @@ test "floating surfaces push occluders that block underlying drivers but not the
|
|
|
845
845
|
try std.testing.expectEqual(@as(u64, 0), drivers[0].parent_id);
|
|
846
846
|
try std.testing.expectEqual(@as(u64, 1), drivers[1].parent_id);
|
|
847
847
|
}
|
|
848
|
+
|
|
849
|
+
test "lower-layer later surfaces do not occlude a modal scroll driver" {
|
|
850
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
851
|
+
defer harness.destroy(std.testing.allocator);
|
|
852
|
+
harness.null_platform.gpu_surfaces = true;
|
|
853
|
+
harness.null_platform.gpu_surface_scroll_drivers = true;
|
|
854
|
+
var app_state: PassiveApp = .{};
|
|
855
|
+
try harness.start(app_state.app());
|
|
856
|
+
|
|
857
|
+
_ = try harness.runtime.createView(.{
|
|
858
|
+
.window_id = 1,
|
|
859
|
+
.label = "canvas",
|
|
860
|
+
.kind = .gpu_surface,
|
|
861
|
+
.frame = geometry.RectF.init(0, 0, 240, 160),
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
// The modal mounts before a default anchored popover, but its effective
|
|
865
|
+
// layer is higher. Its nested scroll driver must therefore ignore both
|
|
866
|
+
// its own modal catcher and the later surface painted beneath it.
|
|
867
|
+
const nodes = [_]canvas.WidgetLayoutNode{
|
|
868
|
+
.{ .widget = .{ .id = 1, .kind = .stack }, .frame = geometry.RectF.init(0, 0, 240, 160), .depth = 0 },
|
|
869
|
+
.{ .widget = .{ .id = 10, .kind = .dialog, .scrim = true }, .frame = geometry.RectF.init(20, 20, 200, 120), .depth = 1, .parent_index = 0 },
|
|
870
|
+
.{ .widget = .{ .id = 11, .kind = .scroll_view }, .frame = geometry.RectF.init(30, 30, 180, 80), .depth = 2, .parent_index = 1 },
|
|
871
|
+
.{ .widget = .{ .id = 12, .kind = .panel }, .frame = geometry.RectF.init(30, 30, 180, 200), .depth = 3, .parent_index = 2 },
|
|
872
|
+
.{ .widget = .{ .id = 20, .kind = .popover, .layout = .{ .anchor = .{} } }, .frame = geometry.RectF.init(40, 40, 100, 60), .depth = 1, .parent_index = 0 },
|
|
873
|
+
};
|
|
874
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", .{ .nodes = &nodes });
|
|
875
|
+
|
|
876
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.scroll_occluder_count);
|
|
877
|
+
const drivers = harness.null_platform.scrollDrivers();
|
|
878
|
+
try std.testing.expectEqual(@as(usize, 1), drivers.len);
|
|
879
|
+
try std.testing.expectEqual(@as(u64, 11), drivers[0].id);
|
|
880
|
+
try std.testing.expectEqual(@as(u32, 0), drivers[0].occluder_mask);
|
|
881
|
+
}
|