@native-sdk/cli 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +26 -9
- package/build.zig +124 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/packages/core/sdk/events.d.ts +7 -0
- package/packages/core/sdk/events.ts +26 -5
- package/packages/core/sdk/text.d.ts +4 -0
- package/packages/core/sdk/text.ts +51 -0
- package/packages/core/src/checker.ts +58 -1
- package/packages/core/src/contract.ts +5 -4
- package/packages/core/src/devhost_journal.mjs +2 -2
- package/packages/core/src/diagnostics.ts +2 -2
- package/packages/core/src/service_contract.ts +10 -0
- package/packages/core/src/typed_ast.ts +9 -7
- package/packages/core/src/types.ts +28 -8
- package/skill-data/automation/SKILL.md +4 -3
- package/skill-data/native-ui/SKILL.md +10 -8
- package/skill-data/ts-core/SKILL.md +8 -5
- package/src/app_runner/root.zig +301 -12
- package/src/app_runner/ts_core_main.zig +6 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +119 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +271 -52
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +222 -14
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +129 -1
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +14 -2
- package/src/primitives/canvas/text_interaction.zig +23 -0
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +65 -0
- package/src/primitives/canvas/ui.zig +66 -10
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +67 -6
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +84 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +593 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +33 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/canvas_widget_text_tests.zig +124 -0
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +29 -0
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_journal.zig +21 -2
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ts_ui_app.zig +164 -1
- package/src/runtime/ui_app.zig +100 -21
- package/src/runtime/ui_app_tests.zig +351 -32
- package/src/runtime/ui_app_window_tests.zig +13 -1
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_text.zig +1 -1
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +128 -18
- package/src/tooling/verbs.zig +1 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +31 -12
- package/tools/corewire/emit_facade.zig +57 -2
- package/tools/corewire/shim_rt.zig +20 -0
|
@@ -28,6 +28,16 @@ pub const Msg = union(enum) {
|
|
|
28
28
|
toggle: u32,
|
|
29
29
|
set_filter: Filter,
|
|
30
30
|
draft: canvas.TextInputEvent,
|
|
31
|
+
drag: DragPayload,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
pub const DragPayload = struct {
|
|
35
|
+
sourceId: usize,
|
|
36
|
+
phase: u8,
|
|
37
|
+
x: f32,
|
|
38
|
+
y: f32,
|
|
39
|
+
viewWidth: f32,
|
|
40
|
+
viewHeight: f32,
|
|
31
41
|
};
|
|
32
42
|
|
|
33
43
|
pub const Model = struct {
|
|
@@ -1208,6 +1218,35 @@ pub const context_menu_markup_source =
|
|
|
1208
1218
|
\\</column>
|
|
1209
1219
|
;
|
|
1210
1220
|
|
|
1221
|
+
pub const drag_context_menu_markup_source =
|
|
1222
|
+
\\<row on-drag="drag:{open_count}" label="Draggable row">
|
|
1223
|
+
\\ <text>Drag me</text>
|
|
1224
|
+
\\ <context-menu>
|
|
1225
|
+
\\ <menu-item on-press="add">Duplicate</menu-item>
|
|
1226
|
+
\\ </context-menu>
|
|
1227
|
+
\\</row>
|
|
1228
|
+
;
|
|
1229
|
+
|
|
1230
|
+
test "a drag-only layout element can host a context menu" {
|
|
1231
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1232
|
+
defer arena_state.deinit();
|
|
1233
|
+
const arena = arena_state.allocator();
|
|
1234
|
+
const model = testModel();
|
|
1235
|
+
|
|
1236
|
+
var parser = canvas.ui_markup.Parser.init(arena, drag_context_menu_markup_source);
|
|
1237
|
+
try testing.expectEqual(@as(?canvas.ui_markup.MarkupErrorInfo, null), canvas.ui_markup.validate(try parser.parse()));
|
|
1238
|
+
|
|
1239
|
+
var view = try InboxMarkup.init(arena, drag_context_menu_markup_source);
|
|
1240
|
+
var ui = InboxUi.init(arena);
|
|
1241
|
+
const tree = try ui.finalize(try view.build(&ui, &model));
|
|
1242
|
+
try testing.expect(tree.root.semantics.actions.drag);
|
|
1243
|
+
try testing.expect(canvas.widgetIsHitTarget(tree.root));
|
|
1244
|
+
try testing.expect(canvas.widgetClaimsPress(tree.root));
|
|
1245
|
+
try testing.expectEqual(@as(usize, 1), tree.root.context_menu.len);
|
|
1246
|
+
try testing.expectEqualStrings("Duplicate", tree.root.context_menu[0].label);
|
|
1247
|
+
try testing.expectEqual(Msg.add, tree.msgForContextMenu(tree.root.id, 0).?);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1211
1250
|
test "markup context-menus lower to declared platform-menu items on their host" {
|
|
1212
1251
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1213
1252
|
defer arena_state.deinit();
|
|
@@ -1418,6 +1457,12 @@ test "the registry's a11y name classes match the engine's control predicates" {
|
|
|
1418
1457
|
if (entry.a11y_name == .image) {
|
|
1419
1458
|
try testing.expect(kind == .avatar or kind == .media_surface or kind == .image);
|
|
1420
1459
|
}
|
|
1460
|
+
// Radio-group is the one named container class: it is not a hit
|
|
1461
|
+
// target, but its label supplies the shared question announced
|
|
1462
|
+
// around the descendant radio choices.
|
|
1463
|
+
if (entry.a11y_name == .radiogroup) {
|
|
1464
|
+
try testing.expectEqual(canvas.WidgetKind.radio_group, kind);
|
|
1465
|
+
}
|
|
1421
1466
|
}
|
|
1422
1467
|
}
|
|
1423
1468
|
|
|
@@ -2169,10 +2214,10 @@ pub const catalog_markup_source =
|
|
|
2169
2214
|
\\ </row>
|
|
2170
2215
|
\\ <row gap="8">
|
|
2171
2216
|
\\ <input text="{query}" placeholder="Name" autofocus="true" on-input="query_edit" on-submit="submit_query" grow="1" />
|
|
2172
|
-
\\ <combobox text="{query}" placeholder="Search fruit" on-input="query_edit" />
|
|
2217
|
+
\\ <combobox text="{query}" placeholder="Search fruit" on-input="query_edit" on-press="open_picker" on-submit="submit_query" />
|
|
2173
2218
|
\\ </row>
|
|
2174
|
-
\\ <radio-group gap="4">
|
|
2175
|
-
\\ <radio checked="{bold}" on-
|
|
2219
|
+
\\ <radio-group gap="4" label="Formatting">
|
|
2220
|
+
\\ <radio checked="{bold}" on-change="toggle_bold" label="Bold" />
|
|
2176
2221
|
\\ </radio-group>
|
|
2177
2222
|
\\ <accordion text="Details" selected="{details_open}" on-toggle="toggle_details" padding="8">
|
|
2178
2223
|
\\ <text>More info</text>
|
|
@@ -2299,10 +2344,10 @@ pub fn handCatalogView(ui: *CatalogUi, model: *const CatalogModel) CatalogUi.Nod
|
|
|
2299
2344
|
}),
|
|
2300
2345
|
ui.row(.{ .gap = 8 }, .{
|
|
2301
2346
|
ui.el(.input, .{ .text = model.query, .placeholder = "Name", .autofocus = true, .on_input = CatalogUi.inputMsg(.query_edit), .on_submit = .submit_query, .grow = 1 }, .{}),
|
|
2302
|
-
ui.el(.combobox, .{ .text = model.query, .placeholder = "Search fruit", .on_input = CatalogUi.inputMsg(.query_edit) }, .{}),
|
|
2347
|
+
ui.el(.combobox, .{ .text = model.query, .placeholder = "Search fruit", .on_input = CatalogUi.inputMsg(.query_edit), .on_press = .open_picker, .on_submit = .submit_query }, .{}),
|
|
2303
2348
|
}),
|
|
2304
|
-
ui.el(.radio_group, .{ .gap = 4 }, .{
|
|
2305
|
-
ui.el(.radio, .{ .checked = model.bold, .
|
|
2349
|
+
ui.el(.radio_group, .{ .gap = 4, .semantics = .{ .label = "Formatting" } }, .{
|
|
2350
|
+
ui.el(.radio, .{ .checked = model.bold, .on_change = .toggle_bold }, .{}),
|
|
2306
2351
|
}),
|
|
2307
2352
|
ui.el(.accordion, .{ .text = "Details", .selected = model.details_open, .on_toggle = .toggle_details, .padding = 8 }, .{
|
|
2308
2353
|
ui.text(.{}, "More info"),
|
|
@@ -2444,6 +2489,10 @@ test "catalog elements build the hand-written tree and dispatch typed messages"
|
|
|
2444
2489
|
try testing.expectEqualStrings("q", markup_tree.msgForKeyboard(input.id, typed).?.query_edit.insert_text);
|
|
2445
2490
|
const submit = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "enter" };
|
|
2446
2491
|
try testing.expectEqual(CatalogMsg.submit_query, markup_tree.msgForKeyboard(input.id, submit).?);
|
|
2492
|
+
const combobox = findByKind(markup_tree.root, .combobox).?;
|
|
2493
|
+
try testing.expectEqual(CatalogMsg.submit_query, markup_tree.msgForKeyboard(combobox.id, submit).?);
|
|
2494
|
+
try testing.expectEqual(CatalogMsg.open_picker, markup_tree.msgForKeyboard(combobox.id, .{ .phase = .key_down, .key = "space" }).?);
|
|
2495
|
+
try testing.expectEqual(CatalogMsg.open_picker, markup_tree.msgForKeyboard(combobox.id, .{ .phase = .key_down, .key = "arrowdown" }).?);
|
|
2447
2496
|
|
|
2448
2497
|
// The whole catalog lays out through the canvas engine.
|
|
2449
2498
|
var nodes: [256]canvas.WidgetLayoutNode = undefined;
|
|
@@ -4615,6 +4664,8 @@ pub const MirrorTextInputEvent = union(enum) {
|
|
|
4615
4664
|
delete_forward,
|
|
4616
4665
|
delete_word_backward,
|
|
4617
4666
|
delete_word_forward,
|
|
4667
|
+
delete_to_start,
|
|
4668
|
+
delete_to_line_start,
|
|
4618
4669
|
clear,
|
|
4619
4670
|
move_caret: MirrorCaretMove,
|
|
4620
4671
|
set_selection: MirrorSelection,
|
|
@@ -4642,6 +4693,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4642
4693
|
delete_forward,
|
|
4643
4694
|
delete_word_backward,
|
|
4644
4695
|
delete_word_forward,
|
|
4696
|
+
delete_to_start,
|
|
4697
|
+
delete_to_line_start,
|
|
4645
4698
|
clear,
|
|
4646
4699
|
move_caret: MirrorCaretMove,
|
|
4647
4700
|
set_selection: MirrorSelectionWithAffinity,
|
|
@@ -4658,6 +4711,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4658
4711
|
delete_forward,
|
|
4659
4712
|
delete_word_backward,
|
|
4660
4713
|
delete_word_forward,
|
|
4714
|
+
delete_to_start,
|
|
4715
|
+
delete_to_line_start,
|
|
4661
4716
|
clear,
|
|
4662
4717
|
move_caret: MirrorCaretMove,
|
|
4663
4718
|
set_selection: MirrorSelection,
|
|
@@ -4671,6 +4726,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4671
4726
|
delete_forward,
|
|
4672
4727
|
delete_word_backward,
|
|
4673
4728
|
delete_word_forward,
|
|
4729
|
+
delete_to_start,
|
|
4730
|
+
delete_to_line_start,
|
|
4674
4731
|
clear,
|
|
4675
4732
|
move_caret: MirrorCaretMove,
|
|
4676
4733
|
set_selection: MirrorSelection,
|
|
@@ -4686,6 +4743,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4686
4743
|
delete_forward,
|
|
4687
4744
|
delete_word_backward,
|
|
4688
4745
|
delete_word_forward,
|
|
4746
|
+
delete_to_start,
|
|
4747
|
+
delete_to_line_start,
|
|
4689
4748
|
clear,
|
|
4690
4749
|
move_caret: struct { direction: WrongDirection, extend: bool },
|
|
4691
4750
|
set_selection: MirrorSelection,
|
|
@@ -4939,6 +4998,8 @@ test "the interpreter binds on-input to a declared mirror union and translates e
|
|
|
4939
4998
|
try testing.expectEqualStrings("abc", inserted.edit.insert_text);
|
|
4940
4999
|
// Void verbs map by tag.
|
|
4941
5000
|
try testing.expectEqual(MirrorTextInputEvent.delete_backward, tree.msgForTextEdit(field.id, .delete_backward).?.edit);
|
|
5001
|
+
try testing.expectEqual(MirrorTextInputEvent.delete_to_start, tree.msgForTextEdit(field.id, .delete_to_start).?.edit);
|
|
5002
|
+
try testing.expectEqual(MirrorTextInputEvent.delete_to_line_start, tree.msgForTextEdit(field.id, .delete_to_line_start).?.edit);
|
|
4942
5003
|
// Caret moves translate the direction enum by member name.
|
|
4943
5004
|
const moved = tree.msgForTextEdit(field.id, .{ .move_caret = .{ .direction = .previous_word, .extend = true } }).?;
|
|
4944
5005
|
try testing.expectEqual(MirrorCaretDirection.previous_word, moved.edit.move_caret.direction);
|
|
@@ -50,7 +50,7 @@ const std = @import("std");
|
|
|
50
50
|
/// documents, journals, serialized contracts) carry it; readers reach
|
|
51
51
|
/// older artifacts through document→document migrations, never silent
|
|
52
52
|
/// reinterpretation.
|
|
53
|
-
pub const schema_version: u16 =
|
|
53
|
+
pub const schema_version: u16 = 2;
|
|
54
54
|
|
|
55
55
|
/// Value type-class of an attribute: what shape of value the engines
|
|
56
56
|
/// accept for it. `option` values name a Zig enum member (the enum itself
|
|
@@ -128,8 +128,8 @@ pub const EventInfo = struct {
|
|
|
128
128
|
/// ever receive this event.
|
|
129
129
|
dismissible_only: bool = false,
|
|
130
130
|
/// This handler binds control/text behavior a non-hit-target element
|
|
131
|
-
/// does not have, so it is a dead handler there (press/toggle
|
|
132
|
-
/// exempt:
|
|
131
|
+
/// does not have, so it is a dead handler there (press/toggle/drag
|
|
132
|
+
/// are exempt: their handlers make any element interactive).
|
|
133
133
|
dead_on_non_hit_target: bool = false,
|
|
134
134
|
};
|
|
135
135
|
|
|
@@ -145,12 +145,16 @@ pub const EventInfo = struct {
|
|
|
145
145
|
/// - `image`: pictorial content. An unnamed image degrades (announced as
|
|
146
146
|
/// an unnamed image) but does not block, so a missing alt-equivalent
|
|
147
147
|
/// label is a WARNING; an explicit `label=""` marks it decorative.
|
|
148
|
+
/// - `radiogroup`: a single-choice container whose label supplies the
|
|
149
|
+
/// shared question for its individually named choices. Only a nonblank
|
|
150
|
+
/// `label` names the group; a missing one is an ERROR.
|
|
148
151
|
/// - `none`: layout, decoration, and content whose name IS its text.
|
|
149
152
|
pub const A11yNameRule = enum {
|
|
150
153
|
none,
|
|
151
154
|
control,
|
|
152
155
|
editable,
|
|
153
156
|
image,
|
|
157
|
+
radiogroup,
|
|
154
158
|
};
|
|
155
159
|
|
|
156
160
|
pub const ElementInfo = struct {
|
|
@@ -221,7 +225,7 @@ pub const elements = [_]ElementInfo{
|
|
|
221
225
|
.{ .code = 11, .name = "breadcrumb", .widget_kind = "breadcrumb", .hit_target = false },
|
|
222
226
|
.{ .code = 12, .name = "button-group", .widget_kind = "button_group", .hit_target = false },
|
|
223
227
|
.{ .code = 13, .name = "pagination", .widget_kind = "pagination", .hit_target = false },
|
|
224
|
-
.{ .code = 14, .name = "radio-group", .widget_kind = "radio_group", .hit_target = false },
|
|
228
|
+
.{ .code = 14, .name = "radio-group", .widget_kind = "radio_group", .hit_target = false, .a11y_name = .radiogroup },
|
|
225
229
|
.{ .code = 15, .name = "tabs", .widget_kind = "tabs", .hit_target = false },
|
|
226
230
|
.{ .code = 16, .name = "toggle-group", .widget_kind = "toggle_group", .hit_target = false },
|
|
227
231
|
// Vertical containers.
|
|
@@ -257,8 +261,8 @@ pub const elements = [_]ElementInfo{
|
|
|
257
261
|
// paints whenever the view renders it.
|
|
258
262
|
.{ .code = 39, .name = "tooltip", .widget_kind = "tooltip", .takes_text = true, .hit_target = false, .anchorable = true },
|
|
259
263
|
// Value controls and text entry.
|
|
260
|
-
.{ .code = 40, .name = "checkbox", .widget_kind = "checkbox", .a11y_name = .control },
|
|
261
|
-
.{ .code = 41, .name = "radio", .widget_kind = "radio", .a11y_name = .control },
|
|
264
|
+
.{ .code = 40, .name = "checkbox", .widget_kind = "checkbox", .takes_text = true, .a11y_name = .control },
|
|
265
|
+
.{ .code = 41, .name = "radio", .widget_kind = "radio", .takes_text = true, .a11y_name = .control },
|
|
262
266
|
.{ .code = 42, .name = "slider", .widget_kind = "slider", .a11y_name = .control },
|
|
263
267
|
.{ .code = 43, .name = "progress", .widget_kind = "progress" },
|
|
264
268
|
.{ .code = 44, .name = "text-field", .widget_kind = "text_field", .a11y_name = .editable },
|
|
@@ -683,12 +687,12 @@ pub const icon_names = [_][]const u8{
|
|
|
683
687
|
/// std-only) with a lockstep test in ui_markup_view_tests.zig holding the
|
|
684
688
|
/// mirror equal to the live enum.
|
|
685
689
|
pub const role_names = [_][]const u8{
|
|
686
|
-
"none",
|
|
687
|
-
"button",
|
|
688
|
-
"menuitem",
|
|
689
|
-
"gridcell",
|
|
690
|
-
"slider", "progressbar", "chart",
|
|
691
|
-
"separator",
|
|
690
|
+
"none", "group", "text", "link", "image",
|
|
691
|
+
"button", "textbox", "tooltip", "dialog", "menu",
|
|
692
|
+
"menuitem", "list", "listitem", "row", "grid",
|
|
693
|
+
"gridcell", "tab", "checkbox", "radio", "radiogroup",
|
|
694
|
+
"switch_control", "slider", "progressbar", "chart", "tree",
|
|
695
|
+
"treeitem", "separator",
|
|
692
696
|
};
|
|
693
697
|
|
|
694
698
|
/// Roles that promise CHILD STRUCTURE to assistive tech (rows, items,
|
|
@@ -696,7 +700,7 @@ pub const role_names = [_][]const u8{
|
|
|
696
700
|
/// cannot hold element children (see `elementHoldsChildren`) is role
|
|
697
701
|
/// misuse the registry can see: the promise can never be kept.
|
|
698
702
|
pub const container_role_names = [_][]const u8{
|
|
699
|
-
"tree", "list", "menu", "grid", "row", "dialog",
|
|
703
|
+
"tree", "list", "menu", "grid", "row", "dialog", "radiogroup",
|
|
700
704
|
};
|
|
701
705
|
|
|
702
706
|
/// Whether markup can put element children inside this element: text
|
|
@@ -349,6 +349,43 @@ test "keyboard events resolve activation and submit messages" {
|
|
|
349
349
|
try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(checkbox.id, letter));
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
test "combobox Enter prefers submit while its other open keys still press" {
|
|
353
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
354
|
+
defer arena_state.deinit();
|
|
355
|
+
|
|
356
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
357
|
+
const tree = try ui.finalize(ui.column(.{}, .{
|
|
358
|
+
ui.el(.combobox, .{
|
|
359
|
+
.text = "both handlers",
|
|
360
|
+
.on_press = .load_more,
|
|
361
|
+
.on_submit = .add,
|
|
362
|
+
}, .{}),
|
|
363
|
+
ui.el(.combobox, .{
|
|
364
|
+
.text = "press only",
|
|
365
|
+
.on_press = .load_more,
|
|
366
|
+
}, .{}),
|
|
367
|
+
ui.el(.combobox, .{
|
|
368
|
+
.text = "submit only",
|
|
369
|
+
.on_submit = .add,
|
|
370
|
+
}, .{}),
|
|
371
|
+
}));
|
|
372
|
+
|
|
373
|
+
const both = tree.root.children[0];
|
|
374
|
+
const press_only = tree.root.children[1];
|
|
375
|
+
const submit_only = tree.root.children[2];
|
|
376
|
+
const enter = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "enter" };
|
|
377
|
+
const space = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "space" };
|
|
378
|
+
const arrow_down = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "arrowdown" };
|
|
379
|
+
const arrow_up = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "arrowup" };
|
|
380
|
+
|
|
381
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(both.id, enter).?);
|
|
382
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(both.id, space).?);
|
|
383
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(both.id, arrow_down).?);
|
|
384
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(both.id, arrow_up).?);
|
|
385
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(press_only.id, enter).?);
|
|
386
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(submit_only.id, enter).?);
|
|
387
|
+
}
|
|
388
|
+
|
|
352
389
|
test "tree keyboard navigation can select without dispatching pointer activation" {
|
|
353
390
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
354
391
|
defer arena_state.deinit();
|
|
@@ -375,6 +412,53 @@ test "tree keyboard navigation can select without dispatching pointer activation
|
|
|
375
412
|
}).?);
|
|
376
413
|
}
|
|
377
414
|
|
|
415
|
+
test "radio selection dispatches change then toggle then press on every input path" {
|
|
416
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
417
|
+
defer arena_state.deinit();
|
|
418
|
+
|
|
419
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
420
|
+
const tree = try ui.finalize(ui.el(.radio_group, .{}, .{
|
|
421
|
+
ui.el(.radio, .{ .text = "All", .on_change = .add, .on_toggle = .load_more }, .{}),
|
|
422
|
+
ui.el(.radio, .{ .text = "Toggle fallback", .on_toggle = .load_more, .on_press = .add }, .{}),
|
|
423
|
+
ui.el(.radio, .{ .text = "Press fallback", .on_press = .add }, .{}),
|
|
424
|
+
ui.el(.radio, .{ .text = "Selected", .checked = true, .on_change = .add, .on_press = .load_more }, .{}),
|
|
425
|
+
}));
|
|
426
|
+
const change_radio = tree.root.children[0];
|
|
427
|
+
const toggle_radio = tree.root.children[1];
|
|
428
|
+
const press_radio = tree.root.children[2];
|
|
429
|
+
const selected_radio = tree.root.children[3];
|
|
430
|
+
|
|
431
|
+
try testing.expectEqual(Msg.add, tree.msgForPointer(change_radio.id, .up).?);
|
|
432
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(change_radio.id, .{ .phase = .key_down, .key = "space" }).?);
|
|
433
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(change_radio.id, .{ .phase = .key_down, .key = "enter" }).?);
|
|
434
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(change_radio.id, .{
|
|
435
|
+
.phase = .key_down,
|
|
436
|
+
.key = "arrowright",
|
|
437
|
+
.focus_moved = true,
|
|
438
|
+
.radio_group_navigation = true,
|
|
439
|
+
.radio_group_selection = true,
|
|
440
|
+
}).?);
|
|
441
|
+
try testing.expectEqual(Msg.load_more, tree.msgForPointer(toggle_radio.id, .up).?);
|
|
442
|
+
try testing.expectEqual(Msg.add, tree.msgForPointer(press_radio.id, .up).?);
|
|
443
|
+
|
|
444
|
+
// `on_change` is an edge, not an activation alias. Direct tree
|
|
445
|
+
// consumers derive the result from source state; runtime events carry
|
|
446
|
+
// the retained mutation explicitly. Reselecting falls through to the
|
|
447
|
+
// historical activation handler when one exists.
|
|
448
|
+
try testing.expectEqual(Msg.load_more, tree.msgForPointer(selected_radio.id, .up).?);
|
|
449
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(selected_radio.id, .{ .phase = .key_down, .key = "space" }).?);
|
|
450
|
+
try testing.expectEqual(Msg.load_more, tree.msgForPointerEvent(change_radio.id, .{
|
|
451
|
+
.phase = .up,
|
|
452
|
+
.point = .{},
|
|
453
|
+
.radio_selection_changed = false,
|
|
454
|
+
}).?);
|
|
455
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(selected_radio.id, .{
|
|
456
|
+
.phase = .key_down,
|
|
457
|
+
.key = "space",
|
|
458
|
+
.radio_selection_changed = true,
|
|
459
|
+
}).?);
|
|
460
|
+
}
|
|
461
|
+
|
|
378
462
|
test "textarea keyboard: the default and chat-composer Enter policies stay distinct" {
|
|
379
463
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
380
464
|
defer arena_state.deinit();
|
|
@@ -174,15 +174,15 @@ pub fn widgetKindClaimsPress(kind: WidgetKind) bool {
|
|
|
174
174
|
|
|
175
175
|
/// Whether a press gesture stops at this widget instead of falling
|
|
176
176
|
/// through to the nearest claiming ancestor: an interactive kind
|
|
177
|
-
/// (`widgetKindClaimsPress`), or ANY widget with a bound press/toggle
|
|
178
|
-
/// handler (`on_press`/`on_toggle` stamp `semantics.actions`, and
|
|
177
|
+
/// (`widgetKindClaimsPress`), or ANY widget with a bound press/toggle/drag
|
|
178
|
+
/// handler (`on_press`/`on_toggle`/`on_drag` stamp `semantics.actions`, and
|
|
179
179
|
/// engine-owned `command` dispatch only exists on kinds already claiming).
|
|
180
180
|
/// Disabled widgets never claim — the hit test skips them too, so a press
|
|
181
181
|
/// on a disabled control keeps today's behavior of landing on whatever is
|
|
182
182
|
/// around it.
|
|
183
183
|
pub fn widgetClaimsPress(widget: Widget) bool {
|
|
184
184
|
if (widget.id == 0 or widget.state.disabled) return false;
|
|
185
|
-
if (widget.semantics.actions.press or widget.semantics.actions.toggle) return true;
|
|
185
|
+
if (widget.semantics.actions.press or widget.semantics.actions.toggle or widget.semantics.actions.drag) return true;
|
|
186
186
|
return widgetKindClaimsPress(widget.kind);
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -182,6 +182,44 @@ test "leaf trigger kinds lay out their anchored children" {
|
|
|
182
182
|
try std.testing.expect(layout.findById(4) != null);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
test "anchored relayout recomputes placement from a translated trigger frame" {
|
|
186
|
+
const menu_items = [_]Widget{.{ .id = 5, .kind = .menu_item, .frame = geometry.RectF.init(0, 0, 0, 24), .text = "One" }};
|
|
187
|
+
const dropdown = Widget{
|
|
188
|
+
.id = 4,
|
|
189
|
+
.kind = .dropdown_menu,
|
|
190
|
+
.frame = geometry.RectF.init(0, 0, 140, 50),
|
|
191
|
+
.layout = .{ .anchor = .{} },
|
|
192
|
+
.children = &menu_items,
|
|
193
|
+
};
|
|
194
|
+
const wrap_children = [_]Widget{
|
|
195
|
+
.{ .id = 3, .kind = .text, .text = "Files" },
|
|
196
|
+
dropdown,
|
|
197
|
+
};
|
|
198
|
+
const scroll_children = [_]Widget{
|
|
199
|
+
.{ .id = 2, .kind = .stack, .frame = geometry.RectF.init(0, 140, 160, 28), .children = &wrap_children },
|
|
200
|
+
.{ .id = 6, .kind = .panel, .frame = geometry.RectF.init(0, 320, 160, 20) },
|
|
201
|
+
};
|
|
202
|
+
const scroll = Widget{ .id = 1, .kind = .scroll_view, .children = &scroll_children };
|
|
203
|
+
var nodes: [6]WidgetLayoutNode = undefined;
|
|
204
|
+
const layout = try canvas.layoutWidgetTree(scroll, geometry.RectF.init(0, 0, 180, 100), &nodes);
|
|
205
|
+
|
|
206
|
+
// Model the post-layout scroll restore: content moved, while the old
|
|
207
|
+
// anchored frame merely rode the translation and retained its stale
|
|
208
|
+
// pre-scroll clamp.
|
|
209
|
+
for (nodes[1..layout.nodes.len]) |*node| {
|
|
210
|
+
node.frame.y -= 130;
|
|
211
|
+
node.widget.frame = node.frame;
|
|
212
|
+
}
|
|
213
|
+
try canvas.relayoutAnchoredChildren(nodes[0..layout.nodes.len], .{});
|
|
214
|
+
|
|
215
|
+
const relaid = canvas.WidgetLayoutTree{ .nodes = nodes[0..layout.nodes.len] };
|
|
216
|
+
const trigger = relaid.findById(2).?.frame;
|
|
217
|
+
const surface = relaid.findById(4).?.frame;
|
|
218
|
+
try std.testing.expectEqual(@as(f32, 10), trigger.y);
|
|
219
|
+
try std.testing.expectEqual(trigger.maxY() + 4, surface.y);
|
|
220
|
+
try std.testing.expectEqual(@as(f32, 50), surface.height);
|
|
221
|
+
}
|
|
222
|
+
|
|
185
223
|
/// The shared fixture for z-order/clip tests: a scroll pane whose content
|
|
186
224
|
/// holds the trigger + anchored dropdown, and a LATER sibling panel the
|
|
187
225
|
/// dropdown overlaps. In-tree paint order would put the panel above the
|
|
@@ -217,6 +255,74 @@ fn firstCommandIndexForWidget(list: canvas.DisplayList, widget_id: canvas.Object
|
|
|
217
255
|
return null;
|
|
218
256
|
}
|
|
219
257
|
|
|
258
|
+
test "window-level modals paint and route above later anchored overlays" {
|
|
259
|
+
const dialog = Widget{
|
|
260
|
+
.id = 2,
|
|
261
|
+
.kind = .dialog,
|
|
262
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
263
|
+
};
|
|
264
|
+
const dropdown = Widget{
|
|
265
|
+
.id = 3,
|
|
266
|
+
.kind = .dropdown_menu,
|
|
267
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
268
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(100, 100) } },
|
|
269
|
+
};
|
|
270
|
+
// The dropdown mounts later and overlaps the centered dialog exactly.
|
|
271
|
+
// Modal token order, not raw node order, owns the window-level stack.
|
|
272
|
+
const root = Widget{ .id = 1, .kind = .stack, .children = &.{ dialog, dropdown } };
|
|
273
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
274
|
+
const layout = try canvas.layoutWidgetTree(root, window, &nodes);
|
|
275
|
+
|
|
276
|
+
var commands: [64]canvas.CanvasCommand = undefined;
|
|
277
|
+
var builder = canvas.Builder.init(&commands);
|
|
278
|
+
try layout.emitDisplayList(&builder, .{});
|
|
279
|
+
const list = builder.displayList();
|
|
280
|
+
const dialog_index = firstCommandIndexForWidget(list, 2) orelse return error.TestUnexpectedResult;
|
|
281
|
+
const dropdown_index = firstCommandIndexForWidget(list, 3) orelse return error.TestUnexpectedResult;
|
|
282
|
+
try std.testing.expect(dialog_index > dropdown_index);
|
|
283
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 2), layout.hitTest(geometry.PointF.init(150, 150)).?.id);
|
|
284
|
+
|
|
285
|
+
// An explicit layer remains the author-controlled escape hatch.
|
|
286
|
+
const elevated_dropdown = Widget{
|
|
287
|
+
.id = 3,
|
|
288
|
+
.kind = .dropdown_menu,
|
|
289
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
290
|
+
.layer = 400,
|
|
291
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(100, 100) } },
|
|
292
|
+
};
|
|
293
|
+
const elevated_root = Widget{ .id = 1, .kind = .stack, .children = &.{ dialog, elevated_dropdown } };
|
|
294
|
+
var elevated_nodes: [4]WidgetLayoutNode = undefined;
|
|
295
|
+
const elevated = try canvas.layoutWidgetTree(elevated_root, window, &elevated_nodes);
|
|
296
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 3), elevated.hitTest(geometry.PointF.init(150, 150)).?.id);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
test "default anchored surfaces inside a modal stay above their modal" {
|
|
300
|
+
const dropdown = Widget{
|
|
301
|
+
.id = 3,
|
|
302
|
+
.kind = .dropdown_menu,
|
|
303
|
+
.frame = geometry.RectF.init(0, 0, 100, 50),
|
|
304
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(120, 120) } },
|
|
305
|
+
};
|
|
306
|
+
const dialog = Widget{
|
|
307
|
+
.id = 2,
|
|
308
|
+
.kind = .dialog,
|
|
309
|
+
.frame = geometry.RectF.init(0, 0, 200, 100),
|
|
310
|
+
.children = &.{dropdown},
|
|
311
|
+
};
|
|
312
|
+
const root = Widget{ .id = 1, .kind = .stack, .children = &.{dialog} };
|
|
313
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
314
|
+
const layout = try canvas.layoutWidgetTree(root, window, &nodes);
|
|
315
|
+
|
|
316
|
+
var commands: [64]canvas.CanvasCommand = undefined;
|
|
317
|
+
var builder = canvas.Builder.init(&commands);
|
|
318
|
+
try layout.emitDisplayList(&builder, .{});
|
|
319
|
+
const list = builder.displayList();
|
|
320
|
+
const dialog_index = firstCommandIndexForWidget(list, 2) orelse return error.TestUnexpectedResult;
|
|
321
|
+
const dropdown_index = firstCommandIndexForWidget(list, 3) orelse return error.TestUnexpectedResult;
|
|
322
|
+
try std.testing.expect(dropdown_index > dialog_index);
|
|
323
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 3), layout.hitTest(geometry.PointF.init(140, 140)).?.id);
|
|
324
|
+
}
|
|
325
|
+
|
|
220
326
|
test "anchored surfaces render in a late z-pass above later siblings and outside ancestor clips" {
|
|
221
327
|
var nodes: [8]WidgetLayoutNode = undefined;
|
|
222
328
|
const layout = try buildOverlapFixture(&nodes);
|