@native-sdk/cli 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +91 -2
- package/build.zig +756 -5
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +19 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +416 -9
- package/packages/core/sdk/core.ts +706 -5
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +3187 -264
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +42 -4
- package/skill-data/ts-core/SKILL.md +13 -3
- package/src/app_runner/root.zig +112 -10
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/tests.zig +119 -1
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +639 -16
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +351 -7
- package/src/platform/macos/appkit_host.h +152 -8
- package/src/platform/macos/appkit_host.m +1816 -100
- package/src/platform/macos/cef_host.mm +372 -11
- package/src/platform/macos/root.zig +379 -11
- package/src/platform/null_platform.zig +696 -9
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +42 -0
- package/src/platform/types.zig +524 -18
- package/src/platform/windows/root.zig +432 -9
- package/src/platform/windows/webview2_host.cpp +482 -45
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +535 -12
- package/src/primitives/canvas/ui_markup.zig +253 -36
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
- package/src/primitives/canvas/ui_markup_contract.zig +89 -6
- package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +178 -9
- package/src/primitives/canvas/ui_markup_view.zig +220 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
- package/src/primitives/canvas/ui_schema.zig +110 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -10
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +23 -0
- package/src/runtime/api.zig +76 -5
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +8 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +240 -24
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +131 -13
- package/src/runtime/effects.zig +8136 -180
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +167 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +42 -4
- package/src/runtime/gpu_surface_events.zig +473 -13
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +36 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +432 -62
- package/src/runtime/session_record.zig +43 -2
- package/src/runtime/session_replay.zig +556 -20
- package/src/runtime/session_tests.zig +2087 -1
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +8 -0
- package/src/runtime/ts_core_host.zig +1320 -45
- package/src/runtime/ts_core_host_tests.zig +1100 -1
- package/src/runtime/ts_ui_app.zig +23 -5
- package/src/runtime/ui_app.zig +2444 -69
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +736 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +77 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +62 -1
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +244 -8
|
@@ -1040,6 +1040,415 @@ test "a composited cover media texture is byte-contained in the reference render
|
|
|
1040
1040
|
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 18, 12);
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
|
+
/// Render one contain-fit media surface headlessly and hand back the
|
|
1044
|
+
/// composited pixels: the widget's emitted display list (placeholder
|
|
1045
|
+
/// fill + black remainder bars + fitted quad) reference-rendered with
|
|
1046
|
+
/// the texture fed in as an ORDINARY resource under the media-derived
|
|
1047
|
+
/// id, defeating the presentation-only skip so the letterbox geometry
|
|
1048
|
+
/// itself is pixel-assertable. The texture is solid white at the
|
|
1049
|
+
/// STREAM's own aspect (a decoder pushes frames at stream geometry, so
|
|
1050
|
+
/// the draw's contain re-fit against the real texture is a no-op —
|
|
1051
|
+
/// exactly production); the pass clears to opaque blue so bars
|
|
1052
|
+
/// (black), picture (white), and page (blue) are three unmistakable
|
|
1053
|
+
/// bands.
|
|
1054
|
+
fn renderContainVideoSurface(
|
|
1055
|
+
frame: geometry.RectF,
|
|
1056
|
+
stream: ?geometry.SizeF,
|
|
1057
|
+
texture_width: usize,
|
|
1058
|
+
texture_height: usize,
|
|
1059
|
+
pixels: *[32 * 24 * 4]u8,
|
|
1060
|
+
) !ReferenceRenderSurface {
|
|
1061
|
+
const surface_id: u64 = 5;
|
|
1062
|
+
const widget = Widget{
|
|
1063
|
+
.id = 9,
|
|
1064
|
+
.kind = .media_surface,
|
|
1065
|
+
.frame = frame,
|
|
1066
|
+
.image_id = surface_id,
|
|
1067
|
+
.image_fit = .contain,
|
|
1068
|
+
.stream_size = stream,
|
|
1069
|
+
};
|
|
1070
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1071
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1072
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1073
|
+
var builder = Builder.init(&commands);
|
|
1074
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1075
|
+
|
|
1076
|
+
var texture_pixels: [4 * 2 * 4]u8 = undefined;
|
|
1077
|
+
@memset(&texture_pixels, 255);
|
|
1078
|
+
const images = [_]ReferenceImage{.{
|
|
1079
|
+
.id = canvas.mediaSurfaceTextureImageId(surface_id),
|
|
1080
|
+
.width = texture_width,
|
|
1081
|
+
.height = texture_height,
|
|
1082
|
+
.pixels = texture_pixels[0 .. texture_width * texture_height * 4],
|
|
1083
|
+
}};
|
|
1084
|
+
var render_commands: [8]RenderCommand = undefined;
|
|
1085
|
+
const plan = try builder.displayList().renderPlan(&render_commands);
|
|
1086
|
+
@memset(pixels, 0);
|
|
1087
|
+
const surface = (try ReferenceRenderSurface.init(32, 24, pixels)).withImages(&images);
|
|
1088
|
+
try surface.renderPass(.{
|
|
1089
|
+
.commands = plan.commands,
|
|
1090
|
+
.surface_size = geometry.SizeF.init(32, 24),
|
|
1091
|
+
.full_repaint = true,
|
|
1092
|
+
}, Color.rgb8(0, 0, 255));
|
|
1093
|
+
return surface;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
test "a contain video surface pillarboxes a narrow stream on black" {
|
|
1097
|
+
// A square (1:1) stream into a 2:1 box: the fitted quad is the
|
|
1098
|
+
// 16x16 center, with 8px black bars left and right.
|
|
1099
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1100
|
+
const widget = Widget{
|
|
1101
|
+
.id = 9,
|
|
1102
|
+
.kind = .media_surface,
|
|
1103
|
+
.frame = frame,
|
|
1104
|
+
.image_id = 5,
|
|
1105
|
+
.image_fit = .contain,
|
|
1106
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1107
|
+
};
|
|
1108
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1109
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1110
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1111
|
+
var builder = Builder.init(&commands);
|
|
1112
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1113
|
+
const display_list = builder.displayList();
|
|
1114
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1115
|
+
|
|
1116
|
+
// The letterbox field: black across the WHOLE frame at the frame's
|
|
1117
|
+
// radius — the silhouette is exact by construction.
|
|
1118
|
+
switch (display_list.commands[0]) {
|
|
1119
|
+
.fill_rounded_rect => |fill| {
|
|
1120
|
+
try expectRect(frame, fill.rect);
|
|
1121
|
+
try std.testing.expectEqual(Fill{ .color = Color.rgba8(0, 0, 0, 255) }, fill.fill);
|
|
1122
|
+
},
|
|
1123
|
+
else => return error.TestUnexpectedResult,
|
|
1124
|
+
}
|
|
1125
|
+
// The deterministic placeholder, confined to the quad: goldens and
|
|
1126
|
+
// replay screenshots (which skip the texture) show it exactly where
|
|
1127
|
+
// the picture goes, inside the black field.
|
|
1128
|
+
switch (display_list.commands[1]) {
|
|
1129
|
+
.fill_rounded_rect => |fill| {
|
|
1130
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), fill.rect);
|
|
1131
|
+
try std.testing.expectEqual(Fill{ .color = canvas.mediaSurfacePlaceholderColor(5) }, fill.fill);
|
|
1132
|
+
},
|
|
1133
|
+
else => return error.TestUnexpectedResult,
|
|
1134
|
+
}
|
|
1135
|
+
// The frame quad: aspect-fitted from the REPORTED dimensions and
|
|
1136
|
+
// centered — the engine computed it, no host fit math required.
|
|
1137
|
+
// `image_src` keeps its ordinary source-crop meaning (untouched
|
|
1138
|
+
// here, so null).
|
|
1139
|
+
switch (display_list.commands[2]) {
|
|
1140
|
+
.draw_image => |draw| {
|
|
1141
|
+
try std.testing.expectEqual(canvas.mediaSurfaceTextureImageId(5), draw.image_id);
|
|
1142
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), draw.dst);
|
|
1143
|
+
// The quad IS the fit: the draw stretches into it, so a
|
|
1144
|
+
// decoder whose true dimensions round off the report can
|
|
1145
|
+
// never open a host-side contain seam inside the quad.
|
|
1146
|
+
try std.testing.expectEqual(ImageFit.stretch, draw.fit);
|
|
1147
|
+
try std.testing.expectEqual(@as(?geometry.RectF, null), draw.src);
|
|
1148
|
+
},
|
|
1149
|
+
else => return error.TestUnexpectedResult,
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Pixel truth: black side regions, picture centered, page untouched.
|
|
1153
|
+
var pixels: [32 * 24 * 4]u8 = undefined;
|
|
1154
|
+
const surface = try renderContainVideoSurface(frame, .{ .width = 240, .height = 240 }, 2, 2, &pixels);
|
|
1155
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 12); // left bar
|
|
1156
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 28, 12); // right bar
|
|
1157
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 16, 12); // picture
|
|
1158
|
+
try support.expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 16, 1); // page above the frame
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
test "a contain video surface letterboxes a wide stream on black" {
|
|
1162
|
+
// A 2:1 stream into a 2:3 box: the fitted quad is the 16x8 center
|
|
1163
|
+
// band, with 8px black bars above and below.
|
|
1164
|
+
const frame = geometry.RectF.init(8, 0, 16, 24);
|
|
1165
|
+
const stream = geometry.SizeF{ .width = 480, .height = 240 };
|
|
1166
|
+
const widget = Widget{
|
|
1167
|
+
.id = 9,
|
|
1168
|
+
.kind = .media_surface,
|
|
1169
|
+
.frame = frame,
|
|
1170
|
+
.image_id = 5,
|
|
1171
|
+
.image_fit = .contain,
|
|
1172
|
+
.stream_size = stream,
|
|
1173
|
+
};
|
|
1174
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1175
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1176
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1177
|
+
var builder = Builder.init(&commands);
|
|
1178
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1179
|
+
const display_list = builder.displayList();
|
|
1180
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1181
|
+
// Black field over the frame, placeholder confined to the quad.
|
|
1182
|
+
switch (display_list.commands[0]) {
|
|
1183
|
+
.fill_rounded_rect => |fill| {
|
|
1184
|
+
try expectRect(frame, fill.rect);
|
|
1185
|
+
try std.testing.expectEqual(Fill{ .color = Color.rgba8(0, 0, 0, 255) }, fill.fill);
|
|
1186
|
+
},
|
|
1187
|
+
else => return error.TestUnexpectedResult,
|
|
1188
|
+
}
|
|
1189
|
+
switch (display_list.commands[1]) {
|
|
1190
|
+
.fill_rounded_rect => |fill| {
|
|
1191
|
+
try expectRect(geometry.RectF.init(8, 8, 16, 8), fill.rect);
|
|
1192
|
+
try std.testing.expectEqual(Fill{ .color = canvas.mediaSurfacePlaceholderColor(5) }, fill.fill);
|
|
1193
|
+
},
|
|
1194
|
+
else => return error.TestUnexpectedResult,
|
|
1195
|
+
}
|
|
1196
|
+
switch (display_list.commands[2]) {
|
|
1197
|
+
.draw_image => |draw| try expectRect(geometry.RectF.init(8, 8, 16, 8), draw.dst),
|
|
1198
|
+
else => return error.TestUnexpectedResult,
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
var pixels: [32 * 24 * 4]u8 = undefined;
|
|
1202
|
+
const surface = try renderContainVideoSurface(frame, stream, 4, 2, &pixels);
|
|
1203
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 16, 4); // top bar
|
|
1204
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 16, 20); // bottom bar
|
|
1205
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 16, 12); // picture
|
|
1206
|
+
try support.expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 4, 12); // page beside the frame
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
test "a contain video surface with matching aspect fills the frame barless" {
|
|
1210
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1211
|
+
const stream = geometry.SizeF{ .width = 640, .height = 320 };
|
|
1212
|
+
var pixels: [32 * 24 * 4]u8 = undefined;
|
|
1213
|
+
const surface = try renderContainVideoSurface(frame, stream, 4, 2, &pixels);
|
|
1214
|
+
// Every frame corner is picture — no bars on either axis.
|
|
1215
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 1, 5);
|
|
1216
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 30, 18);
|
|
1217
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 16, 12);
|
|
1218
|
+
|
|
1219
|
+
// No bar fills, and the full-frame quad keeps the frame's own
|
|
1220
|
+
// corner radius (an inset quad drops it — its corners sit in the
|
|
1221
|
+
// bars, not at the surface's silhouette).
|
|
1222
|
+
const widget = Widget{
|
|
1223
|
+
.id = 9,
|
|
1224
|
+
.kind = .media_surface,
|
|
1225
|
+
.frame = frame,
|
|
1226
|
+
.image_id = 5,
|
|
1227
|
+
.image_fit = .contain,
|
|
1228
|
+
.stream_size = stream,
|
|
1229
|
+
.style = .{ .radius = 6 },
|
|
1230
|
+
};
|
|
1231
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1232
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1233
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1234
|
+
var builder = Builder.init(&commands);
|
|
1235
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1236
|
+
const display_list = builder.displayList();
|
|
1237
|
+
try std.testing.expectEqual(@as(usize, 2), display_list.commandCount());
|
|
1238
|
+
switch (display_list.commands[1]) {
|
|
1239
|
+
.draw_image => |draw| {
|
|
1240
|
+
try expectRect(frame, draw.dst);
|
|
1241
|
+
try std.testing.expectEqual(@as(f32, 6), draw.radius.top_left);
|
|
1242
|
+
// Known geometry always stretches into the engine's quad —
|
|
1243
|
+
// the barless exact-aspect case seams just like the boxed
|
|
1244
|
+
// ones if a host re-fits the real texture.
|
|
1245
|
+
try std.testing.expectEqual(ImageFit.stretch, draw.fit);
|
|
1246
|
+
},
|
|
1247
|
+
else => return error.TestUnexpectedResult,
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
test "bars thinner than the corner radius shrink the quad's mask to the tangent radius" {
|
|
1252
|
+
// A 2.25:1 stream into a 2:1 box leaves ~0.89px letterbox bars —
|
|
1253
|
+
// thinner than the 6px corner radius. The quad's mask is the TIGHT
|
|
1254
|
+
// inset radius, max(0, 6 - bar) ~ 5.11: internally tangent to the
|
|
1255
|
+
// frame's corner circle, so the picture never paints outside the
|
|
1256
|
+
// rounded silhouette (a hairline bar cannot cover a 6px corner)
|
|
1257
|
+
// and never loses more corner than the silhouette demands.
|
|
1258
|
+
const frame = geometry.RectF.init(0, 0, 32, 16);
|
|
1259
|
+
const widget = Widget{
|
|
1260
|
+
.id = 9,
|
|
1261
|
+
.kind = .media_surface,
|
|
1262
|
+
.frame = frame,
|
|
1263
|
+
.image_id = 5,
|
|
1264
|
+
.image_fit = .contain,
|
|
1265
|
+
.stream_size = .{ .width = 36, .height = 16 },
|
|
1266
|
+
.style = .{ .radius = 6 },
|
|
1267
|
+
};
|
|
1268
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1269
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1270
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1271
|
+
var builder = Builder.init(&commands);
|
|
1272
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1273
|
+
const display_list = builder.displayList();
|
|
1274
|
+
// Black field + placeholder quad + the picture quad.
|
|
1275
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1276
|
+
const bar: f32 = (16.0 - 32.0 * 16.0 / 36.0) * 0.5;
|
|
1277
|
+
switch (display_list.commands[2]) {
|
|
1278
|
+
.draw_image => |draw| {
|
|
1279
|
+
try std.testing.expect(draw.dst.height < frame.height);
|
|
1280
|
+
try std.testing.expectApproxEqAbs(@as(f32, 6) - bar, draw.radius.top_left, 0.0001);
|
|
1281
|
+
try std.testing.expectApproxEqAbs(@as(f32, 6) - bar, draw.radius.bottom_right, 0.0001);
|
|
1282
|
+
},
|
|
1283
|
+
else => return error.TestUnexpectedResult,
|
|
1284
|
+
}
|
|
1285
|
+
// The placeholder stand-in carries the same tight mask.
|
|
1286
|
+
switch (display_list.commands[1]) {
|
|
1287
|
+
.fill_rounded_rect => |fill| try std.testing.expectApproxEqAbs(@as(f32, 6) - bar, fill.radius.top_left, 0.0001),
|
|
1288
|
+
else => return error.TestUnexpectedResult,
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
test "an unbounded style radius clamps to the frame before the tangent mask" {
|
|
1293
|
+
// Radius 100 on a 32x16 surface: renderers clamp every corner to
|
|
1294
|
+
// half the short side (8). The tangent math must start from that
|
|
1295
|
+
// effective value — from the raw 100, an 8px-bar quad would carry
|
|
1296
|
+
// mask radius 92, which renderers clamp to 8 on the 16x16 quad and
|
|
1297
|
+
// round the picture into a circle. Effective 8 minus the 8px bar
|
|
1298
|
+
// is 0: a square quad, exactly the silhouette's demand.
|
|
1299
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1300
|
+
const widget = Widget{
|
|
1301
|
+
.id = 9,
|
|
1302
|
+
.kind = .media_surface,
|
|
1303
|
+
.frame = frame,
|
|
1304
|
+
.image_id = 5,
|
|
1305
|
+
.image_fit = .contain,
|
|
1306
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1307
|
+
.style = .{ .radius = 100 },
|
|
1308
|
+
};
|
|
1309
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1310
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1311
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1312
|
+
var builder = Builder.init(&commands);
|
|
1313
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1314
|
+
const display_list = builder.displayList();
|
|
1315
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1316
|
+
switch (display_list.commands[0]) {
|
|
1317
|
+
.fill_rounded_rect => |fill| try std.testing.expectEqual(@as(f32, 8), fill.radius.top_left),
|
|
1318
|
+
else => return error.TestUnexpectedResult,
|
|
1319
|
+
}
|
|
1320
|
+
switch (display_list.commands[2]) {
|
|
1321
|
+
.draw_image => |draw| {
|
|
1322
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), draw.dst);
|
|
1323
|
+
try std.testing.expectEqual(@as(f32, 0), draw.radius.top_left);
|
|
1324
|
+
},
|
|
1325
|
+
else => return error.TestUnexpectedResult,
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
test "the fitted video draw composites the whole frame; image_src crops do not apply" {
|
|
1330
|
+
// `DrawImage.src` is adopted-TEXTURE pixel coordinates, and the
|
|
1331
|
+
// video texture's size is unknowable at emit time (macOS
|
|
1332
|
+
// budget-fits large decodes to a smaller texture), so a crop
|
|
1333
|
+
// declared against the stream cannot be translated — forwarding it
|
|
1334
|
+
// raw would sample the wrong region or nothing, and fitting the
|
|
1335
|
+
// quad to it would stretch whatever the host's clip leaves. The
|
|
1336
|
+
// fitted draw therefore always samples the whole texture at the
|
|
1337
|
+
// stream's aspect; crops remain a generic-producer facility in
|
|
1338
|
+
// texture coordinates (the non-fitted paths pass them through
|
|
1339
|
+
// unchanged, as ever).
|
|
1340
|
+
const frame = geometry.RectF.init(0, 0, 32, 16);
|
|
1341
|
+
const widget = Widget{
|
|
1342
|
+
.id = 9,
|
|
1343
|
+
.kind = .media_surface,
|
|
1344
|
+
.frame = frame,
|
|
1345
|
+
.image_id = 5,
|
|
1346
|
+
.image_fit = .contain,
|
|
1347
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1348
|
+
.image_src = geometry.RectF.init(100, 40, 240, 240),
|
|
1349
|
+
};
|
|
1350
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1351
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1352
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1353
|
+
var builder = Builder.init(&commands);
|
|
1354
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1355
|
+
const display_list = builder.displayList();
|
|
1356
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1357
|
+
switch (display_list.commands[2]) {
|
|
1358
|
+
.draw_image => |draw| {
|
|
1359
|
+
// Square stream into the 2:1 box: the quad is the stream's
|
|
1360
|
+
// 16x16 center, the sample is the whole texture.
|
|
1361
|
+
try expectRect(geometry.RectF.init(8, 0, 16, 16), draw.dst);
|
|
1362
|
+
try std.testing.expectEqual(@as(?geometry.RectF, null), draw.src);
|
|
1363
|
+
try std.testing.expectEqual(ImageFit.stretch, draw.fit);
|
|
1364
|
+
},
|
|
1365
|
+
else => return error.TestUnexpectedResult,
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
test "a rounded pillarboxed surface keeps its silhouette on the black field and unmasks the deep-set quad" {
|
|
1370
|
+
// Bars (8px) wider than the corner radius (6): the black field
|
|
1371
|
+
// carries the frame's rounding — the silhouette lives there, never
|
|
1372
|
+
// approximated per bar — and the quad's tight mask relaxes to
|
|
1373
|
+
// square (max(0, 6 - 8) = 0): its corners sit fully inside the
|
|
1374
|
+
// frame's straight edges, so no picture is notched.
|
|
1375
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1376
|
+
const widget = Widget{
|
|
1377
|
+
.id = 9,
|
|
1378
|
+
.kind = .media_surface,
|
|
1379
|
+
.frame = frame,
|
|
1380
|
+
.image_id = 5,
|
|
1381
|
+
.image_fit = .contain,
|
|
1382
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1383
|
+
.style = .{ .radius = 6 },
|
|
1384
|
+
};
|
|
1385
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1386
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1387
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1388
|
+
var builder = Builder.init(&commands);
|
|
1389
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1390
|
+
const display_list = builder.displayList();
|
|
1391
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1392
|
+
switch (display_list.commands[0]) {
|
|
1393
|
+
.fill_rounded_rect => |fill| {
|
|
1394
|
+
try expectRect(frame, fill.rect);
|
|
1395
|
+
try std.testing.expectEqual(Fill{ .color = Color.rgba8(0, 0, 0, 255) }, fill.fill);
|
|
1396
|
+
try std.testing.expectEqual(@as(f32, 6), fill.radius.top_left);
|
|
1397
|
+
},
|
|
1398
|
+
else => return error.TestUnexpectedResult,
|
|
1399
|
+
}
|
|
1400
|
+
switch (display_list.commands[1]) {
|
|
1401
|
+
.fill_rounded_rect => |fill| {
|
|
1402
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), fill.rect);
|
|
1403
|
+
try std.testing.expectEqual(@as(f32, 0), fill.radius.top_left);
|
|
1404
|
+
},
|
|
1405
|
+
else => return error.TestUnexpectedResult,
|
|
1406
|
+
}
|
|
1407
|
+
switch (display_list.commands[2]) {
|
|
1408
|
+
.draw_image => |draw| {
|
|
1409
|
+
try std.testing.expectEqual(@as(f32, 0), draw.radius.top_left);
|
|
1410
|
+
try std.testing.expectEqual(@as(f32, 0), draw.radius.bottom_right);
|
|
1411
|
+
},
|
|
1412
|
+
else => return error.TestUnexpectedResult,
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
test "a contain video surface with unknown stream geometry keeps the placeholder draw" {
|
|
1417
|
+
// Pre-LOADED: no reported dimensions, so no fit math runs (nothing
|
|
1418
|
+
// to divide by) — the id-derived placeholder fills the frame and
|
|
1419
|
+
// the texture draw keeps the full frame as its dst.
|
|
1420
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1421
|
+
const widget = Widget{
|
|
1422
|
+
.id = 9,
|
|
1423
|
+
.kind = .media_surface,
|
|
1424
|
+
.frame = frame,
|
|
1425
|
+
.image_id = 5,
|
|
1426
|
+
.image_fit = .contain,
|
|
1427
|
+
};
|
|
1428
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1429
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1430
|
+
var commands: [4]CanvasCommand = undefined;
|
|
1431
|
+
var builder = Builder.init(&commands);
|
|
1432
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1433
|
+
const display_list = builder.displayList();
|
|
1434
|
+
switch (display_list.commands[0]) {
|
|
1435
|
+
.fill_rounded_rect => |fill| {
|
|
1436
|
+
try std.testing.expectEqual(
|
|
1437
|
+
Fill{ .color = canvas.mediaSurfacePlaceholderColor(5) },
|
|
1438
|
+
fill.fill,
|
|
1439
|
+
);
|
|
1440
|
+
},
|
|
1441
|
+
else => return error.TestUnexpectedResult,
|
|
1442
|
+
}
|
|
1443
|
+
switch (display_list.commands[1]) {
|
|
1444
|
+
.draw_image => |draw| {
|
|
1445
|
+
try expectRect(frame, draw.dst);
|
|
1446
|
+
try std.testing.expectEqual(ImageFit.contain, draw.fit);
|
|
1447
|
+
},
|
|
1448
|
+
else => return error.TestUnexpectedResult,
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1043
1452
|
test "widget text fields expose textbox semantics and render focused chrome" {
|
|
1044
1453
|
const text_field = Widget{
|
|
1045
1454
|
.id = 8,
|
|
@@ -114,6 +114,23 @@ pub fn widgetVirtualRuntimeScrolled(widget: Widget) bool {
|
|
|
114
114
|
return widget.kind == .scroll_view and widget.layout.virtualized and widget.layout.virtual_item_count > 0;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/// Whether one widget scrolls on the named axis. This is THE axis
|
|
118
|
+
/// capability predicate: wheel/trackpad routing resolves each axis
|
|
119
|
+
/// against it independently, keyboard and semantic scroll intents pick
|
|
120
|
+
/// their axis through it, and the scrollbar/driver emit only the axes
|
|
121
|
+
/// it grants. Vertical: every scrollable kind (scroll views unless
|
|
122
|
+
/// declared `horizontal`, textareas, the virtualized containers).
|
|
123
|
+
/// Horizontal: only a non-virtualized `.scroll_view` declared
|
|
124
|
+
/// `horizontal` or `both` — virtualization is vertical machinery
|
|
125
|
+
/// (windowed ranges price rows, not columns), so a virtualized region
|
|
126
|
+
/// never grants the horizontal axis.
|
|
127
|
+
pub fn widgetScrollsAxis(widget: Widget, axis: token_model.ScrollAxis) bool {
|
|
128
|
+
return switch (axis) {
|
|
129
|
+
.vertical => widget.kind != .scroll_view or widget.scroll_axes.scrollsVertically() or widget.layout.virtualized,
|
|
130
|
+
.horizontal => widget.kind == .scroll_view and widget.scroll_axes.scrollsHorizontally() and !widget.layout.virtualized,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
117
134
|
/// The effective scroll physics for one scroll region: the shared
|
|
118
135
|
/// `ScrollPhysics` token with the region's `Widget.overscroll` override
|
|
119
136
|
/// resolved onto `physics.overscroll` (`.default` keeps the token's
|
|
@@ -5,6 +5,7 @@ const text_model = @import("text.zig");
|
|
|
5
5
|
const text_spans_model = @import("text_spans.zig");
|
|
6
6
|
const token_model = @import("tokens.zig");
|
|
7
7
|
const chart_model = @import("chart.zig");
|
|
8
|
+
const terminal_grid_model = @import("terminal_grid.zig");
|
|
8
9
|
|
|
9
10
|
const Error = canvas.Error;
|
|
10
11
|
const ObjectId = canvas.ObjectId;
|
|
@@ -20,6 +21,7 @@ const TextRange = text_model.TextRange;
|
|
|
20
21
|
const TextSelection = text_model.TextSelection;
|
|
21
22
|
const CanvasRenderAnimation = canvas.CanvasRenderAnimation;
|
|
22
23
|
const BlurTokenRef = token_model.BlurTokenRef;
|
|
24
|
+
const ScrollAxes = token_model.ScrollAxes;
|
|
23
25
|
const Easing = token_model.Easing;
|
|
24
26
|
const MotionDuration = token_model.MotionDuration;
|
|
25
27
|
const MotionTokens = token_model.MotionTokens;
|
|
@@ -148,6 +150,18 @@ pub const WidgetKind = enum {
|
|
|
148
150
|
/// `ReferenceImage.presentation_only`), so goldens and session
|
|
149
151
|
/// fingerprints never depend on producer output.
|
|
150
152
|
media_surface,
|
|
153
|
+
/// The terminal leaf: paints a RESOLVED emulator viewport (a
|
|
154
|
+
/// `terminal_grid.TerminalGrid` snapshot the widget's `terminal`
|
|
155
|
+
/// binding references) as real text runs and geometric box drawing,
|
|
156
|
+
/// clipped to its frame. A stateful focus target like the text
|
|
157
|
+
/// inputs — focused, it routes keys and committed text to the
|
|
158
|
+
/// framework-owned session behind its bound pty id and consumes
|
|
159
|
+
/// wheel scrollback — but never a text-input kind: the emulator,
|
|
160
|
+
/// not a TextBuffer, owns the editing model. Its semantics label
|
|
161
|
+
/// carries the viewport's plain text (a terminal's semantic content
|
|
162
|
+
/// IS its text), so assistive tech reads the real screen and the
|
|
163
|
+
/// session fingerprint covers cell state.
|
|
164
|
+
terminal,
|
|
151
165
|
};
|
|
152
166
|
|
|
153
167
|
/// STABLE code for a widget kind: assigned at birth, never reused or
|
|
@@ -226,6 +240,7 @@ pub fn widgetKindCode(kind: WidgetKind) u16 {
|
|
|
226
240
|
.tree => 59,
|
|
227
241
|
.input_group => 60,
|
|
228
242
|
.media_surface => 61,
|
|
243
|
+
.terminal => 62,
|
|
229
244
|
};
|
|
230
245
|
}
|
|
231
246
|
|
|
@@ -249,6 +264,12 @@ pub const WidgetState = struct {
|
|
|
249
264
|
};
|
|
250
265
|
|
|
251
266
|
pub const WidgetRenderState = struct {
|
|
267
|
+
/// Whether the app is active and this widget tree's window is key.
|
|
268
|
+
/// Runtime focus ids stay retained while false so focus-visible
|
|
269
|
+
/// chrome and per-window restoration keep their existing semantics;
|
|
270
|
+
/// controls whose pixels represent CURRENT keyboard ownership (the
|
|
271
|
+
/// terminal cursor) consult this gate too.
|
|
272
|
+
keyboard_active: bool = true,
|
|
252
273
|
focused_id: ?ObjectId = null,
|
|
253
274
|
focus_visible_id: ?ObjectId = null,
|
|
254
275
|
hovered_id: ?ObjectId = null,
|
|
@@ -323,6 +344,16 @@ pub const WidgetAnchor = struct {
|
|
|
323
344
|
alignment: WidgetAnchorAlignment = .start,
|
|
324
345
|
/// Gap in points between the anchor edge and the surface.
|
|
325
346
|
offset: f32 = 4,
|
|
347
|
+
/// Point-anchor mode: when set, the surface anchors at this explicit
|
|
348
|
+
/// point in the window's coordinate space instead of the parent
|
|
349
|
+
/// widget's frame (the context-menu-at-the-pointer shape). The point
|
|
350
|
+
/// acts as a zero-size anchor rect, so the standard popup edge rules
|
|
351
|
+
/// apply unchanged: `placement` prefers a side of the point, the
|
|
352
|
+
/// surface flips to the other side when it would cross the window
|
|
353
|
+
/// edge and the other side has more room, and both axes clamp into
|
|
354
|
+
/// the window. `stretch` alignment has no width to inherit from a
|
|
355
|
+
/// point and behaves like `start`.
|
|
356
|
+
point: ?geometry.PointF = null,
|
|
326
357
|
};
|
|
327
358
|
|
|
328
359
|
pub const WidgetLayoutStyle = struct {
|
|
@@ -381,6 +412,17 @@ pub const WidgetLayoutStyle = struct {
|
|
|
381
412
|
/// into both `min_size` and `max_size`, so intrinsic content can
|
|
382
413
|
/// neither shrink nor silently grow the box past it.
|
|
383
414
|
max_size: geometry.SizeF = .{},
|
|
415
|
+
/// The media sizing contract for a COMPOSED container: report no
|
|
416
|
+
/// intrinsic size, exactly like the media-surface leaf it wraps
|
|
417
|
+
/// (definite width/height or flex grow size it; a hug container
|
|
418
|
+
/// gives it nothing). Chrome composed beside a zero-intrinsic
|
|
419
|
+
/// surface — a transport bar — must not leak its own intrinsic
|
|
420
|
+
/// size into the element, or an unsized element would render as a
|
|
421
|
+
/// chrome-only strip. Declared sizes stay definite (they ride the
|
|
422
|
+
/// frame and the min/max bounds, never the intrinsic measure);
|
|
423
|
+
/// pair with `clip_content` so chrome cannot paint past a box the
|
|
424
|
+
/// layout granted nothing.
|
|
425
|
+
zero_intrinsic: bool = false,
|
|
384
426
|
};
|
|
385
427
|
|
|
386
428
|
pub const WidgetStyle = struct {
|
|
@@ -718,6 +760,49 @@ pub const WidgetOverscroll = enum {
|
|
|
718
760
|
rubber_band,
|
|
719
761
|
};
|
|
720
762
|
|
|
763
|
+
/// The `.terminal` widget's binding: `pty` is the MODEL-OWNED pty
|
|
764
|
+
/// effect key the element binds (the id `fx.ptySpawn` named — ids are
|
|
765
|
+
/// model data, never markup literals; 0 is the unbound sentinel and the
|
|
766
|
+
/// surface paints its background only). `scrollback` is the declared
|
|
767
|
+
/// scrollback offset in rows, following the scroll `value` source-wins
|
|
768
|
+
/// reconcile rule: echo the `on-terminal` state's `scrollback` back
|
|
769
|
+
/// here and the runtime-owned position survives rebuilds; change it
|
|
770
|
+
/// model-side to scroll programmatically. `grid` is the RESOLVED
|
|
771
|
+
/// viewport snapshot the producer published for the key.
|
|
772
|
+
///
|
|
773
|
+
/// LIFETIME: `grid` is a BORROWED pointer, not copied into a retained
|
|
774
|
+
/// tree the way `text`/`spans` are — so the producer must own it for at
|
|
775
|
+
/// least as long as any retained tree built from this widget, since a
|
|
776
|
+
/// focus/hover repaint re-emits from the retained tree without a
|
|
777
|
+
/// rebuild. The sanctioned producer is the framework's terminal-session
|
|
778
|
+
/// store (installed via `Ui.TerminalGridLookup`), whose grids live in
|
|
779
|
+
/// stable per-session storage across frames and are freed only when the
|
|
780
|
+
/// session ends and the widget unmounts — so the runtime flow satisfies
|
|
781
|
+
/// the contract by construction. It is `null` whenever no lookup is
|
|
782
|
+
/// installed (every app- or test-built tree today), which paints the
|
|
783
|
+
/// honest empty surface; a direct builder caller that sets it must honor
|
|
784
|
+
/// the same outlive-the-retained-tree contract, exactly as it must for a
|
|
785
|
+
/// borrowed `text` slice.
|
|
786
|
+
pub const TerminalBinding = struct {
|
|
787
|
+
pty: u64 = 0,
|
|
788
|
+
scrollback: u32 = 0,
|
|
789
|
+
grid: ?*const terminal_grid_model.TerminalGrid = null,
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
/// A house video-transport chrome role for a control the RUNTIME
|
|
793
|
+
/// consumes: `Ui.video` stamps it on the chrome it composes (`.toggle`
|
|
794
|
+
/// on the play/pause button, `.scrub` on the seek slider), and the app
|
|
795
|
+
/// loop drives the single video playback channel from presses/changes
|
|
796
|
+
/// on these widgets instead of resolving an app Msg — declarative
|
|
797
|
+
/// playback needs no model plumbing to keep its transport honest.
|
|
798
|
+
/// `.none` everywhere else, including every app-authored widget:
|
|
799
|
+
/// builder-internal, never an `ElementOptions` channel.
|
|
800
|
+
pub const VideoControlVerb = enum(u8) {
|
|
801
|
+
none,
|
|
802
|
+
toggle,
|
|
803
|
+
scrub,
|
|
804
|
+
};
|
|
805
|
+
|
|
721
806
|
/// Where a control sits inside a FLUSH button group (`button_group`
|
|
722
807
|
/// with gap 0), stamped onto the render-time widget copy by BOTH render
|
|
723
808
|
/// walks — never authored, never serialized, never retained. The stamp
|
|
@@ -801,9 +886,33 @@ pub const Widget = struct {
|
|
|
801
886
|
image_fit: ImageFit = .stretch,
|
|
802
887
|
image_sampling: ImageSampling = .linear,
|
|
803
888
|
image_opacity: f32 = 1,
|
|
889
|
+
/// The video stream's REPORTED dimensions for a contain-fitted
|
|
890
|
+
/// media surface (`Ui.stampVideoSurfaceFit` writes it from the
|
|
891
|
+
/// LOADED event's journaled report; null until then): the emit
|
|
892
|
+
/// computes the letterboxed frame quad from this, never from
|
|
893
|
+
/// `image_src` — which keeps its ordinary source-crop meaning on
|
|
894
|
+
/// every widget. Engine-internal: no builder option, no markup
|
|
895
|
+
/// attribute.
|
|
896
|
+
stream_size: ?geometry.SizeF = null,
|
|
804
897
|
text_selection: ?TextSelection = null,
|
|
805
898
|
text_composition: ?TextRange = null,
|
|
806
899
|
value: f32 = 0,
|
|
900
|
+
/// The HORIZONTAL scroll offset of a horizontal-capable
|
|
901
|
+
/// `.scroll_view` (`value_x:` in the builder, `value-x=` in markup)
|
|
902
|
+
/// — the horizontal counterpart of the retained offset that rides
|
|
903
|
+
/// `value`. Follows the same source-wins reconcile rule: the
|
|
904
|
+
/// runtime-owned offset (user scrolling) survives rebuilds while
|
|
905
|
+
/// the source offset is unchanged; a source-side change
|
|
906
|
+
/// (programmatic scroll) wins. Meaningless on every other kind.
|
|
907
|
+
value_x: f32 = 0,
|
|
908
|
+
/// Which axes a `.scroll_view` scrolls (`axis:` in the builder,
|
|
909
|
+
/// `axis=` in markup). Vertical — the pre-axis behavior — is the
|
|
910
|
+
/// default; `horizontal` and `both` opt the region into wheel
|
|
911
|
+
/// `delta_x`, the horizontal scrollbar, and the horizontal keymap.
|
|
912
|
+
/// Virtualized regions ignore the horizontal grant (windowed
|
|
913
|
+
/// virtualization prices rows, not columns). Meaningless on every
|
|
914
|
+
/// other kind.
|
|
915
|
+
scroll_axes: ScrollAxes = .vertical,
|
|
807
916
|
layer: ?i32 = null,
|
|
808
917
|
/// Modal surfaces (dialog/drawer/sheet) paint a token-driven scrim
|
|
809
918
|
/// (dim + backdrop blur) across the whole tree behind them. False
|
|
@@ -879,12 +988,35 @@ pub const Widget = struct {
|
|
|
879
988
|
/// widget a hit target; platforms without a window-drag channel
|
|
880
989
|
/// treat the press as dead space.
|
|
881
990
|
window_drag: bool = false,
|
|
991
|
+
/// The widget listens for hover-enter/hover-leave Msgs
|
|
992
|
+
/// (`ElementOptions.on_hover_enter` / `on_hover_leave`; markup
|
|
993
|
+
/// `on-hover-enter` / `on-hover-leave`): the builder stamps this
|
|
994
|
+
/// from the bound handlers, and the runtime tracks the pointer's
|
|
995
|
+
/// containment against it — enter when the pointer enters the
|
|
996
|
+
/// widget's hit region, leave when it exits. Like the chart's
|
|
997
|
+
/// `hover_details`, the flag makes the widget hit-testable WITHOUT
|
|
998
|
+
/// claiming presses (clicks keep falling through to the nearest
|
|
999
|
+
/// claiming ancestor) and without any hover wash of its own — the
|
|
1000
|
+
/// wash stays a per-kind visual channel, so binding hover on a
|
|
1001
|
+
/// quiet content tile never lights it up.
|
|
1002
|
+
hover_msgs: bool = false,
|
|
882
1003
|
/// Plot data for `.chart` widgets: model-derived series (values,
|
|
883
1004
|
/// token colors, kind) plus domain/grid options. The retained tree
|
|
884
1005
|
/// copies series and points into per-view storage like text/spans,
|
|
885
1006
|
/// bounded by `canvas_limits.max_canvas_widget_chart_*` budgets.
|
|
886
1007
|
/// `Ui.chart` downsamples long series before they land here.
|
|
887
1008
|
chart: chart_model.ChartData = .{},
|
|
1009
|
+
/// The `.terminal` widget's binding (see `TerminalBinding`): the
|
|
1010
|
+
/// model-owned pty effect key the element binds, the declared
|
|
1011
|
+
/// scrollback echo, and the resolved grid snapshot published for
|
|
1012
|
+
/// that key. Default (unbound) on every other kind.
|
|
1013
|
+
terminal: TerminalBinding = .{},
|
|
1014
|
+
/// House video-transport role (see `VideoControlVerb`): `Ui.video`
|
|
1015
|
+
/// stamps `.toggle`/`.scrub` on the chrome controls it composes, and
|
|
1016
|
+
/// the app loop consumes presses/changes on them by driving the
|
|
1017
|
+
/// video playback channel — never by resolving an app Msg. `.none`
|
|
1018
|
+
/// on every app-authored widget.
|
|
1019
|
+
video_control: VideoControlVerb = .none,
|
|
888
1020
|
/// Render-walk stamp for flush button-group segments (see
|
|
889
1021
|
/// `WidgetGroupSegment`). Derived at emit time from the widget's
|
|
890
1022
|
/// position among its group's visible children; `.none` everywhere
|