@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
|
@@ -47,6 +47,18 @@ fn counterThemePack(model: *const CounterModel) canvas.ThemePack {
|
|
|
47
47
|
return if (model.count == 0) .house else .geist;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
fn counterThemeState(model: *const CounterModel) CounterApp.ThemeState {
|
|
51
|
+
return switch (model.count) {
|
|
52
|
+
0 => .{ .color_scheme = .dark },
|
|
53
|
+
1 => .{ .pack = .geist, .color_scheme = .system, .accent = canvas.Color.rgb8(0, 0x78, 0x6f) },
|
|
54
|
+
else => .{ .pack = .house, .color_scheme = .light, .accent = canvas.Color.rgb8(0xdf, 0x26, 0x70) },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fn invalidCounterThemeState(_: *const CounterModel) CounterApp.ThemeState {
|
|
59
|
+
return .{ .invalid_accent = "pink" };
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
const counter_views = [_]app_manifest.ShellView{
|
|
51
63
|
.{ .label = canvas_label, .kind = .gpu_surface, .fill = true, .gpu_backend = .metal },
|
|
52
64
|
};
|
|
@@ -70,6 +82,43 @@ fn counterOptions() CounterApp.Options {
|
|
|
70
82
|
};
|
|
71
83
|
}
|
|
72
84
|
|
|
85
|
+
const RadioModel = struct {
|
|
86
|
+
choice: u8 = 0,
|
|
87
|
+
change_count: u32 = 0,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const RadioMsg = union(enum) {
|
|
91
|
+
choose_first,
|
|
92
|
+
choose_second,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const RadioApp = ui_app_model.UiApp(RadioModel, RadioMsg);
|
|
96
|
+
|
|
97
|
+
fn radioUpdate(model: *RadioModel, msg: RadioMsg) void {
|
|
98
|
+
model.choice = switch (msg) {
|
|
99
|
+
.choose_first => 0,
|
|
100
|
+
.choose_second => 1,
|
|
101
|
+
};
|
|
102
|
+
model.change_count += 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fn radioView(ui: *RadioApp.Ui, model: *const RadioModel) RadioApp.Ui.Node {
|
|
106
|
+
return ui.el(.radio_group, .{ .semantics = .{ .label = "Plan" } }, .{
|
|
107
|
+
ui.el(.radio, .{ .text = "Free", .checked = model.choice == 0, .on_change = .choose_first }, .{}),
|
|
108
|
+
ui.el(.radio, .{ .text = "Pro", .checked = model.choice == 1, .on_change = .choose_second }, .{}),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fn radioOptions() RadioApp.Options {
|
|
113
|
+
return .{
|
|
114
|
+
.name = "ui-app-radio",
|
|
115
|
+
.scene = counter_scene,
|
|
116
|
+
.canvas_label = canvas_label,
|
|
117
|
+
.update = radioUpdate,
|
|
118
|
+
.view = radioView,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
73
122
|
const software_counter_views = [_]app_manifest.ShellView{
|
|
74
123
|
.{ .label = canvas_label, .kind = .gpu_surface, .fill = true, .gpu_backend = .software },
|
|
75
124
|
};
|
|
@@ -772,13 +821,19 @@ test "a declared context menu presents as the anchored fallback surface on prese
|
|
|
772
821
|
try std.testing.expect(app_state.tree.?.context_menu_fallback == null);
|
|
773
822
|
try std.testing.expect(!try retainedWidgetKindExists(&harness.runtime, .dropdown_menu));
|
|
774
823
|
|
|
775
|
-
// Reopen and
|
|
776
|
-
//
|
|
824
|
+
// Reopen and click outside. The fallback was opened from a typically
|
|
825
|
+
// non-focusable secondary-click target, so no focused ancestry is
|
|
826
|
+
// available to find it; the whole-view anchored fallback must still
|
|
827
|
+
// dismiss it. Its internal open state closes and no app Msg fires.
|
|
777
828
|
try harness.runtime.dispatchAutomationCommand(app, context_press);
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
829
|
+
_ = app_state.tree.?.context_menu_fallback orelse return error.TestUnexpectedResult;
|
|
830
|
+
harness.runtime.views[0].canvas_widget_focused_id = 0;
|
|
831
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
832
|
+
.label = canvas_label,
|
|
833
|
+
.kind = .pointer_down,
|
|
834
|
+
.x = 360,
|
|
835
|
+
.y = 280,
|
|
836
|
+
} });
|
|
782
837
|
try std.testing.expect(app_state.tree.?.context_menu_fallback == null);
|
|
783
838
|
try std.testing.expect(!try retainedWidgetKindExists(&harness.runtime, .dropdown_menu));
|
|
784
839
|
try std.testing.expectEqual(@as(u32, 1), app_state.model.deleted);
|
|
@@ -1877,6 +1932,117 @@ test "model-derived theme packs retain live appearance, accent, and surface scal
|
|
|
1877
1932
|
try std.testing.expectEqual(@as(f32, 2), actual.pixel_snap.scale);
|
|
1878
1933
|
}
|
|
1879
1934
|
|
|
1935
|
+
test "model-derived theme state composes forced/system schemes and model accent over manifest defaults" {
|
|
1936
|
+
var options = counterOptions();
|
|
1937
|
+
options.theme = .house;
|
|
1938
|
+
options.theme_accent = canvas.Color.rgb8(0x12, 0x34, 0x56);
|
|
1939
|
+
options.theme_state_fn = counterThemeState;
|
|
1940
|
+
|
|
1941
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
1942
|
+
defer std.testing.allocator.destroy(app_state);
|
|
1943
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
1944
|
+
defer app_state.deinit();
|
|
1945
|
+
app_state.system_appearance = .{ .color_scheme = .light };
|
|
1946
|
+
app_state.pixel_snap_scale = 2;
|
|
1947
|
+
|
|
1948
|
+
// Model-forced dark wins over an OS-light appearance; omitted pack and
|
|
1949
|
+
// accent inherit the manifest-backed options.
|
|
1950
|
+
var expected = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .pack = .house });
|
|
1951
|
+
expected = expected.withOverrides(canvas.accentOverrides(options.theme_accent.?, .dark));
|
|
1952
|
+
var actual = app_state.effectiveTokens();
|
|
1953
|
+
try std.testing.expectEqualDeep(expected.colors.background, actual.colors.background);
|
|
1954
|
+
try std.testing.expectEqualDeep(expected.colors.accent, actual.colors.accent);
|
|
1955
|
+
try std.testing.expectEqual(@as(f32, 2), actual.pixel_snap.scale);
|
|
1956
|
+
|
|
1957
|
+
// `system` resumes live OS following while model pack/accent override the
|
|
1958
|
+
// manifest values.
|
|
1959
|
+
app_state.model.count = 1;
|
|
1960
|
+
app_state.theme_state_known = false;
|
|
1961
|
+
app_state.system_appearance = .{ .color_scheme = .dark };
|
|
1962
|
+
const teal = canvas.Color.rgb8(0, 0x78, 0x6f);
|
|
1963
|
+
expected = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .pack = .geist });
|
|
1964
|
+
expected = expected.withOverrides(canvas.accentOverrides(teal, .dark));
|
|
1965
|
+
actual = app_state.effectiveTokens();
|
|
1966
|
+
try std.testing.expectEqualDeep(expected.colors.background, actual.colors.background);
|
|
1967
|
+
try std.testing.expectEqualDeep(teal, actual.colors.accent);
|
|
1968
|
+
try std.testing.expectEqualDeep(canvas.accentFocusRing(teal, .dark), actual.colors.focus_ring);
|
|
1969
|
+
|
|
1970
|
+
// High contrast keeps the existing accessibility rule: neither the
|
|
1971
|
+
// model nor manifest accent layers over the pack's loud register.
|
|
1972
|
+
app_state.system_appearance.high_contrast = true;
|
|
1973
|
+
actual = app_state.effectiveTokens();
|
|
1974
|
+
const loud = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .contrast = .high, .pack = .geist });
|
|
1975
|
+
try std.testing.expectEqualDeep(loud.colors.accent, actual.colors.accent);
|
|
1976
|
+
try std.testing.expect(!std.meta.eql(teal, actual.colors.accent));
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
test "malformed adapter theme accents reject the rebuild instead of inheriting silently" {
|
|
1980
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1981
|
+
defer harness.destroy(std.testing.allocator);
|
|
1982
|
+
harness.null_platform.gpu_surfaces = true;
|
|
1983
|
+
var options = counterOptions();
|
|
1984
|
+
options.theme_state_fn = invalidCounterThemeState;
|
|
1985
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
1986
|
+
defer std.testing.allocator.destroy(app_state);
|
|
1987
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
1988
|
+
defer app_state.deinit();
|
|
1989
|
+
const app = app_state.app();
|
|
1990
|
+
try harness.start(app);
|
|
1991
|
+
try std.testing.expectError(error.InvalidThemeAccent, harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
1992
|
+
.label = canvas_label,
|
|
1993
|
+
.size = geometry.SizeF.init(400, 300),
|
|
1994
|
+
.scale_factor = 1,
|
|
1995
|
+
.frame_index = 1,
|
|
1996
|
+
.timestamp_ns = 1_000_000,
|
|
1997
|
+
.nonblank = true,
|
|
1998
|
+
} }));
|
|
1999
|
+
try std.testing.expect(!app_state.installed);
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
test "forced theme state still follows accessibility axes while scheme-only OS flips do not restyle" {
|
|
2003
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2004
|
+
defer harness.destroy(std.testing.allocator);
|
|
2005
|
+
harness.null_platform.gpu_surfaces = true;
|
|
2006
|
+
|
|
2007
|
+
var options = counterOptions();
|
|
2008
|
+
options.theme_state_fn = counterThemeState; // count 0 forces dark.
|
|
2009
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
2010
|
+
defer std.testing.allocator.destroy(app_state);
|
|
2011
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
2012
|
+
defer app_state.deinit();
|
|
2013
|
+
const app = app_state.app();
|
|
2014
|
+
try harness.start(app);
|
|
2015
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{ .color_scheme = .light } });
|
|
2016
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
2017
|
+
.label = canvas_label,
|
|
2018
|
+
.size = geometry.SizeF.init(400, 300),
|
|
2019
|
+
.scale_factor = 1,
|
|
2020
|
+
.frame_index = 1,
|
|
2021
|
+
.timestamp_ns = 1_000_000,
|
|
2022
|
+
.nonblank = true,
|
|
2023
|
+
} });
|
|
2024
|
+
var stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
2025
|
+
const dark = canvas.DesignTokens.theme(.{ .color_scheme = .dark });
|
|
2026
|
+
try std.testing.expectEqualDeep(dark.colors.background, stored.colors.background);
|
|
2027
|
+
|
|
2028
|
+
// A scheme-only flip cannot override the forced state.
|
|
2029
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{ .color_scheme = .dark } });
|
|
2030
|
+
stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
2031
|
+
try std.testing.expectEqualDeep(dark.colors.background, stored.colors.background);
|
|
2032
|
+
|
|
2033
|
+
// Accessibility axes remain live even under a forced color scheme.
|
|
2034
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{
|
|
2035
|
+
.color_scheme = .light,
|
|
2036
|
+
.high_contrast = true,
|
|
2037
|
+
.reduce_motion = true,
|
|
2038
|
+
} });
|
|
2039
|
+
stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
2040
|
+
const dark_loud = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .contrast = .high, .reduce_motion = true });
|
|
2041
|
+
try std.testing.expectEqualDeep(dark_loud.colors.background, stored.colors.background);
|
|
2042
|
+
try std.testing.expectEqualDeep(dark_loud.colors.focus_ring, stored.colors.focus_ring);
|
|
2043
|
+
try std.testing.expectEqual(@as(u32, 0), stored.motion.normal_ms);
|
|
2044
|
+
}
|
|
2045
|
+
|
|
1880
2046
|
test "static tokens carry the surface scale and re-snap on a scale change" {
|
|
1881
2047
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1882
2048
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -2370,6 +2536,41 @@ fn installCounterApp(harness: anytype, app: core.App) !void {
|
|
|
2370
2536
|
} });
|
|
2371
2537
|
}
|
|
2372
2538
|
|
|
2539
|
+
test "radio accessibility selection dispatches change once per retained transition" {
|
|
2540
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2541
|
+
defer harness.destroy(std.testing.allocator);
|
|
2542
|
+
harness.null_platform.gpu_surfaces = true;
|
|
2543
|
+
|
|
2544
|
+
const app_state = try std.testing.allocator.create(RadioApp);
|
|
2545
|
+
defer std.testing.allocator.destroy(app_state);
|
|
2546
|
+
app_state.* = RadioApp.init(std.heap.page_allocator, .{}, radioOptions());
|
|
2547
|
+
defer app_state.deinit();
|
|
2548
|
+
const app = app_state.app();
|
|
2549
|
+
try installCounterApp(harness, app);
|
|
2550
|
+
|
|
2551
|
+
const pro_id = findWidgetIdByText(app_state.tree.?, .radio, "Pro").?;
|
|
2552
|
+
_ = try harness.runtime.dispatchCanvasWidgetAccessibilityAction(app, 1, canvas_label, .{
|
|
2553
|
+
.id = pro_id,
|
|
2554
|
+
.action = .select,
|
|
2555
|
+
});
|
|
2556
|
+
try std.testing.expectEqual(@as(u8, 1), app_state.model.choice);
|
|
2557
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.change_count);
|
|
2558
|
+
try std.testing.expect((try harness.runtime.canvasWidgetLayout(1, canvas_label)).findById(pro_id).?.widget.state.selected);
|
|
2559
|
+
|
|
2560
|
+
// AX selection, pointer activation, and Space all still activate the
|
|
2561
|
+
// radio, but an already-selected control has no new `on_change` edge.
|
|
2562
|
+
_ = try harness.runtime.dispatchCanvasWidgetAccessibilityAction(app, 1, canvas_label, .{
|
|
2563
|
+
.id = pro_id,
|
|
2564
|
+
.action = .select,
|
|
2565
|
+
});
|
|
2566
|
+
var command_buffer: [96]u8 = undefined;
|
|
2567
|
+
const click = try std.fmt.bufPrint(&command_buffer, "widget-click {s} {d}", .{ canvas_label, pro_id });
|
|
2568
|
+
try harness.runtime.dispatchAutomationCommand(app, click);
|
|
2569
|
+
try harness.runtime.dispatchAutomationCommand(app, "widget-key counter-canvas space");
|
|
2570
|
+
try std.testing.expectEqual(@as(u8, 1), app_state.model.choice);
|
|
2571
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.change_count);
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2373
2574
|
test "the fragment watch reloads a compiled fragment embedded in a Zig view" {
|
|
2374
2575
|
const io = std.testing.io;
|
|
2375
2576
|
const cwd = std.Io.Dir.cwd();
|
|
@@ -3064,6 +3265,73 @@ test "automation composition and selection verbs keep the model mirror consisten
|
|
|
3064
3265
|
try std.testing.expectEqualStrings("", canceled_layout.findById(field_id).?.widget.text);
|
|
3065
3266
|
}
|
|
3066
3267
|
|
|
3268
|
+
test "macOS Command Backspace keeps the controlled TextBuffer mirror and history in lockstep" {
|
|
3269
|
+
if (comptime @import("builtin").os.tag != .macos) return error.SkipZigTest;
|
|
3270
|
+
|
|
3271
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
3272
|
+
defer harness.destroy(std.testing.allocator);
|
|
3273
|
+
harness.null_platform.gpu_surfaces = true;
|
|
3274
|
+
|
|
3275
|
+
const app_state = try std.testing.allocator.create(SearchMirrorApp);
|
|
3276
|
+
defer std.testing.allocator.destroy(app_state);
|
|
3277
|
+
try startSearchMirror(harness, app_state);
|
|
3278
|
+
defer app_state.deinit();
|
|
3279
|
+
const app = app_state.app();
|
|
3280
|
+
const field_id = findWidgetIdByKind(app_state.tree.?.root, .search_field).?;
|
|
3281
|
+
|
|
3282
|
+
try core.testing.dispatchAutomationWidgetAction(&harness.runtime, app, .{
|
|
3283
|
+
.view_label = search_mirror_canvas_label,
|
|
3284
|
+
.id = field_id,
|
|
3285
|
+
.action = .set_text,
|
|
3286
|
+
.value = "second line",
|
|
3287
|
+
});
|
|
3288
|
+
for (0..5) |_| {
|
|
3289
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3290
|
+
.window_id = 1,
|
|
3291
|
+
.label = search_mirror_canvas_label,
|
|
3292
|
+
.kind = .key_down,
|
|
3293
|
+
.key = "arrowleft",
|
|
3294
|
+
} });
|
|
3295
|
+
}
|
|
3296
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(6), app_state.model.query.selection);
|
|
3297
|
+
|
|
3298
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3299
|
+
.window_id = 1,
|
|
3300
|
+
.label = search_mirror_canvas_label,
|
|
3301
|
+
.kind = .key_down,
|
|
3302
|
+
.key = "backspace",
|
|
3303
|
+
.modifiers = .{ .primary = true, .command = true },
|
|
3304
|
+
} });
|
|
3305
|
+
try std.testing.expectEqualStrings(" line", app_state.model.query.text());
|
|
3306
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(0), app_state.model.query.selection);
|
|
3307
|
+
var retained = try harness.runtime.canvasWidgetLayout(1, search_mirror_canvas_label);
|
|
3308
|
+
try std.testing.expectEqualStrings(app_state.model.query.text(), retained.findById(field_id).?.widget.text);
|
|
3309
|
+
try std.testing.expectEqualDeep(app_state.model.query.selection, retained.findById(field_id).?.widget.text_selection.?);
|
|
3310
|
+
|
|
3311
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3312
|
+
.window_id = 1,
|
|
3313
|
+
.label = search_mirror_canvas_label,
|
|
3314
|
+
.kind = .key_down,
|
|
3315
|
+
.key = "z",
|
|
3316
|
+
.modifiers = .{ .primary = true, .command = true },
|
|
3317
|
+
} });
|
|
3318
|
+
try std.testing.expectEqualStrings("second line", app_state.model.query.text());
|
|
3319
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(6), app_state.model.query.selection);
|
|
3320
|
+
|
|
3321
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3322
|
+
.window_id = 1,
|
|
3323
|
+
.label = search_mirror_canvas_label,
|
|
3324
|
+
.kind = .key_down,
|
|
3325
|
+
.key = "z",
|
|
3326
|
+
.modifiers = .{ .primary = true, .command = true, .shift = true },
|
|
3327
|
+
} });
|
|
3328
|
+
try std.testing.expectEqualStrings(" line", app_state.model.query.text());
|
|
3329
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(0), app_state.model.query.selection);
|
|
3330
|
+
retained = try harness.runtime.canvasWidgetLayout(1, search_mirror_canvas_label);
|
|
3331
|
+
try std.testing.expectEqualStrings(app_state.model.query.text(), retained.findById(field_id).?.widget.text);
|
|
3332
|
+
try std.testing.expectEqualDeep(app_state.model.query.selection, retained.findById(field_id).?.widget.text_selection.?);
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3067
3335
|
// --------------------------------- combobox open-arrow (mirror invariant)
|
|
3068
3336
|
|
|
3069
3337
|
const combo_mirror_canvas_label = "combo-mirror-canvas";
|
|
@@ -3073,12 +3341,16 @@ const ComboMirrorModel = struct {
|
|
|
3073
3341
|
note: canvas.TextBuffer(64) = .{},
|
|
3074
3342
|
open: bool = false,
|
|
3075
3343
|
opens: u32 = 0,
|
|
3344
|
+
submits: u32 = 0,
|
|
3345
|
+
picks: u32 = 0,
|
|
3076
3346
|
query_edits: u32 = 0,
|
|
3077
3347
|
};
|
|
3078
3348
|
|
|
3079
3349
|
const ComboMirrorMsg = union(enum) {
|
|
3080
3350
|
open_picker,
|
|
3081
3351
|
close_picker,
|
|
3352
|
+
submit_query,
|
|
3353
|
+
pick_query: []const u8,
|
|
3082
3354
|
query_edit: canvas.TextInputEvent,
|
|
3083
3355
|
note_edit: canvas.TextInputEvent,
|
|
3084
3356
|
};
|
|
@@ -3092,6 +3364,16 @@ fn comboMirrorUpdate(model: *ComboMirrorModel, msg: ComboMirrorMsg) void {
|
|
|
3092
3364
|
model.opens += 1;
|
|
3093
3365
|
},
|
|
3094
3366
|
.close_picker => model.open = false,
|
|
3367
|
+
.submit_query => {
|
|
3368
|
+
model.open = false;
|
|
3369
|
+
model.submits += 1;
|
|
3370
|
+
},
|
|
3371
|
+
.pick_query => |query| {
|
|
3372
|
+
model.query.clear();
|
|
3373
|
+
model.query.apply(.{ .insert_text = query });
|
|
3374
|
+
model.open = false;
|
|
3375
|
+
model.picks += 1;
|
|
3376
|
+
},
|
|
3095
3377
|
.query_edit => |edit| {
|
|
3096
3378
|
model.query.apply(edit);
|
|
3097
3379
|
model.query_edits += 1;
|
|
@@ -3107,6 +3389,7 @@ fn comboMirrorView(ui: *ComboMirrorApp.Ui, model: *const ComboMirrorModel) Combo
|
|
|
3107
3389
|
.width = 200,
|
|
3108
3390
|
.expanded = model.open,
|
|
3109
3391
|
.on_press = .open_picker,
|
|
3392
|
+
.on_submit = .submit_query,
|
|
3110
3393
|
.on_input = ComboMirrorApp.Ui.inputMsg(.query_edit),
|
|
3111
3394
|
}, .{});
|
|
3112
3395
|
const picker = if (model.open) ui.stack(.{ .height = 28 }, .{
|
|
@@ -3118,8 +3401,8 @@ fn comboMirrorView(ui: *ComboMirrorApp.Ui, model: *const ComboMirrorModel) Combo
|
|
|
3118
3401
|
.height = 60,
|
|
3119
3402
|
.on_dismiss = .close_picker,
|
|
3120
3403
|
}, .{
|
|
3121
|
-
ui.el(.menu_item, .{ .key = .{ .int = 0 }, .text = "glass bead", .height = 26, .on_press = .
|
|
3122
|
-
ui.el(.menu_item, .{ .key = .{ .int = 1 }, .text = "glass jar", .height = 26, .on_press = .
|
|
3404
|
+
ui.el(.menu_item, .{ .key = .{ .int = 0 }, .text = "glass bead", .height = 26, .on_press = ComboMirrorMsg{ .pick_query = "glass bead" } }, .{}),
|
|
3405
|
+
ui.el(.menu_item, .{ .key = .{ .int = 1 }, .text = "glass jar", .height = 26, .on_press = ComboMirrorMsg{ .pick_query = "glass jar" } }, .{}),
|
|
3123
3406
|
}),
|
|
3124
3407
|
}) else ui.stack(.{ .height = 28 }, .{trigger});
|
|
3125
3408
|
return ui.column(.{ .gap = 8, .padding = 12 }, .{
|
|
@@ -3159,7 +3442,7 @@ fn comboMirrorRetainedSelection(harness: *core.TestHarness(), id: canvas.ObjectI
|
|
|
3159
3442
|
return layout.findById(id).?.widget.text_selection;
|
|
3160
3443
|
}
|
|
3161
3444
|
|
|
3162
|
-
test "
|
|
3445
|
+
test "combobox submit precedence and open-menu selection keep the text mirror consistent" {
|
|
3163
3446
|
// The split-brain escapee: a CLOSED combobox maps ArrowUp/Down to
|
|
3164
3447
|
// BOTH its open press (`widgetKeyboardControlIntent`'s menu-open
|
|
3165
3448
|
// keys) and — through the single-line caret derivation — a stamped
|
|
@@ -3214,6 +3497,19 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3214
3497
|
try std.testing.expectEqualStrings("glass", app_state.model.query.text());
|
|
3215
3498
|
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3216
3499
|
|
|
3500
|
+
// Enter resolves through on_submit BEFORE the trigger's open press.
|
|
3501
|
+
// The closed picker stays closed and neither side of the text mirror
|
|
3502
|
+
// changes while the submit message commits.
|
|
3503
|
+
const edits_before_submit = app_state.model.query_edits;
|
|
3504
|
+
try comboMirrorKey(harness, app, "enter");
|
|
3505
|
+
try std.testing.expect(!app_state.model.open);
|
|
3506
|
+
try std.testing.expectEqual(@as(u32, 0), app_state.model.opens);
|
|
3507
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.submits);
|
|
3508
|
+
try std.testing.expectEqual(edits_before_submit, app_state.model.query_edits);
|
|
3509
|
+
try std.testing.expectEqualStrings("glass", app_state.model.query.text());
|
|
3510
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3511
|
+
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(3)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3512
|
+
|
|
3217
3513
|
// THE pin: ArrowDown on the closed trigger opens the picker and
|
|
3218
3514
|
// both carets stay at 3 — no query edit is heard or applied.
|
|
3219
3515
|
const edits_before_open = app_state.model.query_edits;
|
|
@@ -3224,9 +3520,10 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3224
3520
|
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3225
3521
|
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(3)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3226
3522
|
|
|
3227
|
-
// The OPEN-picker truth
|
|
3228
|
-
//
|
|
3229
|
-
//
|
|
3523
|
+
// The OPEN-picker truth: the next arrow walks the keyboard INTO the
|
|
3524
|
+
// mounted menu (the focus step consumes it before routing reaches
|
|
3525
|
+
// the trigger), so Enter selects that menu item instead of reaching
|
|
3526
|
+
// the combobox submit handler again.
|
|
3230
3527
|
const first_item_id = findWidgetIdByText(app_state.tree.?, .menu_item, "glass bead").?;
|
|
3231
3528
|
try comboMirrorKey(harness, app, "arrowdown");
|
|
3232
3529
|
try std.testing.expectEqual(first_item_id, harness.runtime.views[0].canvas_widget_focused_id);
|
|
@@ -3234,12 +3531,12 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3234
3531
|
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3235
3532
|
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(3)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3236
3533
|
|
|
3237
|
-
|
|
3238
|
-
// the picker closes through `on_dismiss` and the combobox's
|
|
3239
|
-
// Escape-clear never runs — the query survives.
|
|
3240
|
-
try comboMirrorKey(harness, app, "escape");
|
|
3534
|
+
try comboMirrorKey(harness, app, "enter");
|
|
3241
3535
|
try std.testing.expect(!app_state.model.open);
|
|
3242
|
-
try std.testing.
|
|
3536
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.submits);
|
|
3537
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.picks);
|
|
3538
|
+
try std.testing.expectEqualStrings("glass bead", app_state.model.query.text());
|
|
3539
|
+
try std.testing.expectEqualStrings("glass bead", (try harness.runtime.canvasWidgetLayout(1, combo_mirror_canvas_label)).findById(combo_id).?.widget.text);
|
|
3243
3540
|
try std.testing.expectEqual(combo_id, harness.runtime.views[0].canvas_widget_focused_id);
|
|
3244
3541
|
|
|
3245
3542
|
// ArrowUp on the closed trigger is the same open key: opens, and
|
|
@@ -3248,8 +3545,8 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3248
3545
|
try std.testing.expect(app_state.model.open);
|
|
3249
3546
|
try std.testing.expectEqual(@as(u32, 2), app_state.model.opens);
|
|
3250
3547
|
try std.testing.expectEqual(edits_before_open, app_state.model.query_edits);
|
|
3251
|
-
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(
|
|
3252
|
-
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(
|
|
3548
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed("glass bead".len), app_state.model.query.selection);
|
|
3549
|
+
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed("glass bead".len)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3253
3550
|
try comboMirrorKey(harness, app, "escape");
|
|
3254
3551
|
try std.testing.expect(!app_state.model.open);
|
|
3255
3552
|
|
|
@@ -3310,17 +3607,23 @@ fn autofocusUpdate(model: *AutofocusModel, msg: AutofocusMsg) void {
|
|
|
3310
3607
|
/// must receive the keyboard without a click.
|
|
3311
3608
|
fn autofocusView(ui: *AutofocusApp.Ui, model: *const AutofocusModel) AutofocusApp.Ui.Node {
|
|
3312
3609
|
if (!model.editing) {
|
|
3313
|
-
return ui.column(.{ .
|
|
3314
|
-
ui.
|
|
3610
|
+
return ui.column(.{ .padding = 12 }, .{
|
|
3611
|
+
ui.scroll(.{ .height = 96 }, ui.column(.{ .gap = 8 }, .{
|
|
3612
|
+
ui.button(.{ .on_press = AutofocusMsg.begin_edit }, "New note"),
|
|
3613
|
+
ui.text(.{ .height = 120 }, "Recent notes"),
|
|
3614
|
+
})),
|
|
3315
3615
|
});
|
|
3316
3616
|
}
|
|
3317
|
-
return ui.column(.{ .
|
|
3318
|
-
ui.
|
|
3319
|
-
|
|
3320
|
-
.
|
|
3321
|
-
.
|
|
3322
|
-
|
|
3323
|
-
|
|
3617
|
+
return ui.column(.{ .padding = 12 }, .{
|
|
3618
|
+
ui.scroll(.{ .height = 96 }, ui.column(.{ .gap = 8 }, .{
|
|
3619
|
+
ui.button(.{ .on_press = AutofocusMsg.begin_edit }, "New note"),
|
|
3620
|
+
ui.text(.{ .height = 120 }, "Recent notes"),
|
|
3621
|
+
ui.textField(.{
|
|
3622
|
+
.autofocus = true,
|
|
3623
|
+
.text = model.draft.text(),
|
|
3624
|
+
.on_input = AutofocusApp.Ui.inputMsg(.draft_edit),
|
|
3625
|
+
}),
|
|
3626
|
+
})),
|
|
3324
3627
|
});
|
|
3325
3628
|
}
|
|
3326
3629
|
|
|
@@ -3375,12 +3678,20 @@ test "ui app autofocus moves the keyboard to a freshly mounted editor through th
|
|
|
3375
3678
|
}
|
|
3376
3679
|
try std.testing.expectEqual(@as(canvas.ObjectId, 0), harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
3377
3680
|
|
|
3378
|
-
// The Cmd-N-shaped command mounts the editor
|
|
3379
|
-
//
|
|
3681
|
+
// The Cmd-N-shaped command mounts the editor BELOW the scroll
|
|
3682
|
+
// viewport; the rebuild's autofocus edge reveals it and moves
|
|
3683
|
+
// keyboard focus to it — no click.
|
|
3380
3684
|
try harness.runtime.dispatchPlatformEvent(app, .{ .menu_command = .{ .name = "note.new", .window_id = 1 } });
|
|
3381
3685
|
try std.testing.expect(app_state.model.editing);
|
|
3382
3686
|
const field_id = findWidgetIdByKind(app_state.tree.?.root, .text_field).?;
|
|
3687
|
+
const scroll_id = findWidgetIdByKind(app_state.tree.?.root, .scroll_view).?;
|
|
3383
3688
|
try std.testing.expectEqual(field_id, harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
3689
|
+
var retained = try harness.runtime.canvasWidgetLayout(1, autofocus_canvas_label);
|
|
3690
|
+
const scroll = retained.findById(scroll_id).?;
|
|
3691
|
+
const field = retained.findById(field_id).?;
|
|
3692
|
+
try std.testing.expect(scroll.widget.value > 0);
|
|
3693
|
+
try std.testing.expect(field.frame.y >= scroll.frame.y);
|
|
3694
|
+
try std.testing.expect(field.frame.maxY() <= scroll.frame.maxY());
|
|
3384
3695
|
|
|
3385
3696
|
// Typing lands in the model through the ordinary input path.
|
|
3386
3697
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
@@ -3392,10 +3703,18 @@ test "ui app autofocus moves the keyboard to a freshly mounted editor through th
|
|
|
3392
3703
|
try std.testing.expectEqualStrings("Groceries", app_state.model.draft.text());
|
|
3393
3704
|
try std.testing.expect(app_state.model.edit_count > 0);
|
|
3394
3705
|
|
|
3395
|
-
// A later rebuild with the flag still true never re-steals focus
|
|
3396
|
-
//
|
|
3706
|
+
// A later rebuild with the flag still true never re-steals focus.
|
|
3707
|
+
// Programmatically focusing the now-offscreen button first also proves
|
|
3708
|
+
// the shared automation focus verb reveals logical targets; its real
|
|
3709
|
+
// click then dispatches begin_edit and rebuilds.
|
|
3397
3710
|
const button_id = findWidgetIdByKind(app_state.tree.?.root, .button).?;
|
|
3398
3711
|
var command_buffer: [96]u8 = undefined;
|
|
3712
|
+
const focus_command = try std.fmt.bufPrint(&command_buffer, "widget-action {s} {d} focus", .{ autofocus_canvas_label, button_id });
|
|
3713
|
+
try harness.runtime.dispatchAutomationCommand(app, focus_command);
|
|
3714
|
+
try std.testing.expectEqual(button_id, harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
3715
|
+
retained = try harness.runtime.canvasWidgetLayout(1, autofocus_canvas_label);
|
|
3716
|
+
try std.testing.expectEqual(@as(f32, 0), retained.findById(scroll_id).?.widget.value);
|
|
3717
|
+
|
|
3399
3718
|
const click_command = try std.fmt.bufPrint(&command_buffer, "widget-click {s} {d}", .{ autofocus_canvas_label, button_id });
|
|
3400
3719
|
try harness.runtime.dispatchAutomationCommand(app, click_command);
|
|
3401
3720
|
try std.testing.expectEqual(button_id, harness.runtime.views[view_index].canvas_widget_focused_id);
|
|
@@ -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" {
|
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| {
|