@native-sdk/cli 0.9.0 → 0.9.2
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 +357 -33
- package/build.zig +234 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +170 -13
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +18 -12
- package/skill-data/ts-core/SKILL.md +54 -21
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +122 -6
- package/src/app_runner/ts_core_main.zig +9 -4
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +3 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +2 -0
- package/src/embed/tests.zig +41 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +94 -4
- 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 +17 -3
- package/src/platform/linux/gtk_host.c +243 -15
- package/src/platform/linux/gtk_host.h +5 -4
- package/src/platform/linux/root.zig +91 -11
- package/src/platform/macos/appkit_host.h +18 -11
- package/src/platform/macos/appkit_host.m +402 -128
- package/src/platform/macos/cef_host.mm +342 -122
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +231 -39
- package/src/platform/null_platform.zig +251 -54
- package/src/platform/null_platform_tests.zig +97 -4
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +174 -35
- package/src/platform/windows/root.zig +42 -13
- package/src/platform/windows/webview2_host.cpp +72 -11
- 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 +50 -0
- 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 +13 -2
- 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 +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- 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 +52 -0
- 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 +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -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 +580 -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 +10 -0
- package/src/runtime/api.zig +14 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +16 -3
- 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 +31 -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/core.zig +28 -6
- package/src/runtime/effects.zig +1337 -49
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +7 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +110 -15
- package/src/runtime/session_tests.zig +192 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +142 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +330 -112
- package/src/runtime/ui_app_tests.zig +251 -25
- package/src/runtime/ui_app_window_tests.zig +74 -8
- package/src/runtime/validation.zig +20 -0
- 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_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 +156 -18
- package/src/tooling/ts_core.zig +83 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -70,6 +70,43 @@ fn counterOptions() CounterApp.Options {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
const RadioModel = struct {
|
|
74
|
+
choice: u8 = 0,
|
|
75
|
+
change_count: u32 = 0,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const RadioMsg = union(enum) {
|
|
79
|
+
choose_first,
|
|
80
|
+
choose_second,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const RadioApp = ui_app_model.UiApp(RadioModel, RadioMsg);
|
|
84
|
+
|
|
85
|
+
fn radioUpdate(model: *RadioModel, msg: RadioMsg) void {
|
|
86
|
+
model.choice = switch (msg) {
|
|
87
|
+
.choose_first => 0,
|
|
88
|
+
.choose_second => 1,
|
|
89
|
+
};
|
|
90
|
+
model.change_count += 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fn radioView(ui: *RadioApp.Ui, model: *const RadioModel) RadioApp.Ui.Node {
|
|
94
|
+
return ui.el(.radio_group, .{ .semantics = .{ .label = "Plan" } }, .{
|
|
95
|
+
ui.el(.radio, .{ .text = "Free", .checked = model.choice == 0, .on_change = .choose_first }, .{}),
|
|
96
|
+
ui.el(.radio, .{ .text = "Pro", .checked = model.choice == 1, .on_change = .choose_second }, .{}),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fn radioOptions() RadioApp.Options {
|
|
101
|
+
return .{
|
|
102
|
+
.name = "ui-app-radio",
|
|
103
|
+
.scene = counter_scene,
|
|
104
|
+
.canvas_label = canvas_label,
|
|
105
|
+
.update = radioUpdate,
|
|
106
|
+
.view = radioView,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
73
110
|
const software_counter_views = [_]app_manifest.ShellView{
|
|
74
111
|
.{ .label = canvas_label, .kind = .gpu_surface, .fill = true, .gpu_backend = .software },
|
|
75
112
|
};
|
|
@@ -772,13 +809,19 @@ test "a declared context menu presents as the anchored fallback surface on prese
|
|
|
772
809
|
try std.testing.expect(app_state.tree.?.context_menu_fallback == null);
|
|
773
810
|
try std.testing.expect(!try retainedWidgetKindExists(&harness.runtime, .dropdown_menu));
|
|
774
811
|
|
|
775
|
-
// Reopen and
|
|
776
|
-
//
|
|
812
|
+
// Reopen and click outside. The fallback was opened from a typically
|
|
813
|
+
// non-focusable secondary-click target, so no focused ancestry is
|
|
814
|
+
// available to find it; the whole-view anchored fallback must still
|
|
815
|
+
// dismiss it. Its internal open state closes and no app Msg fires.
|
|
777
816
|
try harness.runtime.dispatchAutomationCommand(app, context_press);
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
817
|
+
_ = app_state.tree.?.context_menu_fallback orelse return error.TestUnexpectedResult;
|
|
818
|
+
harness.runtime.views[0].canvas_widget_focused_id = 0;
|
|
819
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
820
|
+
.label = canvas_label,
|
|
821
|
+
.kind = .pointer_down,
|
|
822
|
+
.x = 360,
|
|
823
|
+
.y = 280,
|
|
824
|
+
} });
|
|
782
825
|
try std.testing.expect(app_state.tree.?.context_menu_fallback == null);
|
|
783
826
|
try std.testing.expect(!try retainedWidgetKindExists(&harness.runtime, .dropdown_menu));
|
|
784
827
|
try std.testing.expectEqual(@as(u32, 1), app_state.model.deleted);
|
|
@@ -2370,6 +2413,41 @@ fn installCounterApp(harness: anytype, app: core.App) !void {
|
|
|
2370
2413
|
} });
|
|
2371
2414
|
}
|
|
2372
2415
|
|
|
2416
|
+
test "radio accessibility selection dispatches change once per retained transition" {
|
|
2417
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2418
|
+
defer harness.destroy(std.testing.allocator);
|
|
2419
|
+
harness.null_platform.gpu_surfaces = true;
|
|
2420
|
+
|
|
2421
|
+
const app_state = try std.testing.allocator.create(RadioApp);
|
|
2422
|
+
defer std.testing.allocator.destroy(app_state);
|
|
2423
|
+
app_state.* = RadioApp.init(std.heap.page_allocator, .{}, radioOptions());
|
|
2424
|
+
defer app_state.deinit();
|
|
2425
|
+
const app = app_state.app();
|
|
2426
|
+
try installCounterApp(harness, app);
|
|
2427
|
+
|
|
2428
|
+
const pro_id = findWidgetIdByText(app_state.tree.?, .radio, "Pro").?;
|
|
2429
|
+
_ = try harness.runtime.dispatchCanvasWidgetAccessibilityAction(app, 1, canvas_label, .{
|
|
2430
|
+
.id = pro_id,
|
|
2431
|
+
.action = .select,
|
|
2432
|
+
});
|
|
2433
|
+
try std.testing.expectEqual(@as(u8, 1), app_state.model.choice);
|
|
2434
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.change_count);
|
|
2435
|
+
try std.testing.expect((try harness.runtime.canvasWidgetLayout(1, canvas_label)).findById(pro_id).?.widget.state.selected);
|
|
2436
|
+
|
|
2437
|
+
// AX selection, pointer activation, and Space all still activate the
|
|
2438
|
+
// radio, but an already-selected control has no new `on_change` edge.
|
|
2439
|
+
_ = try harness.runtime.dispatchCanvasWidgetAccessibilityAction(app, 1, canvas_label, .{
|
|
2440
|
+
.id = pro_id,
|
|
2441
|
+
.action = .select,
|
|
2442
|
+
});
|
|
2443
|
+
var command_buffer: [96]u8 = undefined;
|
|
2444
|
+
const click = try std.fmt.bufPrint(&command_buffer, "widget-click {s} {d}", .{ canvas_label, pro_id });
|
|
2445
|
+
try harness.runtime.dispatchAutomationCommand(app, click);
|
|
2446
|
+
try harness.runtime.dispatchAutomationCommand(app, "widget-key counter-canvas space");
|
|
2447
|
+
try std.testing.expectEqual(@as(u8, 1), app_state.model.choice);
|
|
2448
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.change_count);
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2373
2451
|
test "the fragment watch reloads a compiled fragment embedded in a Zig view" {
|
|
2374
2452
|
const io = std.testing.io;
|
|
2375
2453
|
const cwd = std.Io.Dir.cwd();
|
|
@@ -3310,17 +3388,23 @@ fn autofocusUpdate(model: *AutofocusModel, msg: AutofocusMsg) void {
|
|
|
3310
3388
|
/// must receive the keyboard without a click.
|
|
3311
3389
|
fn autofocusView(ui: *AutofocusApp.Ui, model: *const AutofocusModel) AutofocusApp.Ui.Node {
|
|
3312
3390
|
if (!model.editing) {
|
|
3313
|
-
return ui.column(.{ .
|
|
3314
|
-
ui.
|
|
3391
|
+
return ui.column(.{ .padding = 12 }, .{
|
|
3392
|
+
ui.scroll(.{ .height = 96 }, ui.column(.{ .gap = 8 }, .{
|
|
3393
|
+
ui.button(.{ .on_press = AutofocusMsg.begin_edit }, "New note"),
|
|
3394
|
+
ui.text(.{ .height = 120 }, "Recent notes"),
|
|
3395
|
+
})),
|
|
3315
3396
|
});
|
|
3316
3397
|
}
|
|
3317
|
-
return ui.column(.{ .
|
|
3318
|
-
ui.
|
|
3319
|
-
|
|
3320
|
-
.
|
|
3321
|
-
.
|
|
3322
|
-
|
|
3323
|
-
|
|
3398
|
+
return ui.column(.{ .padding = 12 }, .{
|
|
3399
|
+
ui.scroll(.{ .height = 96 }, ui.column(.{ .gap = 8 }, .{
|
|
3400
|
+
ui.button(.{ .on_press = AutofocusMsg.begin_edit }, "New note"),
|
|
3401
|
+
ui.text(.{ .height = 120 }, "Recent notes"),
|
|
3402
|
+
ui.textField(.{
|
|
3403
|
+
.autofocus = true,
|
|
3404
|
+
.text = model.draft.text(),
|
|
3405
|
+
.on_input = AutofocusApp.Ui.inputMsg(.draft_edit),
|
|
3406
|
+
}),
|
|
3407
|
+
})),
|
|
3324
3408
|
});
|
|
3325
3409
|
}
|
|
3326
3410
|
|
|
@@ -3375,12 +3459,20 @@ test "ui app autofocus moves the keyboard to a freshly mounted editor through th
|
|
|
3375
3459
|
}
|
|
3376
3460
|
try std.testing.expectEqual(@as(canvas.ObjectId, 0), harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
3377
3461
|
|
|
3378
|
-
// The Cmd-N-shaped command mounts the editor
|
|
3379
|
-
//
|
|
3462
|
+
// The Cmd-N-shaped command mounts the editor BELOW the scroll
|
|
3463
|
+
// viewport; the rebuild's autofocus edge reveals it and moves
|
|
3464
|
+
// keyboard focus to it — no click.
|
|
3380
3465
|
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .name = "note.new", .window_id = 1 } });
|
|
3381
3466
|
try std.testing.expect(app_state.model.editing);
|
|
3382
3467
|
const field_id = findWidgetIdByKind(app_state.tree.?.root, .text_field).?;
|
|
3468
|
+
const scroll_id = findWidgetIdByKind(app_state.tree.?.root, .scroll_view).?;
|
|
3383
3469
|
try std.testing.expectEqual(field_id, harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
3470
|
+
var retained = try harness.runtime.canvasWidgetLayout(1, autofocus_canvas_label);
|
|
3471
|
+
const scroll = retained.findById(scroll_id).?;
|
|
3472
|
+
const field = retained.findById(field_id).?;
|
|
3473
|
+
try std.testing.expect(scroll.widget.value > 0);
|
|
3474
|
+
try std.testing.expect(field.frame.y >= scroll.frame.y);
|
|
3475
|
+
try std.testing.expect(field.frame.maxY() <= scroll.frame.maxY());
|
|
3384
3476
|
|
|
3385
3477
|
// Typing lands in the model through the ordinary input path.
|
|
3386
3478
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
@@ -3392,10 +3484,18 @@ test "ui app autofocus moves the keyboard to a freshly mounted editor through th
|
|
|
3392
3484
|
try std.testing.expectEqualStrings("Groceries", app_state.model.draft.text());
|
|
3393
3485
|
try std.testing.expect(app_state.model.edit_count > 0);
|
|
3394
3486
|
|
|
3395
|
-
// A later rebuild with the flag still true never re-steals focus
|
|
3396
|
-
//
|
|
3487
|
+
// A later rebuild with the flag still true never re-steals focus.
|
|
3488
|
+
// Programmatically focusing the now-offscreen button first also proves
|
|
3489
|
+
// the shared automation focus verb reveals logical targets; its real
|
|
3490
|
+
// click then dispatches begin_edit and rebuilds.
|
|
3397
3491
|
const button_id = findWidgetIdByKind(app_state.tree.?.root, .button).?;
|
|
3398
3492
|
var command_buffer: [96]u8 = undefined;
|
|
3493
|
+
const focus_command = try std.fmt.bufPrint(&command_buffer, "widget-action {s} {d} focus", .{ autofocus_canvas_label, button_id });
|
|
3494
|
+
try harness.runtime.dispatchAutomationCommand(app, focus_command);
|
|
3495
|
+
try std.testing.expectEqual(button_id, harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
3496
|
+
retained = try harness.runtime.canvasWidgetLayout(1, autofocus_canvas_label);
|
|
3497
|
+
try std.testing.expectEqual(@as(f32, 0), retained.findById(scroll_id).?.widget.value);
|
|
3498
|
+
|
|
3399
3499
|
const click_command = try std.fmt.bufPrint(&command_buffer, "widget-click {s} {d}", .{ autofocus_canvas_label, button_id });
|
|
3400
3500
|
try harness.runtime.dispatchAutomationCommand(app, click_command);
|
|
3401
3501
|
try std.testing.expectEqual(button_id, harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
@@ -3895,14 +3995,140 @@ test "ui app status item installs a tray and dispatches its commands" {
|
|
|
3895
3995
|
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayCreateCount());
|
|
3896
3996
|
|
|
3897
3997
|
// Selecting the item dispatches its command through on_command.
|
|
3898
|
-
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 1 });
|
|
3998
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 1 } });
|
|
3899
3999
|
try std.testing.expectEqual(@as(u32, 1), app_state.model.refresh_count);
|
|
3900
4000
|
// Items without commands fall back to the generic name and map to
|
|
3901
4001
|
// no Msg here.
|
|
3902
|
-
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 2 });
|
|
4002
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 2 } });
|
|
3903
4003
|
try std.testing.expectEqual(@as(u32, 1), app_state.model.refresh_count);
|
|
3904
4004
|
}
|
|
3905
4005
|
|
|
4006
|
+
const MultiStatusModel = struct {
|
|
4007
|
+
spend: u32 = 7,
|
|
4008
|
+
controls_visible: bool = true,
|
|
4009
|
+
spend_visible: bool = true,
|
|
4010
|
+
};
|
|
4011
|
+
|
|
4012
|
+
const MultiStatusMsg = union(enum) { bump_spend, toggle_controls, remove_spend };
|
|
4013
|
+
const MultiStatusApp = ui_app_model.UiApp(MultiStatusModel, MultiStatusMsg);
|
|
4014
|
+
|
|
4015
|
+
fn multiStatusUpdate(model: *MultiStatusModel, msg: MultiStatusMsg) void {
|
|
4016
|
+
switch (msg) {
|
|
4017
|
+
.bump_spend => model.spend += 1,
|
|
4018
|
+
.toggle_controls => model.controls_visible = !model.controls_visible,
|
|
4019
|
+
.remove_spend => model.spend_visible = false,
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
fn multiStatusView(ui: *MultiStatusApp.Ui, model: *const MultiStatusModel) MultiStatusApp.Ui.Node {
|
|
4024
|
+
return ui.text(.{}, ui.fmt("Spend {d}", .{model.spend}));
|
|
4025
|
+
}
|
|
4026
|
+
|
|
4027
|
+
fn multiStatusCommand(name: []const u8) ?MultiStatusMsg {
|
|
4028
|
+
if (std.mem.eql(u8, name, "spend.bump")) return .bump_spend;
|
|
4029
|
+
if (std.mem.eql(u8, name, "control.toggle") or std.mem.eql(u8, name, "control.hide") or std.mem.eql(u8, name, "control.show")) return .toggle_controls;
|
|
4030
|
+
if (std.mem.eql(u8, name, "spend.remove")) return .remove_spend;
|
|
4031
|
+
return null;
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
fn multiStatusItems(model: *const MultiStatusModel, scratch: *MultiStatusApp.StatusItemsScratch) []const MultiStatusApp.StatusItemDescriptor {
|
|
4035
|
+
var count: usize = 0;
|
|
4036
|
+
if (model.spend_visible) {
|
|
4037
|
+
const title = std.fmt.bufPrint(&scratch.title_buffers[count], "${d}", .{model.spend}) catch "$";
|
|
4038
|
+
scratch.items[0] = .{ .id = 1, .label = "Refresh spend", .command = "spend.bump" };
|
|
4039
|
+
scratch.items[1] = .{ .id = 2, .label = "Remove spend", .command = "spend.remove" };
|
|
4040
|
+
scratch.status_items[count] = .{
|
|
4041
|
+
.id = 100,
|
|
4042
|
+
.state = .{
|
|
4043
|
+
.presentation = .{ .title = title, .monospaced = true },
|
|
4044
|
+
.icon_path = if (model.spend % 2 == 0) "spend-even.png" else "spend-odd.png",
|
|
4045
|
+
.tooltip = "Vercel spend",
|
|
4046
|
+
.items = scratch.items[0..2],
|
|
4047
|
+
},
|
|
4048
|
+
};
|
|
4049
|
+
count += 1;
|
|
4050
|
+
}
|
|
4051
|
+
const row_start = zero_platform.max_tray_items;
|
|
4052
|
+
scratch.items[row_start] = .{
|
|
4053
|
+
.id = 1,
|
|
4054
|
+
.label = if (model.controls_visible) "Hide controls" else "Show controls",
|
|
4055
|
+
.command = "control.toggle",
|
|
4056
|
+
};
|
|
4057
|
+
scratch.status_items[count] = .{
|
|
4058
|
+
.id = 200,
|
|
4059
|
+
.visible = model.controls_visible,
|
|
4060
|
+
.state = .{
|
|
4061
|
+
.presentation = .{ .title = "V" },
|
|
4062
|
+
.icon_path = if (model.controls_visible) "control-on.png" else "control-off.png",
|
|
4063
|
+
.tooltip = if (model.controls_visible) "Controls visible" else "Controls hidden",
|
|
4064
|
+
.activation_command = if (model.controls_visible) "control.hide" else "control.show",
|
|
4065
|
+
.items = scratch.items[row_start .. row_start + 1],
|
|
4066
|
+
},
|
|
4067
|
+
};
|
|
4068
|
+
count += 1;
|
|
4069
|
+
return scratch.status_items[0..count];
|
|
4070
|
+
}
|
|
4071
|
+
|
|
4072
|
+
test "ui app reconciles multiple status items independently by id" {
|
|
4073
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
4074
|
+
defer harness.destroy(std.testing.allocator);
|
|
4075
|
+
harness.null_platform.gpu_surfaces = true;
|
|
4076
|
+
|
|
4077
|
+
const app_state = try std.testing.allocator.create(MultiStatusApp);
|
|
4078
|
+
defer std.testing.allocator.destroy(app_state);
|
|
4079
|
+
app_state.* = MultiStatusApp.init(std.heap.page_allocator, .{}, .{
|
|
4080
|
+
.name = "ui-app-multi-status",
|
|
4081
|
+
.scene = counter_scene,
|
|
4082
|
+
.canvas_label = canvas_label,
|
|
4083
|
+
.update = multiStatusUpdate,
|
|
4084
|
+
.view = multiStatusView,
|
|
4085
|
+
.on_command = multiStatusCommand,
|
|
4086
|
+
.status_items_fn = multiStatusItems,
|
|
4087
|
+
});
|
|
4088
|
+
defer app_state.deinit();
|
|
4089
|
+
const app = app_state.app();
|
|
4090
|
+
try harness.start(app);
|
|
4091
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
4092
|
+
.label = canvas_label,
|
|
4093
|
+
.size = geometry.SizeF.init(400, 300),
|
|
4094
|
+
.scale_factor = 1,
|
|
4095
|
+
.frame_index = 1,
|
|
4096
|
+
.timestamp_ns = 1_000_000,
|
|
4097
|
+
.nonblank = true,
|
|
4098
|
+
} });
|
|
4099
|
+
|
|
4100
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.statusItemCount());
|
|
4101
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayCreateCount());
|
|
4102
|
+
try std.testing.expectEqualStrings("$7", harness.null_platform.statusItemTitle(100));
|
|
4103
|
+
try std.testing.expectEqualStrings("V", harness.null_platform.statusItemTitle(200));
|
|
4104
|
+
try std.testing.expectEqualStrings("spend-odd.png", harness.null_platform.statusItemIconPath(100));
|
|
4105
|
+
try std.testing.expectEqualStrings("control.hide", harness.null_platform.statusItemActivationCommand(200));
|
|
4106
|
+
|
|
4107
|
+
// Both menus deliberately reuse row id 1; the status-item id keeps
|
|
4108
|
+
// command resolution independent.
|
|
4109
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .status_item_id = 100, .item_id = 1 } });
|
|
4110
|
+
try std.testing.expectEqual(@as(u32, 8), app_state.model.spend);
|
|
4111
|
+
try std.testing.expectEqualStrings("$8", harness.null_platform.statusItemTitle(100));
|
|
4112
|
+
try std.testing.expectEqualStrings("spend-even.png", harness.null_platform.statusItemIconPath(100));
|
|
4113
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayCreateCount());
|
|
4114
|
+
|
|
4115
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .status_item_id = 200, .item_id = 1 } });
|
|
4116
|
+
try std.testing.expect(!harness.null_platform.statusItemVisible(200));
|
|
4117
|
+
try std.testing.expectEqualStrings("control-off.png", harness.null_platform.statusItemIconPath(200));
|
|
4118
|
+
try std.testing.expectEqualStrings("Controls hidden", harness.null_platform.statusItemTooltip(200));
|
|
4119
|
+
try std.testing.expectEqualStrings("control.show", harness.null_platform.statusItemActivationCommand(200));
|
|
4120
|
+
try std.testing.expectEqualStrings("Show controls", harness.null_platform.statusItemMenu(200)[0].label);
|
|
4121
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayCreateCount());
|
|
4122
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.trayShellUpdateCount());
|
|
4123
|
+
try std.testing.expectEqual(@as(usize, 3), harness.null_platform.trayUpdateCount());
|
|
4124
|
+
|
|
4125
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .status_item_id = 100, .item_id = 2 } });
|
|
4126
|
+
try std.testing.expect(!harness.null_platform.statusItemExists(100));
|
|
4127
|
+
try std.testing.expect(harness.null_platform.statusItemExists(200));
|
|
4128
|
+
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.statusItemCount());
|
|
4129
|
+
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayRemoveCount());
|
|
4130
|
+
}
|
|
4131
|
+
|
|
3906
4132
|
// ------------------------------------------------ model-driven status item
|
|
3907
4133
|
|
|
3908
4134
|
const TrayStateModel = struct {
|
|
@@ -4001,7 +4227,7 @@ test "ui app status_item_fn drives the tray title and menu from the model" {
|
|
|
4001
4227
|
|
|
4002
4228
|
// A model change that only affects the TITLE re-titles the live
|
|
4003
4229
|
// button without rebuilding the menu or re-creating the item.
|
|
4004
|
-
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 1 });
|
|
4230
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 1 } });
|
|
4005
4231
|
try std.testing.expectEqual(@as(u32, 4), app_state.model.open_count);
|
|
4006
4232
|
try std.testing.expectEqualStrings("ZN 4", harness.null_platform.lastTrayTitle());
|
|
4007
4233
|
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayTitleUpdateCount());
|
|
@@ -4010,7 +4236,7 @@ test "ui app status_item_fn drives the tray title and menu from the model" {
|
|
|
4010
4236
|
|
|
4011
4237
|
// Selecting a dropdown row closes the loop: tray action -> command ->
|
|
4012
4238
|
// Msg -> model, and the menu (not the title) re-applies.
|
|
4013
|
-
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 11 });
|
|
4239
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 11 } });
|
|
4014
4240
|
try std.testing.expectEqual(@as(u32, 1), app_state.model.selected_issue);
|
|
4015
4241
|
try std.testing.expectEqual(updates_after_install + 1, harness.null_platform.trayUpdateCount());
|
|
4016
4242
|
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayTitleUpdateCount());
|
|
@@ -4018,7 +4244,7 @@ test "ui app status_item_fn drives the tray title and menu from the model" {
|
|
|
4018
4244
|
|
|
4019
4245
|
// A rebuild whose tray output is unchanged touches nothing (the
|
|
4020
4246
|
// repeat selection Msg still rebuilds the view).
|
|
4021
|
-
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = 11 });
|
|
4247
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .tray_action = .{ .item_id = 11 } });
|
|
4022
4248
|
try std.testing.expectEqual(updates_after_install + 1, harness.null_platform.trayUpdateCount());
|
|
4023
4249
|
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayTitleUpdateCount());
|
|
4024
4250
|
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.trayCreateCount());
|
|
@@ -4072,7 +4298,7 @@ test "ui app tray state rides automation snapshots and tray-action drives a row"
|
|
|
4072
4298
|
var writer = std.Io.Writer.fixed(&buffer);
|
|
4073
4299
|
try automation.snapshot.writeText(harness.runtime.automationSnapshot("Tray"), &writer);
|
|
4074
4300
|
const text = writer.buffered();
|
|
4075
|
-
try std.testing.expect(std.mem.indexOf(u8, text, "tray title=\"ZN 3\" items=4\n") != null);
|
|
4301
|
+
try std.testing.expect(std.mem.indexOf(u8, text, "tray #1 title=\"ZN 3\" visible=true items=4\n") != null);
|
|
4076
4302
|
try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #1 label=\"Refresh\" command=\"app.refresh\" enabled=true detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
|
|
4077
4303
|
try std.testing.expect(std.mem.indexOf(u8, text, " tray-item separator\n") != null);
|
|
4078
4304
|
// The fixture disables the SELECTED row (initially issue 0).
|
|
@@ -20,6 +20,7 @@ const settings_window_label = "settings";
|
|
|
20
20
|
|
|
21
21
|
const PanelModel = struct {
|
|
22
22
|
settings_open: bool = false,
|
|
23
|
+
position_settings: bool = true,
|
|
23
24
|
transparent_settings: bool = false,
|
|
24
25
|
bumps: u32 = 0,
|
|
25
26
|
user_closes: u32 = 0,
|
|
@@ -60,6 +61,8 @@ fn panelWindows(model: *const PanelModel, scratch: *PanelApp.WindowsScratch) []c
|
|
|
60
61
|
.title = "Settings",
|
|
61
62
|
.width = 320,
|
|
62
63
|
.height = 240,
|
|
64
|
+
.x = if (model.position_settings) 84 else null,
|
|
65
|
+
.y = if (model.position_settings) 126 else null,
|
|
63
66
|
.min_width = 280,
|
|
64
67
|
.min_height = 200,
|
|
65
68
|
.titlebar = if (model.transparent_settings) .chromeless else .standard,
|
|
@@ -191,6 +194,9 @@ test "a Msg declares the settings window, its canvas installs, and automation dr
|
|
|
191
194
|
if (window.id != info.id) continue;
|
|
192
195
|
try std.testing.expectEqual(@as(f32, 280), null_platform.window_min_width[index]);
|
|
193
196
|
try std.testing.expectEqual(@as(f32, 200), null_platform.window_min_height[index]);
|
|
197
|
+
try std.testing.expectEqual(support.platform.WindowInitialPlacement.explicit, null_platform.window_placement[index]);
|
|
198
|
+
try std.testing.expectEqual(@as(f32, 84), window.frame.x);
|
|
199
|
+
try std.testing.expectEqual(@as(f32, 126), window.frame.y);
|
|
194
200
|
found = true;
|
|
195
201
|
}
|
|
196
202
|
try std.testing.expect(found);
|
|
@@ -226,11 +232,17 @@ test "a Msg declares the settings window, its canvas installs, and automation dr
|
|
|
226
232
|
const closed = fixture.settingsWindowInfo();
|
|
227
233
|
try std.testing.expect(closed == null or !closed.?.open);
|
|
228
234
|
|
|
229
|
-
// Reopen under the SAME label: the closed slot
|
|
235
|
+
// Reopen under the SAME label without an authored origin: the closed slot
|
|
236
|
+
// released it, and a descriptor with no x/y takes default host placement.
|
|
237
|
+
fixture.app_state.model.position_settings = false;
|
|
230
238
|
try fixture.clickSettingsButton();
|
|
231
239
|
try std.testing.expect(fixture.app_state.model.settings_open);
|
|
232
240
|
const reopened = fixture.settingsWindowInfo() orelse return error.TestUnexpectedResult;
|
|
233
241
|
try std.testing.expect(reopened.open);
|
|
242
|
+
for (fixture.harness.null_platform.windows[0..fixture.harness.null_platform.window_count], 0..) |window, index| {
|
|
243
|
+
if (window.id != reopened.id) continue;
|
|
244
|
+
try std.testing.expectEqual(support.platform.WindowInitialPlacement.default, fixture.harness.null_platform.window_placement[index]);
|
|
245
|
+
}
|
|
234
246
|
}
|
|
235
247
|
|
|
236
248
|
test "a transparent descriptor selects premultiplied canvas alpha and an alpha-zero clear" {
|
|
@@ -669,6 +681,7 @@ test "a padded secondary drag header keeps its layout (no double reservation)" {
|
|
|
669
681
|
|
|
670
682
|
const VerbModel = struct {
|
|
671
683
|
settings_open: bool = true,
|
|
684
|
+
close_policy: app_manifest.WindowClosePolicy = .quit,
|
|
672
685
|
};
|
|
673
686
|
|
|
674
687
|
const VerbMsg = union(enum) {
|
|
@@ -709,6 +722,7 @@ fn verbWindows(model: *const VerbModel, scratch: *VerbApp.WindowsScratch) []cons
|
|
|
709
722
|
.title = "Settings",
|
|
710
723
|
.width = 320,
|
|
711
724
|
.height = 240,
|
|
725
|
+
.close_policy = model.close_policy,
|
|
712
726
|
.on_close = .settings_closed,
|
|
713
727
|
};
|
|
714
728
|
count += 1;
|
|
@@ -837,6 +851,7 @@ test "the .hide close then showWindow round-trip: tray Open brings the hidden wi
|
|
|
837
851
|
.window_view = verbWindowView,
|
|
838
852
|
});
|
|
839
853
|
defer app_state.destroy();
|
|
854
|
+
app_state.model.close_policy = .hide;
|
|
840
855
|
const app = app_state.app();
|
|
841
856
|
try harness.start(app);
|
|
842
857
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
@@ -853,17 +868,32 @@ test "the .hide close then showWindow round-trip: tray Open brings the hidden wi
|
|
|
853
868
|
if (std.mem.eql(u8, info.label, settings_window_label)) settings_id = info.id;
|
|
854
869
|
}
|
|
855
870
|
try std.testing.expect(settings_id != 0);
|
|
871
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
872
|
+
.window_id = settings_id,
|
|
873
|
+
.label = settings_canvas_label,
|
|
874
|
+
.size = geometry.SizeF.init(320, 240),
|
|
875
|
+
.scale_factor = 2,
|
|
876
|
+
.frame_index = 1,
|
|
877
|
+
.timestamp_ns = 2_000_000,
|
|
878
|
+
.nonblank = true,
|
|
879
|
+
} });
|
|
880
|
+
_ = try harness.runtime.canvasWidgetLayout(settings_id, settings_canvas_label);
|
|
856
881
|
|
|
857
|
-
//
|
|
858
|
-
//
|
|
859
|
-
//
|
|
860
|
-
|
|
861
|
-
if (window.id == settings_id) harness.null_platform.window_close_policy[index] = .hide;
|
|
862
|
-
}
|
|
882
|
+
// The model-declared descriptor's policy reached the REAL platform
|
|
883
|
+
// create seam. Closing as the user hides the window instead of
|
|
884
|
+
// tearing down its slot, views, or model declaration.
|
|
885
|
+
try std.testing.expectEqual(support.platform.WindowClosePolicy.hide, harness.null_platform.closePolicyForWindow(settings_id).?);
|
|
863
886
|
const hide_event = harness.null_platform.userCloseWindow(settings_id).?;
|
|
864
887
|
try harness.runtime.dispatchPlatformEvent(app, hide_event);
|
|
888
|
+
try std.testing.expect(app_state.model.settings_open);
|
|
889
|
+
try std.testing.expectEqual(@as(usize, 1), app_state.window_slot_count);
|
|
890
|
+
// The canvas tree and view stay installed under the same identity.
|
|
891
|
+
_ = try harness.runtime.canvasWidgetLayout(settings_id, settings_canvas_label);
|
|
865
892
|
for (harness.runtime.listWindows(&buffer)) |info| {
|
|
866
|
-
if (info.id == settings_id)
|
|
893
|
+
if (info.id == settings_id) {
|
|
894
|
+
try std.testing.expect(info.open);
|
|
895
|
+
try std.testing.expect(info.hidden);
|
|
896
|
+
}
|
|
867
897
|
}
|
|
868
898
|
|
|
869
899
|
// The tray "Open" consequence: the model returns the show verb, the
|
|
@@ -882,6 +912,42 @@ test "the .hide close then showWindow round-trip: tray Open brings the hidden wi
|
|
|
882
912
|
}
|
|
883
913
|
}
|
|
884
914
|
|
|
915
|
+
test "a model-declared .hide window is refused on a host that cannot bring it back" {
|
|
916
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
917
|
+
defer harness.destroy(std.testing.allocator);
|
|
918
|
+
harness.null_platform.gpu_surfaces = true;
|
|
919
|
+
harness.null_platform.window_hide_on_close = false;
|
|
920
|
+
const app_state = try VerbApp.create(std.heap.page_allocator, .{
|
|
921
|
+
.name = "ui-app-hide-unsupported",
|
|
922
|
+
.scene = panel_scene,
|
|
923
|
+
.canvas_label = canvas_label,
|
|
924
|
+
.update_fx = verbUpdate,
|
|
925
|
+
.view = verbView,
|
|
926
|
+
.windows_fn = verbWindows,
|
|
927
|
+
.window_view = verbWindowView,
|
|
928
|
+
});
|
|
929
|
+
defer app_state.destroy();
|
|
930
|
+
app_state.model.close_policy = .hide;
|
|
931
|
+
const app = app_state.app();
|
|
932
|
+
try harness.start(app);
|
|
933
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
934
|
+
.label = canvas_label,
|
|
935
|
+
.size = geometry.SizeF.init(400, 300),
|
|
936
|
+
.scale_factor = 2,
|
|
937
|
+
.frame_index = 1,
|
|
938
|
+
.timestamp_ns = 1_000_000,
|
|
939
|
+
.nonblank = true,
|
|
940
|
+
} });
|
|
941
|
+
|
|
942
|
+
// UiApp creation failures degrade to a warning, so the observable
|
|
943
|
+
// contract is that no unreachable window or retained slot exists.
|
|
944
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
945
|
+
for (harness.runtime.listWindows(&buffer)) |info| {
|
|
946
|
+
try std.testing.expect(!std.mem.eql(u8, info.label, settings_window_label));
|
|
947
|
+
}
|
|
948
|
+
try std.testing.expectEqual(@as(usize, 0), app_state.window_slot_count);
|
|
949
|
+
}
|
|
950
|
+
|
|
885
951
|
// ------------------------------------- close_policy (.quit | .hide)
|
|
886
952
|
|
|
887
953
|
test "close_policy .hide: the user close hides the window, nothing tears down, and the reopen re-shows it" {
|
|
@@ -77,9 +77,14 @@ fn validateDialogString(value: []const u8, max_len: usize, allow_empty: bool) !v
|
|
|
77
77
|
|
|
78
78
|
pub fn validateNotificationOptions(options: platform.NotificationOptions) !void {
|
|
79
79
|
if (options.title.len == 0) return error.InvalidNotificationOptions;
|
|
80
|
+
try validateNotificationField(options.id, platform.max_notification_id_bytes);
|
|
80
81
|
try validateNotificationField(options.title, platform.max_notification_title_bytes);
|
|
81
82
|
try validateNotificationField(options.subtitle, platform.max_notification_subtitle_bytes);
|
|
82
83
|
try validateNotificationField(options.body, platform.max_notification_body_bytes);
|
|
84
|
+
try validateNotificationField(options.action_label, platform.max_notification_action_label_bytes);
|
|
85
|
+
try validateNotificationField(options.action_command, platform.max_notification_action_command_bytes);
|
|
86
|
+
if ((options.action_label.len == 0) != (options.action_command.len == 0)) return error.InvalidNotificationOptions;
|
|
87
|
+
if (options.action_command.len > 0) try validateCommandName(options.action_command);
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
pub fn validateClipboardData(data: platform.ClipboardData) !void {
|
|
@@ -130,6 +135,21 @@ pub fn validateTrayOptions(options: platform.TrayOptions) !void {
|
|
|
130
135
|
try validateTrayMenuItems(options.items);
|
|
131
136
|
}
|
|
132
137
|
|
|
138
|
+
pub fn validateStatusItemId(status_item_id: platform.StatusItemId) !void {
|
|
139
|
+
if (status_item_id == 0) return error.InvalidTrayOptions;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
pub fn validateTrayShell(shell: platform.TrayShell) !void {
|
|
143
|
+
try validateTrayField(shell.icon_path, platform.max_tray_icon_path_bytes);
|
|
144
|
+
try validateTrayField(shell.tooltip, platform.max_tray_tooltip_bytes);
|
|
145
|
+
try validateTrayField(shell.activation_command, platform.max_tray_item_command_bytes);
|
|
146
|
+
try validateTrayField(shell.alternate_activation_command, platform.max_tray_item_command_bytes);
|
|
147
|
+
try validateTrayField(shell.open_command, platform.max_tray_item_command_bytes);
|
|
148
|
+
if (shell.activation_command.len > 0) try validateCommandName(shell.activation_command);
|
|
149
|
+
if (shell.alternate_activation_command.len > 0) try validateCommandName(shell.alternate_activation_command);
|
|
150
|
+
if (shell.open_command.len > 0) try validateCommandName(shell.open_command);
|
|
151
|
+
}
|
|
152
|
+
|
|
133
153
|
pub fn validateTrayTitle(title: []const u8) !void {
|
|
134
154
|
try validateTrayField(title, platform.max_tray_title_bytes);
|
|
135
155
|
}
|
package/src/runtime/view.zig
CHANGED
|
@@ -445,6 +445,7 @@ pub const RuntimeView = struct {
|
|
|
445
445
|
canvas_frame_profile_dirty_ratio: f32 = 0,
|
|
446
446
|
widget_layout_nodes: [max_canvas_widget_nodes_per_view]canvas.WidgetLayoutNode = undefined,
|
|
447
447
|
widget_layout_node_count: usize = 0,
|
|
448
|
+
widget_layout_root_bounds: ?geometry.RectF = null,
|
|
448
449
|
widget_semantics_nodes: [max_canvas_widget_semantics_per_view]canvas.WidgetSemanticsNode = undefined,
|
|
449
450
|
widget_semantics_node_count: usize = 0,
|
|
450
451
|
/// Fingerprint of the last accessibility tree actually handed to the
|
|
@@ -863,6 +864,7 @@ pub const RuntimeView = struct {
|
|
|
863
864
|
pub const applyCanvasWidgetTextareaScroll = CanvasWidgetScrollMethods.applyCanvasWidgetTextareaScroll;
|
|
864
865
|
pub const applyCanvasWidgetScrollDriverOffset = CanvasWidgetScrollMethods.applyCanvasWidgetScrollDriverOffset;
|
|
865
866
|
pub const applyCanvasWidgetScrollKeyboardTarget = CanvasWidgetScrollMethods.applyCanvasWidgetScrollKeyboardTarget;
|
|
867
|
+
pub const canScrollCanvasWidgetIntoView = CanvasWidgetScrollMethods.canScrollCanvasWidgetIntoView;
|
|
866
868
|
pub const scrollCanvasWidgetIntoView = CanvasWidgetScrollMethods.scrollCanvasWidgetIntoView;
|
|
867
869
|
pub const stepCanvasWidgetKineticScroll = CanvasWidgetScrollMethods.stepCanvasWidgetKineticScroll;
|
|
868
870
|
pub const canvasWidgetScrollContentExtent = CanvasWidgetScrollMethods.canvasWidgetScrollContentExtent;
|
|
@@ -981,6 +983,7 @@ pub const RuntimeView = struct {
|
|
|
981
983
|
pub const canvasWidgetTopmostAnchoredDismissibleIndex = CanvasWidgetTreeMethods.canvasWidgetTopmostAnchoredDismissibleIndex;
|
|
982
984
|
pub const canvasWidgetRouteDescendsFromIndex = CanvasWidgetTreeMethods.canvasWidgetRouteDescendsFromIndex;
|
|
983
985
|
pub const canvasWidgetScopedFocusTarget = CanvasWidgetTreeMethods.canvasWidgetScopedFocusTarget;
|
|
986
|
+
pub const canvasWidgetRovingTabTarget = CanvasWidgetTreeMethods.canvasWidgetRovingTabTarget;
|
|
984
987
|
pub const canvasWidgetFocusTargetInScope = CanvasWidgetTreeMethods.canvasWidgetFocusTargetInScope;
|
|
985
988
|
pub const canvasWidgetForwardFocusTargetInScope = CanvasWidgetTreeMethods.canvasWidgetForwardFocusTargetInScope;
|
|
986
989
|
pub const canvasWidgetBackwardFocusTargetInScope = CanvasWidgetTreeMethods.canvasWidgetBackwardFocusTargetInScope;
|
|
@@ -379,6 +379,24 @@ pub fn RuntimeViewCanvasWidgetControl(comptime RuntimeView: type) type {
|
|
|
379
379
|
dirty = unionRects(dirty, self.canvasWidgetDirtyBounds(row_index, node.frame));
|
|
380
380
|
changed = true;
|
|
381
381
|
}
|
|
382
|
+
} else if (selected and widget.kind == .radio) {
|
|
383
|
+
// A radio group is one logical selection scope even when
|
|
384
|
+
// layout containers wrap its radios. Nearest-ancestor
|
|
385
|
+
// resolution also isolates nested radio groups. A bare
|
|
386
|
+
// radio deliberately falls back to its direct parent.
|
|
387
|
+
const scope = canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(self.widgetLayoutTree(), index);
|
|
388
|
+
const parent_index = self.widget_layout_nodes[index].parent_index;
|
|
389
|
+
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, radio_index| {
|
|
390
|
+
if (radio_index == index or node.widget.kind != .radio) continue;
|
|
391
|
+
if (scope) |radio_group_index| {
|
|
392
|
+
if (canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(self.widgetLayoutTree(), radio_index) != radio_group_index) continue;
|
|
393
|
+
} else if (node.parent_index != parent_index or canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(self.widgetLayoutTree(), radio_index) != null) continue;
|
|
394
|
+
if (!canvasWidgetSelectableSelected(node.widget)) continue;
|
|
395
|
+
node.widget.state.selected = false;
|
|
396
|
+
node.widget.value = 0;
|
|
397
|
+
dirty = unionRects(dirty, self.canvasWidgetDirtyBounds(radio_index, node.frame));
|
|
398
|
+
changed = true;
|
|
399
|
+
}
|
|
382
400
|
} else if (selected and canvasWidgetSelectionClearsSiblings(widget.kind)) {
|
|
383
401
|
const parent_index = self.widget_layout_nodes[index].parent_index;
|
|
384
402
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, sibling_index| {
|