@native-sdk/cli 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +905 -61
- package/build.zig +674 -373
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +6 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +455 -3
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +214 -2
- package/packages/core/sdk/core.ts +715 -42
- package/packages/core/sdk/events.d.ts +50 -0
- package/packages/core/sdk/events.ts +75 -0
- package/packages/core/src/checker.ts +528 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1849 -18
- package/packages/core/src/devhost_journal.mjs +181 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +84 -18
- package/packages/core/src/frontend.ts +204 -34
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/core/SKILL.md +4 -2
- package/skill-data/core/references/project-anatomy.md +3 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
- package/skill-data/native-ui/SKILL.md +55 -8
- package/skill-data/ts-core/SKILL.md +92 -40
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +603 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +104 -4
- package/src/app_runner/ts_core_main.zig +268 -4
- package/src/automation/snapshot.zig +23 -5
- package/src/embed/app_exports.zig +11 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +115 -1
- package/src/embed/root.zig +7 -0
- package/src/embed/tests.zig +213 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +121 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +1 -1
- package/src/platform/linux/gtk_host.c +89 -17
- package/src/platform/linux/gtk_host.h +3 -0
- package/src/platform/linux/root.zig +41 -18
- package/src/platform/macos/appkit_host.h +26 -3
- package/src/platform/macos/appkit_host.m +1051 -129
- package/src/platform/macos/capture_info_plist.c +25 -0
- package/src/platform/macos/cef_host.mm +270 -36
- package/src/platform/macos/root.zig +312 -34
- package/src/platform/null_platform.zig +281 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +16 -0
- package/src/platform/types.zig +279 -15
- package/src/platform/windows/root.zig +243 -21
- package/src/platform/windows/webview2_host.cpp +464 -46
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +34 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/primitives/canvas/code_tests.zig +9 -9
- package/src/primitives/canvas/events.zig +12 -11
- package/src/primitives/canvas/frame.zig +44 -9
- package/src/primitives/canvas/icons/mic.svg +1 -0
- package/src/primitives/canvas/icons.zig +2 -0
- package/src/primitives/canvas/root.zig +8 -0
- package/src/primitives/canvas/text_span_tests.zig +39 -0
- package/src/primitives/canvas/ui.zig +23 -4
- package/src/primitives/canvas/ui_markup.zig +15 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
- package/src/primitives/canvas/ui_markup_tests.zig +5 -0
- package/src/primitives/canvas/ui_markup_view.zig +9 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
- package/src/primitives/canvas/ui_schema.zig +19 -10
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +18 -4
- package/src/primitives/canvas/widget_invalidation.zig +9 -2
- package/src/primitives/canvas/widget_render.zig +296 -114
- package/src/primitives/canvas/widget_runtime_tests.zig +133 -0
- package/src/primitives/canvas/widget_text_input.zig +10 -10
- package/src/primitives/canvas/widget_tree.zig +1 -1
- package/src/primitives/canvas/widgets.zig +29 -5
- package/src/root.zig +56 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +1 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +31 -13
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
- package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
- package/src/runtime/canvas_widget_events.zig +69 -24
- package/src/runtime/canvas_widget_runtime.zig +101 -6
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
- package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
- package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
- package/src/runtime/canvas_widget_state.zig +6 -1
- package/src/runtime/canvas_widget_text_tests.zig +112 -3
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +133 -1
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +2568 -75
- package/src/runtime/effects_audio_capture_tests.zig +251 -0
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/flow.zig +14 -1
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +42 -0
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +52 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +1 -1
- package/src/runtime/session_journal.zig +102 -0
- package/src/runtime/session_record.zig +177 -0
- package/src/runtime/session_replay.zig +109 -4
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +6 -0
- package/src/runtime/system_services.zig +49 -10
- package/src/runtime/tests.zig +5 -0
- package/src/runtime/ts_core_host.zig +1189 -118
- package/src/runtime/ts_core_host_tests.zig +638 -11
- package/src/runtime/ts_ui_app.zig +537 -1
- package/src/runtime/ui_app.zig +160 -19
- package/src/runtime/ui_app_tests.zig +203 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +11 -0
- package/src/runtime/view_widget_scroll.zig +56 -5
- package/src/runtime/view_widget_text.zig +24 -5
- package/src/runtime/view_widget_tree.zig +1 -1
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +1248 -2
- package/src/tooling/package.zig +953 -6
- package/src/tooling/raw_manifest.zig +65 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +216 -4
- package/src/tooling/ts_core.zig +283 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +414 -23
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
|
@@ -237,6 +237,7 @@ test "runtime schedules canvas render animations without display list rebuild" {
|
|
|
237
237
|
|
|
238
238
|
harness.runtime.invalidated = false;
|
|
239
239
|
harness.runtime.dirty_region_count = 0;
|
|
240
|
+
const frame_requests_before_mid = harness.null_platform.gpu_surface_frame_request_count;
|
|
240
241
|
const mid_frame = try harness.runtime.nextCanvasFrame(1, "canvas", .{
|
|
241
242
|
.frame_index = 2,
|
|
242
243
|
.timestamp_ns = start_ns + 500_000_000,
|
|
@@ -249,9 +250,11 @@ test "runtime schedules canvas render animations without display list rebuild" {
|
|
|
249
250
|
try std.testing.expectEqualDeep(canvas.Affine.translate(5, 0), mid_frame.render_plan.commands[0].transform);
|
|
250
251
|
try std.testing.expectEqualDeep(geometry.RectF.init(0, 0, 16, 11), mid_frame.dirty_bounds.?);
|
|
251
252
|
try std.testing.expect(harness.runtime.invalidated);
|
|
253
|
+
try std.testing.expectEqual(frame_requests_before_mid + 1, harness.null_platform.gpu_surface_frame_request_count);
|
|
252
254
|
|
|
253
255
|
harness.runtime.invalidated = false;
|
|
254
256
|
harness.runtime.dirty_region_count = 0;
|
|
257
|
+
const frame_requests_before_final = harness.null_platform.gpu_surface_frame_request_count;
|
|
255
258
|
const final_frame = try harness.runtime.nextCanvasFrame(1, "canvas", .{
|
|
256
259
|
.frame_index = 3,
|
|
257
260
|
.timestamp_ns = start_ns + 1_000_000_000,
|
|
@@ -261,6 +264,7 @@ test "runtime schedules canvas render animations without display list rebuild" {
|
|
|
261
264
|
try std.testing.expectEqualDeep(canvas.Affine.identity(), final_frame.render_plan.commands[0].transform);
|
|
262
265
|
try std.testing.expectEqualDeep(geometry.RectF.init(0, 0, 16, 11), final_frame.dirty_bounds.?);
|
|
263
266
|
try std.testing.expect(!harness.runtime.invalidated);
|
|
267
|
+
try std.testing.expectEqual(frame_requests_before_final, harness.null_platform.gpu_surface_frame_request_count);
|
|
264
268
|
try std.testing.expectEqual(@as(usize, 0), (try harness.runtime.canvasRenderAnimations(1, "canvas")).len);
|
|
265
269
|
try std.testing.expectEqual(@as(usize, 0), runtimeViewCanvasFrameRenderOverrides(&harness.runtime.views[0]).len);
|
|
266
270
|
|
|
@@ -438,10 +438,13 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
|
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
440
|
|
|
441
|
-
const surface = geometry.SizeF.init(
|
|
441
|
+
const surface = geometry.SizeF.init(120, 40);
|
|
442
442
|
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
443
443
|
defer harness.destroy(std.testing.allocator);
|
|
444
444
|
harness.null_platform.gpu_surfaces = true;
|
|
445
|
+
// Exercise the AppKit-specific three-box sampling footprint while the
|
|
446
|
+
// null host keeps the test deterministic and headless.
|
|
447
|
+
harness.runtime.options.platform.name = "macos";
|
|
445
448
|
harness.runtime.options.pixel_present_retained_baseline = true;
|
|
446
449
|
var app_state: TestApp = .{};
|
|
447
450
|
try harness.start(app_state.app());
|
|
@@ -452,14 +455,14 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
|
|
|
452
455
|
.kind = .gpu_surface,
|
|
453
456
|
.frame = geometry.RectF.init(0, 0, surface.width, surface.height),
|
|
454
457
|
});
|
|
455
|
-
var pixels: [
|
|
456
|
-
var scratch: [
|
|
458
|
+
var pixels: [120 * 40 * 4]u8 = undefined;
|
|
459
|
+
var scratch: [120 * 40 * 4]u8 = undefined;
|
|
457
460
|
const clear = canvas.Color.rgb8(0, 0, 0);
|
|
458
461
|
|
|
459
462
|
const initial = [_]canvas.CanvasCommand{
|
|
460
463
|
.{ .fill_rect = .{ .id = 1, .rect = geometry.RectF.init(4, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(255, 0, 0) } } },
|
|
461
464
|
.{ .fill_rect = .{ .id = 2, .rect = geometry.RectF.init(44, 15, 4, 4), .fill = .{ .color = canvas.Color.rgb8(255, 0, 0) } } },
|
|
462
|
-
.{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(
|
|
465
|
+
.{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(110, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(255, 0, 0) } } },
|
|
463
466
|
.{ .push_clip = .{ .id = 3, .rect = geometry.RectF.init(50, 10, 20, 20) } },
|
|
464
467
|
.{ .blur = .{ .id = 4, .rect = geometry.RectF.init(50, 10, 20, 20), .radius = 8 } },
|
|
465
468
|
.pop_clip,
|
|
@@ -471,12 +474,13 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
|
|
|
471
474
|
}, canvasFrameScratchStorage(&harness.runtime), &pixels, &scratch, clear);
|
|
472
475
|
try std.testing.expect(first.full_repaint);
|
|
473
476
|
|
|
474
|
-
// Two damage islands well outside the blur's
|
|
475
|
-
// path even though their bounding
|
|
477
|
+
// Two damage islands well outside the three-pass blur's conservative
|
|
478
|
+
// sampling extent keep the retained path even though their bounding
|
|
479
|
+
// union crosses the blur apron.
|
|
476
480
|
const far_changed = [_]canvas.CanvasCommand{
|
|
477
481
|
.{ .fill_rect = .{ .id = 1, .rect = geometry.RectF.init(4, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 255, 0) } } },
|
|
478
482
|
initial[1],
|
|
479
|
-
.{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(
|
|
483
|
+
.{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(110, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 255, 0) } } },
|
|
480
484
|
initial[3],
|
|
481
485
|
initial[4],
|
|
482
486
|
initial[5],
|
|
@@ -490,20 +494,41 @@ test "backdrop blur promotes intersecting damage to a full repaint" {
|
|
|
490
494
|
try std.testing.expect(incremental.dirty_bounds != null);
|
|
491
495
|
try std.testing.expectEqual(@as(usize, 2), incremental.dirtyRects().len);
|
|
492
496
|
|
|
497
|
+
// AppKit's radius-8 Gaussian uses three boxes whose combined support
|
|
498
|
+
// reaches beyond the declared radius. Moving this rect to twenty points
|
|
499
|
+
// past the blur output must therefore replay the whole list; the old
|
|
500
|
+
// radius-only apron left the affected blur pixels stale.
|
|
501
|
+
const gaussian_apron_changed = [_]canvas.CanvasCommand{
|
|
502
|
+
far_changed[0],
|
|
503
|
+
far_changed[1],
|
|
504
|
+
.{ .fill_rect = .{ .id = 5, .rect = geometry.RectF.init(90, 4, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 0, 255) } } },
|
|
505
|
+
initial[3],
|
|
506
|
+
initial[4],
|
|
507
|
+
initial[5],
|
|
508
|
+
};
|
|
509
|
+
_ = try harness.runtime.setCanvasDisplayList(1, "canvas", .{ .commands = &gaussian_apron_changed });
|
|
510
|
+
const gaussian_promoted = try harness.runtime.presentNextCanvasFramePixels(1, "canvas", .{
|
|
511
|
+
.frame_index = 3,
|
|
512
|
+
.surface_size = surface,
|
|
513
|
+
}, canvasFrameScratchStorage(&harness.runtime), &pixels, &scratch, clear);
|
|
514
|
+
try std.testing.expect(gaussian_promoted.full_repaint);
|
|
515
|
+
try std.testing.expectEqual(@as(usize, 0), gaussian_promoted.changes.len);
|
|
516
|
+
try std.testing.expectEqualDeep(geometry.RectF.init(0, 0, surface.width, surface.height), gaussian_promoted.dirty_bounds.?);
|
|
517
|
+
|
|
493
518
|
// This changed rect stops two points before the blur output, but it
|
|
494
519
|
// lies inside the radius-8 sampling apron. A scissored replay would
|
|
495
520
|
// sample the prior composited frame outside its dirty boundary.
|
|
496
521
|
const apron_changed = [_]canvas.CanvasCommand{
|
|
497
|
-
|
|
522
|
+
gaussian_apron_changed[0],
|
|
498
523
|
.{ .fill_rect = .{ .id = 2, .rect = geometry.RectF.init(44, 15, 4, 4), .fill = .{ .color = canvas.Color.rgb8(0, 0, 255) } } },
|
|
499
|
-
|
|
524
|
+
gaussian_apron_changed[2],
|
|
500
525
|
initial[3],
|
|
501
526
|
initial[4],
|
|
502
527
|
initial[5],
|
|
503
528
|
};
|
|
504
529
|
_ = try harness.runtime.setCanvasDisplayList(1, "canvas", .{ .commands = &apron_changed });
|
|
505
530
|
const promoted = try harness.runtime.presentNextCanvasFramePixels(1, "canvas", .{
|
|
506
|
-
.frame_index =
|
|
531
|
+
.frame_index = 4,
|
|
507
532
|
.surface_size = surface,
|
|
508
533
|
}, canvasFrameScratchStorage(&harness.runtime), &pixels, &scratch, clear);
|
|
509
534
|
try std.testing.expect(promoted.full_repaint);
|
|
@@ -31,6 +31,9 @@ const PickerModel = struct {
|
|
|
31
31
|
// issue/file browsers draw one).
|
|
32
32
|
switcher_open: bool = false,
|
|
33
33
|
switcher_dismissals: u32 = 0,
|
|
34
|
+
actions_open: bool = false,
|
|
35
|
+
action: u32 = 99,
|
|
36
|
+
actions: u32 = 0,
|
|
34
37
|
};
|
|
35
38
|
|
|
36
39
|
const PickerMsg = union(enum) {
|
|
@@ -41,6 +44,9 @@ const PickerMsg = union(enum) {
|
|
|
41
44
|
crumb_press,
|
|
42
45
|
toggle_switcher,
|
|
43
46
|
close_switcher,
|
|
47
|
+
toggle_actions,
|
|
48
|
+
close_actions,
|
|
49
|
+
action: u32,
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
const PickerApp = ui_app_model.UiApp(PickerModel, PickerMsg);
|
|
@@ -67,6 +73,13 @@ fn pickerUpdate(model: *PickerModel, msg: PickerMsg) void {
|
|
|
67
73
|
model.switcher_open = false;
|
|
68
74
|
model.switcher_dismissals += 1;
|
|
69
75
|
},
|
|
76
|
+
.toggle_actions => model.actions_open = !model.actions_open,
|
|
77
|
+
.close_actions => model.actions_open = false,
|
|
78
|
+
.action => |index| {
|
|
79
|
+
model.action = index;
|
|
80
|
+
model.actions += 1;
|
|
81
|
+
model.actions_open = false;
|
|
82
|
+
},
|
|
70
83
|
}
|
|
71
84
|
}
|
|
72
85
|
|
|
@@ -86,6 +99,29 @@ fn pickerView(ui: *PickerApp.Ui, model: *const PickerModel) PickerApp.Ui.Node {
|
|
|
86
99
|
}),
|
|
87
100
|
}) else ui.stack(.{ .height = 28 }, .{trigger});
|
|
88
101
|
|
|
102
|
+
// A menu button uses the same anchored ownership shape as the picker,
|
|
103
|
+
// but remains an ordinary button: dropdown keyboard behavior belongs
|
|
104
|
+
// to the built-in composition rather than an app-authored key handler.
|
|
105
|
+
const actions_trigger = ui.el(.button, .{
|
|
106
|
+
.text = "Actions",
|
|
107
|
+
.width = 160,
|
|
108
|
+
.expanded = model.actions_open,
|
|
109
|
+
.on_press = .toggle_actions,
|
|
110
|
+
}, .{});
|
|
111
|
+
const actions = if (model.actions_open) ui.stack(.{ .height = 28 }, .{
|
|
112
|
+
actions_trigger,
|
|
113
|
+
ui.el(.dropdown_menu, .{
|
|
114
|
+
.anchor = .below,
|
|
115
|
+
.anchor_alignment = .stretch,
|
|
116
|
+
.width = 160,
|
|
117
|
+
.height = 90,
|
|
118
|
+
.on_dismiss = .close_actions,
|
|
119
|
+
}, .{
|
|
120
|
+
ui.el(.menu_item, .{ .key = .{ .int = 20 }, .text = "Duplicate", .height = 26, .on_press = PickerMsg{ .action = 0 } }, .{}),
|
|
121
|
+
ui.el(.menu_item, .{ .key = .{ .int = 21 }, .text = "Rename", .height = 26, .on_press = PickerMsg{ .action = 1 } }, .{}),
|
|
122
|
+
}),
|
|
123
|
+
}) else ui.stack(.{ .height = 28 }, .{actions_trigger});
|
|
124
|
+
|
|
89
125
|
// A plain-text trigger: pressable (the handler makes it a hit
|
|
90
126
|
// target) but NOT focusable — clicking it clears widget focus, so
|
|
91
127
|
// its menu floats with nothing focused.
|
|
@@ -104,6 +140,7 @@ fn pickerView(ui: *PickerApp.Ui, model: *const PickerModel) PickerApp.Ui.Node {
|
|
|
104
140
|
|
|
105
141
|
return ui.column(.{ .gap = 8, .padding = 12 }, .{
|
|
106
142
|
picker,
|
|
143
|
+
actions,
|
|
107
144
|
switcher,
|
|
108
145
|
ui.button(.{ .on_press = .crumb_press, .on_hold = .crumb_hold }, "Crumb"),
|
|
109
146
|
ui.text(.{}, ui.fmt("picked {d}", .{model.picked})),
|
|
@@ -407,6 +444,52 @@ test "anchored picker: the open-select keymap opens, walks, commits, and returns
|
|
|
407
444
|
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
408
445
|
}
|
|
409
446
|
|
|
447
|
+
test "anchored dropdown menu: button arrows walk, commit, and return focus" {
|
|
448
|
+
const fixture = try Fixture.create();
|
|
449
|
+
defer fixture.destroy();
|
|
450
|
+
|
|
451
|
+
const trigger_id = fixture.widgetIdByText(.button, "Actions").?;
|
|
452
|
+
try fixture.clickWidget(trigger_id);
|
|
453
|
+
try std.testing.expect(fixture.app_state.model.actions_open);
|
|
454
|
+
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
455
|
+
|
|
456
|
+
const duplicate_id = fixture.widgetIdByText(.menu_item, "Duplicate").?;
|
|
457
|
+
const rename_id = fixture.widgetIdByText(.menu_item, "Rename").?;
|
|
458
|
+
try fixture.key("arrowdown");
|
|
459
|
+
try std.testing.expectEqual(duplicate_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
460
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 0), fixture.harness.runtime.views[0].canvas_widget_focus_visible_id);
|
|
461
|
+
|
|
462
|
+
// Pointer entry is deliberately quiet, but a menu still needs a
|
|
463
|
+
// visible active-row affordance when arrows move into it. Logical
|
|
464
|
+
// focus paints the row wash; focus-visible remains empty, so no
|
|
465
|
+
// traversal outline flashes on the menu item.
|
|
466
|
+
const display_list = try fixture.harness.runtime.canvasDisplayList(1, canvas_label);
|
|
467
|
+
var duplicate_wash = false;
|
|
468
|
+
var duplicate_outline = false;
|
|
469
|
+
for (display_list.commands) |command| switch (command) {
|
|
470
|
+
.fill_rounded_rect => |fill| {
|
|
471
|
+
if (fill.id == partId(duplicate_id, 1)) duplicate_wash = true;
|
|
472
|
+
},
|
|
473
|
+
.stroke_rect => |stroke| {
|
|
474
|
+
if (stroke.id == partId(duplicate_id, 2)) duplicate_outline = true;
|
|
475
|
+
},
|
|
476
|
+
else => {},
|
|
477
|
+
};
|
|
478
|
+
try std.testing.expect(duplicate_wash);
|
|
479
|
+
try std.testing.expect(!duplicate_outline);
|
|
480
|
+
|
|
481
|
+
try fixture.key("arrowdown");
|
|
482
|
+
try std.testing.expectEqual(rename_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
483
|
+
try fixture.key("arrowup");
|
|
484
|
+
try std.testing.expectEqual(duplicate_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
485
|
+
|
|
486
|
+
try fixture.key("enter");
|
|
487
|
+
try std.testing.expectEqual(@as(u32, 0), fixture.app_state.model.action);
|
|
488
|
+
try std.testing.expectEqual(@as(u32, 1), fixture.app_state.model.actions);
|
|
489
|
+
try std.testing.expect(!fixture.app_state.model.actions_open);
|
|
490
|
+
try std.testing.expectEqual(trigger_id, fixture.harness.runtime.views[0].canvas_widget_focused_id);
|
|
491
|
+
}
|
|
492
|
+
|
|
410
493
|
test "anchored picker: arrows enter at the marked row and escape returns focus to the trigger" {
|
|
411
494
|
const fixture = try Fixture.create();
|
|
412
495
|
defer fixture.destroy();
|
|
@@ -2705,7 +2705,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2705
2705
|
self.views[index].canvasWidgetScopedFocusTarget(id, direction) orelse layout.focusTarget(current_id, direction) orelse return false
|
|
2706
2706
|
else
|
|
2707
2707
|
layout.focusTarget(current_id, direction) orelse return false;
|
|
2708
|
-
const moved = try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2708
|
+
const moved = try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, true);
|
|
2709
2709
|
if (moved and
|
|
2710
2710
|
(canvasWidgetTerminalOwnsTabInput(layout, target) or
|
|
2711
2711
|
canvasWidgetCodeEditorOwnsTabInput(layout, target)))
|
|
@@ -2720,36 +2720,44 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2720
2720
|
|
|
2721
2721
|
const focused_id = current_id orelse return false;
|
|
2722
2722
|
const focused = layout.focusTargetById(focused_id) orelse return false;
|
|
2723
|
+
// Roving within a composite preserves how focus ENTERED it:
|
|
2724
|
+
// pointer/programmatic entry stays quiet, while a ring earned
|
|
2725
|
+
// through Tab follows the active descendant. Arrow/Home/End
|
|
2726
|
+
// are not themselves a fresh focus-visible entry.
|
|
2727
|
+
const preserve_focus_visible = self.views[index].canvas_widget_focus_visible_id == focused_id;
|
|
2723
2728
|
// FRAMEWORK BEHAVIOR CHANGE (deliberate, scoped — the same
|
|
2724
2729
|
// seam as the keyboard-routing gate below): arrows and
|
|
2725
2730
|
// Home/End never escalate QUIET focus on a plain list row
|
|
2726
2731
|
// into the visible ring register. Only Tab (handled above)
|
|
2727
2732
|
// enters the keyboard-contract; from quiet row focus the
|
|
2728
2733
|
// navigation keys fall through to the app, whose selection
|
|
2729
|
-
// model owns them.
|
|
2730
|
-
//
|
|
2734
|
+
// model owns them. Tree rows are exempt from that fallthrough
|
|
2735
|
+
// because the runtime owns their ARIA keymap; the roving move
|
|
2736
|
+
// below still preserves quiet versus focus-visible entry.
|
|
2731
2737
|
if (canvasWidgetQuietListRowFocus(self, index, focused_id)) return false;
|
|
2732
2738
|
if (canvasWidgetGroupFocusEdgeFromInput(input_event)) |edge| {
|
|
2733
2739
|
// A tree row's Home/End jump to the SCOPE's edges (rows
|
|
2734
2740
|
// nest, so the group edge walk's same-parent rule would
|
|
2735
2741
|
// stop at one level).
|
|
2736
2742
|
if (canvas_widget_runtime.canvasWidgetTreeFocusEdgeTarget(layout, focused, edge)) |target| {
|
|
2737
|
-
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2743
|
+
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2738
2744
|
}
|
|
2739
2745
|
const target = canvasWidgetGroupFocusEdgeTarget(layout, focused, edge) orelse return false;
|
|
2740
|
-
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2746
|
+
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2741
2747
|
}
|
|
2742
2748
|
const direction = canvasWidgetSpatialFocusDirection(input_event) orelse return false;
|
|
2743
|
-
// The open-
|
|
2744
|
-
//
|
|
2745
|
-
//
|
|
2746
|
-
//
|
|
2747
|
-
//
|
|
2748
|
-
//
|
|
2749
|
-
|
|
2749
|
+
// The open-menu keymap: ArrowDown/Up on a menu-owning trigger
|
|
2750
|
+
// whose anchored surface is MOUNTED moves the keyboard into
|
|
2751
|
+
// the menu (the marked row when one is selected, else the
|
|
2752
|
+
// first/last row). Select/combobox and ordinary menu buttons
|
|
2753
|
+
// share this ownership contract; the surface relationship,
|
|
2754
|
+
// not an example-specific key handler, identifies the popup.
|
|
2755
|
+
// Without a mounted menu, select/combobox arrows fall through
|
|
2756
|
+
// to the control resolver for the model-owned open.
|
|
2757
|
+
if (canvasWidgetAnchoredMenuTriggerKind(focused.kind) and (direction == .down or direction == .up)) {
|
|
2750
2758
|
if (self.views[index].canvasWidgetOwnedMenuSurfaceIndex(focused.index)) |surface_index| {
|
|
2751
2759
|
if (self.views[index].canvasWidgetMenuSurfaceEntryId(surface_index, direction == .up)) |entry_id| {
|
|
2752
|
-
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, entry_id);
|
|
2760
|
+
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, entry_id, preserve_focus_visible);
|
|
2753
2761
|
}
|
|
2754
2762
|
}
|
|
2755
2763
|
}
|
|
@@ -2757,27 +2765,54 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2757
2765
|
// visible rows, Left/Right move to parent / first child when
|
|
2758
2766
|
// they are moves (collapse/expand stay routed intents).
|
|
2759
2767
|
if (canvas_widget_runtime.canvasWidgetTreeDirectionalFocusTarget(layout, focused, direction)) |target| {
|
|
2760
|
-
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2768
|
+
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2761
2769
|
}
|
|
2762
2770
|
if (canvasWidgetGroupDirectionalFocusTarget(layout, focused, direction)) |target| {
|
|
2763
|
-
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2771
|
+
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2764
2772
|
}
|
|
2765
2773
|
const target = layout.focusTarget(focused_id, direction) orelse return false;
|
|
2766
2774
|
if (!canvasWidgetSpatialFocusAllowed(layout, focused, target, direction)) return false;
|
|
2767
|
-
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2775
|
+
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2768
2776
|
}
|
|
2769
2777
|
|
|
2770
|
-
fn setCanvasWidgetFocusFromKeyboardMoved(self: *Runtime, view_index: usize, previous_id: ?canvas.ObjectId, target_id: canvas.ObjectId) anyerror!bool {
|
|
2771
|
-
try
|
|
2778
|
+
fn setCanvasWidgetFocusFromKeyboardMoved(self: *Runtime, view_index: usize, previous_id: ?canvas.ObjectId, target_id: canvas.ObjectId, focus_visible: bool) anyerror!bool {
|
|
2779
|
+
try setCanvasWidgetFocusFromKeyboardWithVisibility(self, view_index, target_id, focus_visible);
|
|
2772
2780
|
const previous = previous_id orelse 0;
|
|
2773
|
-
return target_id != 0 and target_id != previous;
|
|
2781
|
+
return target_id != 0 and target_id != previous and self.views[view_index].canvas_widget_focused_id == target_id;
|
|
2774
2782
|
}
|
|
2775
2783
|
|
|
2776
2784
|
pub fn setCanvasWidgetFocusFromKeyboard(self: *Runtime, view_index: usize, target_id: canvas.ObjectId) anyerror!void {
|
|
2777
|
-
|
|
2785
|
+
try setCanvasWidgetFocusFromKeyboardWithVisibility(self, view_index, target_id, true);
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
fn setCanvasWidgetFocusFromKeyboardWithVisibility(self: *Runtime, view_index: usize, target_id: canvas.ObjectId, focus_visible: bool) anyerror!void {
|
|
2789
|
+
const next_focus_visible_id: canvas.ObjectId = if (focus_visible) target_id else 0;
|
|
2790
|
+
if (self.views[view_index].canvas_widget_focused_id == target_id and self.views[view_index].canvas_widget_focus_visible_id == next_focus_visible_id) return;
|
|
2791
|
+
|
|
2792
|
+
// Roving tree/list navigation may resolve a logical row that
|
|
2793
|
+
// is currently clipped. Reveal it before the focus write so
|
|
2794
|
+
// keyboard routing, semantics, and rendering all see an
|
|
2795
|
+
// ordinary visible target during this same key event.
|
|
2796
|
+
const scroll_dirty = try self.views[view_index].scrollCanvasWidgetIntoView(target_id);
|
|
2797
|
+
if (scroll_dirty) |dirty| {
|
|
2798
|
+
const previous_cursor = self.views[view_index].canvas_widget_cursor;
|
|
2799
|
+
try reconcileCanvasWidgetRenderStateAfterScrollWithTooltipIntent(self, view_index, null);
|
|
2800
|
+
if (previous_cursor != self.views[view_index].canvas_widget_cursor) try syncCanvasWidgetCursorForView(self, view_index);
|
|
2801
|
+
if (canvasDirtyRegionForView(self.views[view_index].frame, dirty)) |dirty_region| {
|
|
2802
|
+
self.invalidateFor(.state, dirty_region);
|
|
2803
|
+
} else {
|
|
2804
|
+
self.invalidateFor(.state, self.views[view_index].frame);
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
// Logical tree/list navigation may name a row before geometry
|
|
2808
|
+
// filtering so a scroll viewport can reveal it. If no runtime-
|
|
2809
|
+
// owned scroll ancestor actually made the row visible (for
|
|
2810
|
+
// example, a fixed clip_content card), keep focus on the current
|
|
2811
|
+
// target instead of committing an invisible, unroutable id.
|
|
2812
|
+
if (target_id != 0 and self.views[view_index].widgetLayoutTree().focusTargetById(target_id) == null) return;
|
|
2778
2813
|
const previous_state = self.views[view_index].canvasWidgetRenderState();
|
|
2779
2814
|
self.views[view_index].canvas_widget_focused_id = target_id;
|
|
2780
|
-
self.views[view_index].canvas_widget_focus_visible_id =
|
|
2815
|
+
self.views[view_index].canvas_widget_focus_visible_id = next_focus_visible_id;
|
|
2781
2816
|
// The one provenance write that grants the keyboard
|
|
2782
2817
|
// contract: only rings placed HERE carry the standing
|
|
2783
2818
|
// reveal intent a later layout adoption may honor.
|
|
@@ -2785,12 +2820,12 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2785
2820
|
// that intent where it dismisses — the register clears
|
|
2786
2821
|
// there and only a fresh arrival through this write
|
|
2787
2822
|
// re-grants it.
|
|
2788
|
-
self.views[view_index].canvas_widget_focus_visible_keyboard =
|
|
2823
|
+
self.views[view_index].canvas_widget_focus_visible_keyboard = next_focus_visible_id != 0;
|
|
2789
2824
|
// Keyboard focus-visible is the tooltip's second reveal
|
|
2790
2825
|
// path: landing on a tooltip-owning trigger shows it
|
|
2791
2826
|
// immediately, moving on hides the previous one (the
|
|
2792
2827
|
// `.focus_visible` cause of the intent choke point).
|
|
2793
|
-
try reconcileCanvasTooltipIntent(self, view_index, .{ .focus_visible =
|
|
2828
|
+
try reconcileCanvasTooltipIntent(self, view_index, .{ .focus_visible = next_focus_visible_id });
|
|
2794
2829
|
// Keyboard focus landing on an editable establishes a caret:
|
|
2795
2830
|
// without a selection the emitters draw no caret line, so a
|
|
2796
2831
|
// tabbed-into field would render its ring but no insertion
|
|
@@ -2807,6 +2842,9 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2807
2842
|
}
|
|
2808
2843
|
}
|
|
2809
2844
|
try invalidateForCanvasWidgetRenderStateChange(self, view_index, previous_state, self.views[view_index].canvasWidgetRenderState());
|
|
2845
|
+
if (scroll_dirty != null) {
|
|
2846
|
+
_ = try runtime_canvas_widget_display.RuntimeCanvasWidgetDisplay(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, view_index);
|
|
2847
|
+
}
|
|
2810
2848
|
}
|
|
2811
2849
|
|
|
2812
2850
|
pub fn invalidateForWidgetInvalidations(self: *Runtime, view_frame: geometry.RectF, invalidations: []const canvas.WidgetInvalidation) void {
|
|
@@ -2862,7 +2900,14 @@ fn canvasWidgetTerminalOwnsTabInput(layout: canvas.WidgetLayoutTree, target: can
|
|
|
2862
2900
|
fn canvasWidgetCodeEditorOwnsTabInput(layout: canvas.WidgetLayoutTree, target: canvas.WidgetFocusTarget) bool {
|
|
2863
2901
|
if (target.kind != .textarea or target.index >= layout.nodes.len) return false;
|
|
2864
2902
|
const widget = layout.nodes[target.index].widget;
|
|
2865
|
-
return widget.code_editor and !widget.state.disabled;
|
|
2903
|
+
return widget.runtime_flags.code_editor and !widget.state.disabled;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
fn canvasWidgetAnchoredMenuTriggerKind(kind: canvas.WidgetKind) bool {
|
|
2907
|
+
return switch (kind) {
|
|
2908
|
+
.button, .icon_button, .select, .combobox => true,
|
|
2909
|
+
else => false,
|
|
2910
|
+
};
|
|
2866
2911
|
}
|
|
2867
2912
|
|
|
2868
2913
|
fn canvasDirtyRegionForView(view_frame: geometry.RectF, local_dirty: geometry.RectF) ?geometry.RectF {
|
|
@@ -253,6 +253,68 @@ pub fn restoreCanvasWidgetLayoutScrollOffsets(
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
/// Clamp a fresh or genuinely PROGRAMMATIC source offset before a native
|
|
257
|
+
/// scroll driver adopts the layout. Native drivers otherwise keep their raw
|
|
258
|
+
/// runtime offset so an Elm-style rebuild cannot interrupt rubber-band
|
|
259
|
+
/// overscroll. A source value that exactly echoes the retained runtime value
|
|
260
|
+
/// is the same user-driven state, not a programmatic move, and stays exempt.
|
|
261
|
+
///
|
|
262
|
+
/// This pass is what makes an intentionally out-of-range source value useful
|
|
263
|
+
/// as "scroll to the end": descendants are first laid out at that source
|
|
264
|
+
/// value, then translated back to the content-range clamp before either the
|
|
265
|
+
/// retained tree or the native driver sees them.
|
|
266
|
+
fn clampCanvasWidgetLayoutProgrammaticScrollOffsets(
|
|
267
|
+
nodes: []canvas.WidgetLayoutNode,
|
|
268
|
+
source: canvas.WidgetLayoutTree,
|
|
269
|
+
previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
270
|
+
previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
|
|
271
|
+
) void {
|
|
272
|
+
for (nodes, 0..) |node, index| {
|
|
273
|
+
if (node.widget.kind != .scroll_view or node.widget.id == 0) continue;
|
|
274
|
+
if (node.widget.layout.virtualized and !canvas.widgetVirtualRuntimeScrolled(node.widget)) continue;
|
|
275
|
+
|
|
276
|
+
const source_node = source.findById(node.widget.id) orelse continue;
|
|
277
|
+
const previous_runtime = canvasWidgetSourceScrollEntryById(previous_runtime_offsets, node.widget.id);
|
|
278
|
+
const previous_source = canvasWidgetSourceScrollEntryById(previous_source_offsets, node.widget.id);
|
|
279
|
+
const fresh = previous_source == null;
|
|
280
|
+
const source_moved_y = fresh or source_node.widget.value != previous_source.?.value;
|
|
281
|
+
const source_moved_x = fresh or source_node.widget.value_x != previous_source.?.value_x;
|
|
282
|
+
const runtime_echo_y = previous_runtime != null and source_node.widget.value == previous_runtime.?.value;
|
|
283
|
+
const runtime_echo_x = previous_runtime != null and source_node.widget.value_x == previous_runtime.?.value_x;
|
|
284
|
+
const clamp_y = source_moved_y and !runtime_echo_y;
|
|
285
|
+
const clamp_x = source_moved_x and !runtime_echo_x;
|
|
286
|
+
if (!clamp_y and !clamp_x) continue;
|
|
287
|
+
|
|
288
|
+
const viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
289
|
+
if (viewport.isEmpty()) continue;
|
|
290
|
+
|
|
291
|
+
const current_y = node.widget.value;
|
|
292
|
+
const current_x = node.widget.value_x;
|
|
293
|
+
const next_y = if (clamp_y)
|
|
294
|
+
if (canvas.widgetScrollsAxis(node.widget, .vertical))
|
|
295
|
+
std.math.clamp(@max(0, current_y), 0, @max(0, canvasWidgetLayoutScrollContentExtent(nodes, index, viewport) - viewport.height))
|
|
296
|
+
else
|
|
297
|
+
0
|
|
298
|
+
else
|
|
299
|
+
current_y;
|
|
300
|
+
const next_x = if (clamp_x)
|
|
301
|
+
if (canvas.widgetScrollsAxis(node.widget, .horizontal))
|
|
302
|
+
std.math.clamp(@max(0, current_x), 0, @max(0, canvasWidgetLayoutScrollContentExtentX(nodes, index, viewport) - viewport.width))
|
|
303
|
+
else
|
|
304
|
+
0
|
|
305
|
+
else
|
|
306
|
+
current_x;
|
|
307
|
+
if (next_y == current_y and next_x == current_x) continue;
|
|
308
|
+
|
|
309
|
+
nodes[index].widget.value = next_y;
|
|
310
|
+
nodes[index].widget.value_x = next_x;
|
|
311
|
+
translateCanvasWidgetLayoutScrollDescendants(nodes, index, .{
|
|
312
|
+
.dx = if (canvas.widgetScrollsAxis(node.widget, .horizontal)) -(next_x - current_x) else 0,
|
|
313
|
+
.dy = if (canvas.widgetScrollsAxis(node.widget, .vertical)) -(next_y - current_y) else 0,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
256
318
|
fn previousLayoutHasSelectedTab(previous: canvas.WidgetLayoutTree, id: canvas.ObjectId) bool {
|
|
257
319
|
for (previous.nodes) |node| {
|
|
258
320
|
if (node.widget.id == id) return node.widget.semantics.role == .tab and node.widget.state.selected;
|
|
@@ -878,7 +940,7 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
878
940
|
// right after, so a resized or re-texted field never keeps a
|
|
879
941
|
// stale offset).
|
|
880
942
|
if (canvasWidgetEditableTextKind(copy.widget.kind)) copy.widget.value = entry.value;
|
|
881
|
-
if (copy.widget.code_editor) {
|
|
943
|
+
if (copy.widget.runtime_flags.code_editor) {
|
|
882
944
|
copy.widget.value_x = entry.value_x;
|
|
883
945
|
if (!copy.widget.hasCodeDiff()) {
|
|
884
946
|
copy.widget.code_content_width = entry.code_content_width;
|
|
@@ -1036,6 +1098,12 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
1036
1098
|
// the caller AFTER native scroll drivers are stamped — a rebuild
|
|
1037
1099
|
// mid-rubber-band must not clamp an offset the OS scroller owns.
|
|
1038
1100
|
restoreCanvasWidgetLayoutScrollOffsets(staged_nodes, previous_runtime_offsets, previous_source_scroll_entries);
|
|
1101
|
+
clampCanvasWidgetLayoutProgrammaticScrollOffsets(
|
|
1102
|
+
staged_nodes,
|
|
1103
|
+
next,
|
|
1104
|
+
previous_runtime_offsets,
|
|
1105
|
+
previous_source_scroll_entries,
|
|
1106
|
+
);
|
|
1039
1107
|
revealNewlySelectedTabs(previous, staged_nodes);
|
|
1040
1108
|
|
|
1041
1109
|
const index_scratch = canvas_widget_reconcile_index_scratch.get();
|
|
@@ -1101,7 +1169,7 @@ pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, st
|
|
|
1101
1169
|
// must behave the same on every host, or a source still
|
|
1102
1170
|
// echoing the old offset would resurrect it on re-grant only
|
|
1103
1171
|
// where drivers run.
|
|
1104
|
-
if (node.widget.native_scroll) {
|
|
1172
|
+
if (node.widget.runtime_flags.native_scroll) {
|
|
1105
1173
|
const pin_y = !canvas.widgetScrollsAxis(node.widget, .vertical) and node.widget.value != 0;
|
|
1106
1174
|
const pin_x = !canvas.widgetScrollsAxis(node.widget, .horizontal) and node.widget.value_x != 0;
|
|
1107
1175
|
if (pin_y) nodes[index].widget.value = 0;
|
|
@@ -1173,7 +1241,7 @@ pub fn clampCanvasWidgetLayoutTextOffsets(nodes: []canvas.WidgetLayoutNode, toke
|
|
|
1173
1241
|
if (node.widget.kind == .textarea) {
|
|
1174
1242
|
canvas.cacheTextInputContentWidthForWidget(&node.widget, tokens);
|
|
1175
1243
|
node.widget.value = canvas.clampedTextInputScrollOffsetForWidget(node.widget, tokens, node.widget.value);
|
|
1176
|
-
node.widget.value_x = if (node.widget.code_editor)
|
|
1244
|
+
node.widget.value_x = if (node.widget.runtime_flags.code_editor)
|
|
1177
1245
|
canvas.clampedTextInputHorizontalScrollOffsetForWidget(node.widget, tokens, node.widget.value_x)
|
|
1178
1246
|
else
|
|
1179
1247
|
0;
|
|
@@ -1521,11 +1589,17 @@ pub fn canvasWidgetAdjacentGroupFocusTarget(
|
|
|
1521
1589
|
focused: canvas.WidgetFocusTarget,
|
|
1522
1590
|
direction: CanvasWidgetGroupDirection,
|
|
1523
1591
|
) ?canvas.WidgetFocusTarget {
|
|
1592
|
+
const logical_scroll_list = parent_index < layout.nodes.len and
|
|
1593
|
+
layout.nodes[parent_index].widget.kind == .list and
|
|
1594
|
+
focused.kind == .list_item;
|
|
1524
1595
|
var previous: ?canvas.WidgetFocusTarget = null;
|
|
1525
1596
|
var saw_focused = false;
|
|
1526
|
-
for (layout.nodes) |node| {
|
|
1597
|
+
for (layout.nodes, 0..) |node, node_index| {
|
|
1527
1598
|
if (node.parent_index != parent_index or node.widget.kind != focused.kind) continue;
|
|
1528
|
-
const target =
|
|
1599
|
+
const target = if (logical_scroll_list)
|
|
1600
|
+
canvasWidgetLogicalFocusTarget(layout, node_index) orelse continue
|
|
1601
|
+
else
|
|
1602
|
+
layout.focusTargetById(node.widget.id) orelse continue;
|
|
1529
1603
|
if (saw_focused) return target;
|
|
1530
1604
|
if (target.id == focused.id) {
|
|
1531
1605
|
if (direction == .previous) return previous;
|
|
@@ -1565,7 +1639,28 @@ pub fn canvasWidgetTreeScopeIndex(layout: canvas.WidgetLayoutTree, node_index: u
|
|
|
1565
1639
|
|
|
1566
1640
|
fn canvasWidgetTreeRowFocusTarget(layout: canvas.WidgetLayoutTree, node_index: usize) ?canvas.WidgetFocusTarget {
|
|
1567
1641
|
if (layout.nodes[node_index].widget.semantics.role != .treeitem) return null;
|
|
1568
|
-
return
|
|
1642
|
+
return canvasWidgetLogicalFocusTarget(layout, node_index);
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/// A roving group must be able to name its next LOGICAL row even when a
|
|
1646
|
+
/// scroll ancestor clips that row out of the current viewport. Keep every
|
|
1647
|
+
/// other focus gate (identity, disabled/hidden state, hidden ancestors,
|
|
1648
|
+
/// concealed disclosure content), but deliberately omit only the geometry
|
|
1649
|
+
/// clip check performed by `WidgetLayoutTree.focusTargetById`. The runtime
|
|
1650
|
+
/// scrolls this target into view before it commits focus.
|
|
1651
|
+
fn canvasWidgetLogicalFocusTarget(layout: canvas.WidgetLayoutTree, node_index: usize) ?canvas.WidgetFocusTarget {
|
|
1652
|
+
if (node_index >= layout.nodes.len) return null;
|
|
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
|
+
};
|
|
1569
1664
|
}
|
|
1570
1665
|
|
|
1571
1666
|
/// The tree keymap's focus moves. Up/Down walk the scope's rows in node
|