@native-sdk/cli 0.5.4 → 0.6.1
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 +50 -1
- package/build.zig +588 -32
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +3 -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 +280 -8
- package/packages/core/sdk/core.ts +481 -2
- 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 +599 -3
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +39 -2
- package/skill-data/ts-core/SKILL.md +4 -2
- package/src/app_runner/root.zig +32 -10
- 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/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +527 -13
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +280 -7
- package/src/platform/macos/appkit_host.h +104 -6
- package/src/platform/macos/appkit_host.m +1368 -74
- package/src/platform/macos/cef_host.mm +110 -1
- package/src/platform/macos/root.zig +287 -7
- package/src/platform/null_platform.zig +398 -4
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +386 -14
- package/src/platform/windows/root.zig +298 -9
- package/src/platform/windows/webview2_host.cpp +330 -5
- 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 +1 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +524 -5
- package/src/primitives/canvas/ui_markup.zig +195 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
- package/src/primitives/canvas/ui_markup_contract.zig +88 -5
- package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
- 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 +149 -0
- package/src/primitives/canvas/ui_markup_view.zig +191 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
- package/src/primitives/canvas/ui_schema.zig +97 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -11
- 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 +16 -0
- package/src/runtime/api.zig +76 -6
- 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 +1 -0
- 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_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 +268 -26
- 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 +73 -2
- package/src/runtime/effects.zig +6389 -54
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +14 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +25 -4
- package/src/runtime/gpu_surface_events.zig +475 -15
- 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 +25 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_journal.zig +367 -61
- package/src/runtime/session_record.zig +16 -0
- package/src/runtime/session_replay.zig +395 -11
- package/src/runtime/session_tests.zig +114 -19
- 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/tests.zig +6 -0
- package/src/runtime/ts_core_host.zig +980 -140
- package/src/runtime/ts_core_host_tests.zig +1059 -1
- package/src/runtime/ts_ui_app.zig +16 -5
- package/src/runtime/ui_app.zig +2338 -67
- 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 +268 -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_storage.zig +45 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +1 -0
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/templates.zig +25 -7
|
@@ -21,14 +21,15 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
21
21
|
// (append or slot them anywhere — order carries no meaning) and pin
|
|
22
22
|
// the new fingerprint ONLY for additions; renames/renumbers are
|
|
23
23
|
// schema-version-bump events, not silent edits.
|
|
24
|
-
try testing.expectEqual(@as(usize,
|
|
25
|
-
try testing.expectEqual(@as(usize,
|
|
26
|
-
try testing.expectEqual(@as(usize,
|
|
24
|
+
try testing.expectEqual(@as(usize, 69), schema.elements.len);
|
|
25
|
+
try testing.expectEqual(@as(usize, 89), schema.attrs.len);
|
|
26
|
+
try testing.expectEqual(@as(usize, 13), schema.events.len);
|
|
27
27
|
// The element table runs through the span composite (64), the
|
|
28
|
-
// bubble-reactions composite (65), the media surface (66),
|
|
29
|
-
// runtime-image leaf (67)
|
|
28
|
+
// bubble-reactions composite (65), the media surface (66), the
|
|
29
|
+
// runtime-image leaf (67), the video playback composite (68), and
|
|
30
|
+
// the terminal leaf (69).
|
|
30
31
|
try testing.expectEqual(
|
|
31
|
-
@as(u64,
|
|
32
|
+
@as(u64, 0x439b5e520bedc352),
|
|
32
33
|
tableFingerprint(schema.ElementInfo, &schema.elements),
|
|
33
34
|
);
|
|
34
35
|
// The attr table runs through the split layout-tween attributes
|
|
@@ -37,14 +38,20 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
37
38
|
// the later span additions scale (76) and underline (77), the
|
|
38
39
|
// split enter-from attribute resize-origin (78), the quiet-surface
|
|
39
40
|
// hover knob quiet-hover (79), the anchored-tooltip hover-intent
|
|
40
|
-
// delay tooltip-delay (80),
|
|
41
|
-
//
|
|
41
|
+
// delay tooltip-delay (80), the media-surface producer rendezvous
|
|
42
|
+
// surface (81), the video element attributes controls (82),
|
|
43
|
+
// autoplay (83), loop (84), and muted (85), the scroll-axis
|
|
44
|
+
// attributes axis (86) and value-x (87), and the terminal
|
|
45
|
+
// attributes pty (88) and scrollback (89).
|
|
42
46
|
try testing.expectEqual(
|
|
43
|
-
@as(u64,
|
|
47
|
+
@as(u64, 0x60e430e0cf2cc4f9),
|
|
44
48
|
tableFingerprint(schema.AttrInfo, &schema.attrs),
|
|
45
49
|
);
|
|
50
|
+
// The event table runs through the pointer-hover containment pair
|
|
51
|
+
// hover-enter (11) and hover-leave (12) and the terminal view-state
|
|
52
|
+
// echo terminal (13).
|
|
46
53
|
try testing.expectEqual(
|
|
47
|
-
@as(u64,
|
|
54
|
+
@as(u64, 0x62d715c2db7951d6),
|
|
48
55
|
tableFingerprint(schema.EventInfo, &schema.events),
|
|
49
56
|
);
|
|
50
57
|
}
|
|
@@ -91,7 +98,7 @@ test "registry event scoping names registry elements" {
|
|
|
91
98
|
test "derived name lists mirror the registry" {
|
|
92
99
|
// The derivations are the vocabulary every consumer reads; hold them
|
|
93
100
|
// to the registry's own predicates.
|
|
94
|
-
try testing.expectEqual(@as(usize,
|
|
101
|
+
try testing.expectEqual(@as(usize, 56), schema.element_names.len);
|
|
95
102
|
for (schema.element_names) |name| {
|
|
96
103
|
try testing.expect(schema.elementByName(name).?.rule_hook == null);
|
|
97
104
|
}
|
|
@@ -476,12 +476,12 @@ test "payload-carrying handlers build messages from edits and values" {
|
|
|
476
476
|
};
|
|
477
477
|
const feed = findByKind(scroll_tree.root, .scroll_view).?;
|
|
478
478
|
const scrolled = scroll_tree.msgForScroll(feed.id, .{
|
|
479
|
-
.
|
|
480
|
-
.
|
|
481
|
-
.
|
|
479
|
+
.offset_y = 64,
|
|
480
|
+
.viewport_extent_y = 72,
|
|
481
|
+
.content_extent_y = 200,
|
|
482
482
|
}).?.feed_scrolled;
|
|
483
|
-
try testing.expectEqual(@as(f32, 64), scrolled.
|
|
484
|
-
try testing.expectEqual(@as(f32, 128), scrolled.maxOffset());
|
|
483
|
+
try testing.expectEqual(@as(f32, 64), scrolled.offset_y);
|
|
484
|
+
try testing.expectEqual(@as(f32, 128), scrolled.axis(.vertical).maxOffset());
|
|
485
485
|
try testing.expectEqual(@as(?Msg, null), tree.msgForScroll(slider.id, .{}));
|
|
486
486
|
|
|
487
487
|
// Widgets without payload handlers dispatch nothing for edits.
|
|
@@ -1184,6 +1184,139 @@ test "a bound press handler makes layout containers hit targets" {
|
|
|
1184
1184
|
try testing.expectEqual(@as(u32, 7), tree.msgForPointer(row.id, .up).?.toggle);
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
+
test "Ui.video records the declaration last-wins, formats times, and disables chrome when inactive" {
|
|
1188
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1189
|
+
defer arena_state.deinit();
|
|
1190
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
1191
|
+
|
|
1192
|
+
// Inactive channel (the default outside an app loop): the chrome
|
|
1193
|
+
// renders disabled at the play glyph with zeroed readouts.
|
|
1194
|
+
const idle = ui.video(.{ .src = "assets/clips/one.mp4", .controls = true, .width = 320, .height = 180 });
|
|
1195
|
+
const idle_surface = idle.nodes[0];
|
|
1196
|
+
try testing.expectEqual(canvas.WidgetKind.media_surface, idle_surface.widget.kind);
|
|
1197
|
+
try testing.expectEqual(canvas.video_playback_surface_id, idle_surface.widget.image_id);
|
|
1198
|
+
const idle_row = idle.nodes[1];
|
|
1199
|
+
const idle_button = idle_row.nodes[0];
|
|
1200
|
+
try testing.expectEqual(canvas.VideoControlVerb.toggle, idle_button.widget.video_control);
|
|
1201
|
+
try testing.expect(idle_button.widget.state.disabled);
|
|
1202
|
+
try testing.expectEqualStrings("play", idle_button.widget.icon);
|
|
1203
|
+
try testing.expectEqualStrings("0:00", idle_row.nodes[1].widget.text);
|
|
1204
|
+
const idle_slider = idle_row.nodes[2];
|
|
1205
|
+
try testing.expectEqual(canvas.VideoControlVerb.scrub, idle_slider.widget.video_control);
|
|
1206
|
+
try testing.expect(idle_slider.widget.state.disabled);
|
|
1207
|
+
try testing.expectEqual(@as(f32, 0), idle_slider.widget.value);
|
|
1208
|
+
try testing.expectEqualStrings("0:00", idle_row.nodes[3].widget.text);
|
|
1209
|
+
try testing.expectEqualStrings("assets/clips/one.mp4", ui.video_declaration.?.src);
|
|
1210
|
+
|
|
1211
|
+
// A live stamped snapshot: the pause glyph, h:mm:ss past the hour,
|
|
1212
|
+
// and the seek fraction from position over duration.
|
|
1213
|
+
ui.video_state = .{ .active = true, .playing = true, .position_ms = 3_725_000, .duration_ms = 7_200_000 };
|
|
1214
|
+
const live = ui.video(.{ .src = "assets/clips/two.mp4", .controls = true, .loop = true });
|
|
1215
|
+
const live_row = live.nodes[1];
|
|
1216
|
+
const live_button = live_row.nodes[0];
|
|
1217
|
+
try testing.expect(!live_button.widget.state.disabled);
|
|
1218
|
+
try testing.expectEqualStrings("pause", live_button.widget.icon);
|
|
1219
|
+
try testing.expectEqualStrings("1:02:05", live_row.nodes[1].widget.text);
|
|
1220
|
+
try testing.expectApproxEqAbs(@as(f32, 3_725_000.0 / 7_200_000.0), live_row.nodes[2].widget.value, 0.0001);
|
|
1221
|
+
try testing.expect(!live_row.nodes[2].widget.state.disabled);
|
|
1222
|
+
try testing.expectEqualStrings("2:00:00", live_row.nodes[3].widget.text);
|
|
1223
|
+
|
|
1224
|
+
// The last declaration wins (loadVideo's replace semantics: one
|
|
1225
|
+
// player is the whole surface).
|
|
1226
|
+
try testing.expectEqualStrings("assets/clips/two.mp4", ui.video_declaration.?.src);
|
|
1227
|
+
try testing.expect(ui.video_declaration.?.loop);
|
|
1228
|
+
|
|
1229
|
+
// A src-less video records nothing: it is surface-only chrome over
|
|
1230
|
+
// whatever playback the app loaded itself.
|
|
1231
|
+
var chrome_ui = InboxUi.init(arena_state.allocator());
|
|
1232
|
+
_ = chrome_ui.video(.{ .controls = true });
|
|
1233
|
+
try testing.expect(chrome_ui.video_declaration == null);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
test "Ui stamps contain fit and stream geometry on video-fed media surfaces" {
|
|
1237
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1238
|
+
defer arena_state.deinit();
|
|
1239
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
1240
|
+
|
|
1241
|
+
// The framework `<video>` surface is ALWAYS contain — pre-LOADED it
|
|
1242
|
+
// simply carries no stream geometry yet (no fit math to run).
|
|
1243
|
+
const idle = ui.video(.{ .src = "assets/clips/one.mp4", .controls = true });
|
|
1244
|
+
try testing.expectEqual(canvas.ImageFit.contain, idle.nodes[0].widget.image_fit);
|
|
1245
|
+
try testing.expectEqual(@as(?geometry.SizeF, null), idle.nodes[0].widget.stream_size);
|
|
1246
|
+
|
|
1247
|
+
// The LOADED report stamps the fitted-draw geometry on the surface
|
|
1248
|
+
// the active playback FEEDS — here an app-claimed custom surface.
|
|
1249
|
+
ui.video_state = .{ .active = true, .playing = true, .surface = 0x7601, .width = 427, .height = 240 };
|
|
1250
|
+
const custom = ui.mediaSurface(.{ .image = 0x7601, .grow = 1 });
|
|
1251
|
+
try testing.expectEqual(canvas.ImageFit.contain, custom.widget.image_fit);
|
|
1252
|
+
try testing.expectEqual(
|
|
1253
|
+
@as(?geometry.SizeF, geometry.SizeF.init(427, 240)),
|
|
1254
|
+
custom.widget.stream_size,
|
|
1255
|
+
);
|
|
1256
|
+
|
|
1257
|
+
// A source-less `<video>` shown WHILE that custom playback runs
|
|
1258
|
+
// must not borrow the unrelated stream's geometry: contain (it is
|
|
1259
|
+
// the video surface by convention), but no dimensions — the
|
|
1260
|
+
// placeholder fills the frame.
|
|
1261
|
+
const bystander = ui.video(.{ .controls = true });
|
|
1262
|
+
try testing.expectEqual(canvas.ImageFit.contain, bystander.nodes[0].widget.image_fit);
|
|
1263
|
+
try testing.expectEqual(@as(?geometry.SizeF, null), bystander.nodes[0].widget.stream_size);
|
|
1264
|
+
|
|
1265
|
+
// A producer surface the video channel does NOT feed keeps its own
|
|
1266
|
+
// geometry: no stamp, the default stretch, `image_src` untouched.
|
|
1267
|
+
const camera = ui.mediaSurface(.{ .image = 0x9902, .grow = 1 });
|
|
1268
|
+
try testing.expectEqual(canvas.ImageFit.stretch, camera.widget.image_fit);
|
|
1269
|
+
try testing.expectEqual(@as(?geometry.SizeF, null), camera.widget.stream_size);
|
|
1270
|
+
|
|
1271
|
+
// The declarative playback feeding the framework surface stamps
|
|
1272
|
+
// dimensions on the `<video>` element itself.
|
|
1273
|
+
ui.video_state = .{ .active = true, .playing = true, .surface = canvas.video_playback_surface_id, .width = 1280, .height = 720 };
|
|
1274
|
+
const house = ui.video(.{ .src = "assets/clips/one.mp4", .controls = true });
|
|
1275
|
+
try testing.expectEqual(
|
|
1276
|
+
@as(?geometry.SizeF, geometry.SizeF.init(1280, 720)),
|
|
1277
|
+
house.nodes[0].widget.stream_size,
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
test "Ui.video with controls keeps the media surface's zero-intrinsic contract" {
|
|
1282
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1283
|
+
defer arena_state.deinit();
|
|
1284
|
+
|
|
1285
|
+
// A hug-sized container and no declared width/height/grow: the
|
|
1286
|
+
// element measures zero exactly like the bare surface — the
|
|
1287
|
+
// transport bar must not size it into a controls-only strip.
|
|
1288
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
1289
|
+
const tree = try ui.finalize(ui.column(.{ .cross = .start }, .{
|
|
1290
|
+
ui.video(.{ .src = "assets/clips/one.mp4", .controls = true }),
|
|
1291
|
+
}));
|
|
1292
|
+
const element = tree.root.children[0];
|
|
1293
|
+
try testing.expect(element.layout.zero_intrinsic);
|
|
1294
|
+
try testing.expect(element.layout.clip_content);
|
|
1295
|
+
var layout_nodes: [32]canvas.WidgetLayoutNode = undefined;
|
|
1296
|
+
const layout = try canvas.layoutWidgetTree(tree.root, geometry.RectF.init(0, 0, 400, 300), &layout_nodes);
|
|
1297
|
+
const frame = layout.findById(element.id).?.frame;
|
|
1298
|
+
try testing.expectEqual(@as(f32, 0), frame.width);
|
|
1299
|
+
try testing.expectEqual(@as(f32, 0), frame.height);
|
|
1300
|
+
|
|
1301
|
+
// Declared sizes stay definite: the same element sized 320x180
|
|
1302
|
+
// carries the surface above the transport bar, which keeps its
|
|
1303
|
+
// intrinsic height inside the declared box.
|
|
1304
|
+
var sized_ui = InboxUi.init(arena_state.allocator());
|
|
1305
|
+
const sized_tree = try sized_ui.finalize(sized_ui.column(.{ .cross = .start }, .{
|
|
1306
|
+
sized_ui.video(.{ .src = "assets/clips/one.mp4", .controls = true, .width = 320, .height = 180 }),
|
|
1307
|
+
}));
|
|
1308
|
+
const sized_element = sized_tree.root.children[0];
|
|
1309
|
+
var sized_nodes: [32]canvas.WidgetLayoutNode = undefined;
|
|
1310
|
+
const sized_layout = try canvas.layoutWidgetTree(sized_tree.root, geometry.RectF.init(0, 0, 400, 300), &sized_nodes);
|
|
1311
|
+
const sized_frame = sized_layout.findById(sized_element.id).?.frame;
|
|
1312
|
+
try testing.expectEqual(@as(f32, 320), sized_frame.width);
|
|
1313
|
+
try testing.expectEqual(@as(f32, 180), sized_frame.height);
|
|
1314
|
+
const surface_frame = sized_layout.findById(sized_element.children[0].id).?.frame;
|
|
1315
|
+
const bar_frame = sized_layout.findById(sized_element.children[1].id).?.frame;
|
|
1316
|
+
try testing.expect(bar_frame.height > 0);
|
|
1317
|
+
try testing.expectApproxEqAbs(@as(f32, 180), surface_frame.height + bar_frame.height, 0.5);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1187
1320
|
test "chart builder copies, downsamples, and summarizes series" {
|
|
1188
1321
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1189
1322
|
defer arena_state.deinit();
|
|
@@ -1308,8 +1441,8 @@ test "virtualWindow resolves the runtime state and virtualList builds only the w
|
|
|
1308
1441
|
|
|
1309
1442
|
// Typed dispatch: the scroll observation and the approach-end signal
|
|
1310
1443
|
// both resolve through the container's handlers.
|
|
1311
|
-
const state = canvas.ScrollState{ .
|
|
1312
|
-
try testing.expectEqual(@as(f32, 25_000), tree.msgForScroll(tree.root.id, state).?.feed_scrolled.
|
|
1444
|
+
const state = canvas.ScrollState{ .offset_y = 25_000, .viewport_extent_y = 90, .content_extent_y = 2_499_975 };
|
|
1445
|
+
try testing.expectEqual(@as(f32, 25_000), tree.msgForScroll(tree.root.id, state).?.feed_scrolled.offset_y);
|
|
1313
1446
|
try testing.expectEqual(Msg.load_more, tree.msgForReachEnd(tree.root.id).?);
|
|
1314
1447
|
}
|
|
1315
1448
|
|
|
@@ -1360,7 +1493,6 @@ test "virtualWindow without a source falls back to the request viewport" {
|
|
|
1360
1493
|
try testing.expect(ui.virtualWindow(options).isEmpty());
|
|
1361
1494
|
}
|
|
1362
1495
|
|
|
1363
|
-
|
|
1364
1496
|
test "widget kind codes are pinned: assigned at birth, declaration-order-independent" {
|
|
1365
1497
|
// The FULL golden table. `structuralId` hashes `widgetKindCode`, so
|
|
1366
1498
|
// this table IS the id vocabulary persisted state references:
|
|
@@ -1433,6 +1565,7 @@ test "widget kind codes are pinned: assigned at birth, declaration-order-indepen
|
|
|
1433
1565
|
.{ .kind = .tree, .code = 59 },
|
|
1434
1566
|
.{ .kind = .input_group, .code = 60 },
|
|
1435
1567
|
.{ .kind = .media_surface, .code = 61 },
|
|
1568
|
+
.{ .kind = .terminal, .code = 62 },
|
|
1436
1569
|
};
|
|
1437
1570
|
try testing.expectEqual(std.enums.values(canvas.WidgetKind).len, expected.len);
|
|
1438
1571
|
for (expected) |entry| {
|
|
@@ -1460,4 +1593,3 @@ test "structural id goldens: the id algorithm is pinned end to end" {
|
|
|
1460
1593
|
try testing.expectEqual(@as(canvas.ObjectId, 10740830058688169295), canvas.globalWidgetId(.tree, .{ .index = 3 }));
|
|
1461
1594
|
try testing.expectEqual(@as(canvas.ObjectId, 9835495177657875356), canvas.globalWidgetId(.split_divider, canvas.uiKey("divider")));
|
|
1462
1595
|
}
|
|
1463
|
-
|
|
@@ -34,7 +34,10 @@ pub fn cursorForWidgetHit(hit: ?WidgetHit) WidgetCursor {
|
|
|
34
34
|
pub fn cursorForWidgetTarget(kind: WidgetKind, state: WidgetState) WidgetCursor {
|
|
35
35
|
if (state.disabled) return .arrow;
|
|
36
36
|
return switch (kind) {
|
|
37
|
-
|
|
37
|
+
// The terminal joins the editable-text register: a click
|
|
38
|
+
// focuses the session's input, and the I-beam advertises it —
|
|
39
|
+
// the platform terminals' own convention.
|
|
40
|
+
.input, .text_field, .search_field, .combobox, .textarea, .terminal => .text,
|
|
38
41
|
.resizable, .split_divider => .resize_horizontal,
|
|
39
42
|
else => .arrow,
|
|
40
43
|
};
|
|
@@ -76,7 +79,7 @@ pub fn isDragSource(widget: Widget) bool {
|
|
|
76
79
|
pub fn widgetKindHitTarget(kind: WidgetKind) bool {
|
|
77
80
|
return switch (kind) {
|
|
78
81
|
.row, .column, .grid, .data_grid, .table, .data_row, .list, .breadcrumb, .button_group, .pagination, .radio_group, .tabs, .toggle_group, .stack, .tooltip, .icon, .image, .avatar, .badge, .separator, .skeleton, .spinner, .chart, .split, .tree, .input_group, .media_surface => false,
|
|
79
|
-
.scroll_view, .accordion, .alert, .bubble, .card, .dialog, .drawer, .sheet, .resizable, .panel, .popover, .menu_surface, .dropdown_menu, .text, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .menu_item, .list_item, .data_cell, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .split_divider => true,
|
|
82
|
+
.scroll_view, .accordion, .alert, .bubble, .card, .dialog, .drawer, .sheet, .resizable, .panel, .popover, .menu_surface, .dropdown_menu, .text, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .menu_item, .list_item, .data_cell, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .split_divider, .terminal => true,
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -93,6 +96,25 @@ pub fn isHitTarget(widget: Widget) bool {
|
|
|
93
96
|
return widgetKindHitTarget(widget.kind);
|
|
94
97
|
}
|
|
95
98
|
|
|
99
|
+
/// The hover-Msg CONTAINMENT predicate: everything the interactive hit
|
|
100
|
+
/// test sees, plus hover-Msg listeners. Deliberately a separate policy
|
|
101
|
+
/// from `isHitTarget` — a hover-only listener must be resolvable for
|
|
102
|
+
/// enter/leave containment while remaining INVISIBLE to the interactive
|
|
103
|
+
/// pipeline (wash, cursor, press routing, text selection), so binding
|
|
104
|
+
/// hover changes nothing about where washes paint or clicks land, even
|
|
105
|
+
/// for overlapping siblings.
|
|
106
|
+
pub fn isHoverMsgHitTarget(widget: Widget) bool {
|
|
107
|
+
return isHitTarget(widget) or widgetListensForHoverMsgs(widget);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// Whether this widget's bound hover-enter/hover-leave Msgs are LIVE:
|
|
111
|
+
/// the containment walk (`widgetHoverMsgChainFromNode`) collects only
|
|
112
|
+
/// these. Disabled widgets stand down exactly like they do for presses
|
|
113
|
+
/// (the hit test skips them too).
|
|
114
|
+
pub fn widgetListensForHoverMsgs(widget: Widget) bool {
|
|
115
|
+
return widget.id != 0 and !widget.state.disabled and widget.hover_msgs;
|
|
116
|
+
}
|
|
117
|
+
|
|
96
118
|
/// Whether this widget is a live window-drag surface: a press landing
|
|
97
119
|
/// on it (or falling through to it) moves the WINDOW. Disabled widgets
|
|
98
120
|
/// stand down exactly like they do for presses.
|
|
@@ -140,6 +162,10 @@ pub fn widgetKindClaimsPress(kind: WidgetKind) bool {
|
|
|
140
162
|
.popover,
|
|
141
163
|
.menu_surface,
|
|
142
164
|
.dropdown_menu,
|
|
165
|
+
// A click in the terminal focuses the session's input, exactly
|
|
166
|
+
// like a click in a text field places the caret — it must never
|
|
167
|
+
// activate the row or card around it.
|
|
168
|
+
.terminal,
|
|
143
169
|
=> true,
|
|
144
170
|
else => false,
|
|
145
171
|
};
|
|
@@ -73,6 +73,54 @@ test "anchored frame clamps into the window horizontally and by offset" {
|
|
|
73
73
|
try std.testing.expectEqual(@as(f32, 58), frame.y); // 20 + 28 + 10
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
test "point anchor places the surface corner at the point" {
|
|
77
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
78
|
+
// The anchor rect (a wide row's frame) must be ignored: only the
|
|
79
|
+
// point positions the surface.
|
|
80
|
+
const frame = anchoredFrame(
|
|
81
|
+
child,
|
|
82
|
+
.{ .offset = 0, .point = geometry.PointF.init(180, 60) },
|
|
83
|
+
geometry.RectF.init(0, 40, 400, 40),
|
|
84
|
+
);
|
|
85
|
+
try std.testing.expectEqual(@as(f32, 180), frame.x);
|
|
86
|
+
try std.testing.expectEqual(@as(f32, 60), frame.y);
|
|
87
|
+
try std.testing.expectEqual(@as(f32, 140), frame.width);
|
|
88
|
+
try std.testing.expectEqual(@as(f32, 90), frame.height);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
test "point anchor flips above when the surface would cross the bottom edge" {
|
|
92
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
93
|
+
// window is 300 tall: below the point has 300-260 = 40 < 90, above
|
|
94
|
+
// has 260 — flip, bottom edge lands on the point.
|
|
95
|
+
const frame = anchoredFrame(
|
|
96
|
+
child,
|
|
97
|
+
.{ .offset = 0, .point = geometry.PointF.init(50, 260) },
|
|
98
|
+
geometry.RectF.init(0, 0, 400, 300),
|
|
99
|
+
);
|
|
100
|
+
try std.testing.expectEqual(@as(f32, 260 - 90), frame.y);
|
|
101
|
+
try std.testing.expectEqual(@as(f32, 90), frame.height);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
test "point anchor clamps into the window horizontally" {
|
|
105
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
106
|
+
// window is 400 wide: a point near the right edge cannot push the
|
|
107
|
+
// surface off-screen — it clamps to the window's right edge.
|
|
108
|
+
const right = anchoredFrame(
|
|
109
|
+
child,
|
|
110
|
+
.{ .offset = 0, .point = geometry.PointF.init(390, 60) },
|
|
111
|
+
geometry.RectF.init(0, 0, 400, 300),
|
|
112
|
+
);
|
|
113
|
+
try std.testing.expectEqual(@as(f32, 400 - 140), right.x);
|
|
114
|
+
// A point beyond the window clamps into it first (never off-screen
|
|
115
|
+
// left either).
|
|
116
|
+
const left = anchoredFrame(
|
|
117
|
+
child,
|
|
118
|
+
.{ .offset = 0, .point = geometry.PointF.init(-30, 60) },
|
|
119
|
+
geometry.RectF.init(0, 0, 400, 300),
|
|
120
|
+
);
|
|
121
|
+
try std.testing.expectEqual(@as(f32, 0), left.x);
|
|
122
|
+
}
|
|
123
|
+
|
|
76
124
|
test "anchored children consume no flow space and float against the parent" {
|
|
77
125
|
const menu_items = [_]Widget{.{ .id = 4, .kind = .menu_item, .text = "One" }};
|
|
78
126
|
const dropdown = Widget{
|
|
@@ -37,6 +37,7 @@ const strokeBounds = drawing_model.strokeBounds;
|
|
|
37
37
|
const shadowBounds = drawing_model.shadowBounds;
|
|
38
38
|
const rectsEqual = equality_model.rectsEqual;
|
|
39
39
|
const optionalRectsEqual = equality_model.optionalRectsEqual;
|
|
40
|
+
const optionalSizesEqual = equality_model.optionalSizesEqual;
|
|
40
41
|
const sizesEqual = equality_model.sizesEqual;
|
|
41
42
|
const insetsEqual = equality_model.insetsEqual;
|
|
42
43
|
const optionalColorsEqual = equality_model.optionalColorsEqual;
|
|
@@ -246,6 +247,18 @@ fn validateUniqueWidgetIds(layout: anytype) Error!void {
|
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
|
|
250
|
+
/// Terminal bindings compare clean only while UNBOUND (matching pty and
|
|
251
|
+
/// scrollback, no grid on either side): a bound grid is live emulator
|
|
252
|
+
/// content whose snapshot may be republished at a new address or
|
|
253
|
+
/// refreshed in place between diffs, so it always reports paint damage —
|
|
254
|
+
/// conservative, never stale terminal pixels for partial-invalidation
|
|
255
|
+
/// consumers; the command-level retained diff downstream still keeps the
|
|
256
|
+
/// actual repaint row-shaped.
|
|
257
|
+
fn terminalBindingClean(previous: widget_model.TerminalBinding, next: widget_model.TerminalBinding) bool {
|
|
258
|
+
if (previous.pty != next.pty or previous.scrollback != next.scrollback) return false;
|
|
259
|
+
return previous.grid == null and next.grid == null;
|
|
260
|
+
}
|
|
261
|
+
|
|
249
262
|
fn widgetChange(previous: WidgetLayoutNode, next: WidgetLayoutNode, previous_index: usize, next_index: usize, tokens: DesignTokens) WidgetInvalidation {
|
|
250
263
|
const layout_dirty =
|
|
251
264
|
previous.widget.kind != next.widget.kind or
|
|
@@ -259,13 +272,17 @@ fn widgetChange(previous: WidgetLayoutNode, next: WidgetLayoutNode, previous_ind
|
|
|
259
272
|
!std.mem.eql(u8, previous.widget.placeholder, next.widget.placeholder) or
|
|
260
273
|
!std.mem.eql(u8, previous.widget.icon, next.widget.icon) or
|
|
261
274
|
previous.widget.value != next.widget.value or
|
|
275
|
+
previous.widget.value_x != next.widget.value_x or
|
|
276
|
+
previous.widget.scroll_axes != next.widget.scroll_axes or
|
|
262
277
|
previous.widget.image_id != next.widget.image_id or
|
|
263
278
|
!optionalRectsEqual(previous.widget.image_src, next.widget.image_src) or
|
|
264
279
|
previous.widget.image_fit != next.widget.image_fit or
|
|
265
280
|
previous.widget.image_sampling != next.widget.image_sampling or
|
|
266
281
|
previous.widget.image_opacity != next.widget.image_opacity or
|
|
282
|
+
!optionalSizesEqual(previous.widget.stream_size, next.widget.stream_size) or
|
|
267
283
|
!optionalTextSelectionsEqual(previous.widget.text_selection, next.widget.text_selection) or
|
|
268
|
-
!optionalTextRangesEqual(previous.widget.text_composition, next.widget.text_composition)
|
|
284
|
+
!optionalTextRangesEqual(previous.widget.text_composition, next.widget.text_composition) or
|
|
285
|
+
!terminalBindingClean(previous.widget.terminal, next.widget.terminal);
|
|
269
286
|
const behavior_dirty = !std.mem.eql(u8, previous.widget.command, next.widget.command);
|
|
270
287
|
const visual_dirty = previous.widget.opacity != next.widget.opacity or
|
|
271
288
|
!affinesEqual(previous.widget.transform, next.widget.transform) or
|
|
@@ -315,6 +332,10 @@ pub fn widgetRenderStateDirtyBounds(layout: anytype, previous: WidgetRenderState
|
|
|
315
332
|
appendOptionalObjectId(&ids, &id_len, previous.focused_id);
|
|
316
333
|
appendOptionalObjectId(&ids, &id_len, next.focused_id);
|
|
317
334
|
}
|
|
335
|
+
if (previous.keyboard_active != next.keyboard_active) {
|
|
336
|
+
appendOptionalObjectId(&ids, &id_len, previous.focused_id);
|
|
337
|
+
appendOptionalObjectId(&ids, &id_len, next.focused_id);
|
|
338
|
+
}
|
|
318
339
|
if (previous.focus_visible_id != next.focus_visible_id) {
|
|
319
340
|
appendOptionalObjectId(&ids, &id_len, previous.focus_visible_id);
|
|
320
341
|
appendOptionalObjectId(&ids, &id_len, next.focus_visible_id);
|
|
@@ -336,9 +357,41 @@ pub fn widgetRenderStateDirtyBounds(layout: anytype, previous: WidgetRenderState
|
|
|
336
357
|
const base = widgetWithFrame(node.widget, node.frame);
|
|
337
358
|
const previous_widget = widgetWithRenderState(base, previous);
|
|
338
359
|
const next_widget = widgetWithRenderState(base, next);
|
|
360
|
+
// A terminal's cursor follows LOGICAL focus (`focused_id`), not
|
|
361
|
+
// the focus-visible state projected into `WidgetState.focused`.
|
|
362
|
+
// Dirtiness has to mirror that extra render dependency or a
|
|
363
|
+
// quiet pointer-focus/window-focus transition can change the
|
|
364
|
+
// cursor from hollow to filled while this API reports no pixels.
|
|
365
|
+
if (terminalLogicalFocusPaintChanged(base, previous, next)) {
|
|
366
|
+
bounds = unionOptionalBounds(bounds, widgetClippedDirtyBounds(
|
|
367
|
+
layout,
|
|
368
|
+
index,
|
|
369
|
+
widgetFullPaintBoundsWithTransform(node, widgetAccumulatedTransform(layout, index), tokens),
|
|
370
|
+
));
|
|
371
|
+
}
|
|
339
372
|
if (widgetStatesEqual(previous_widget.state, next_widget.state)) continue;
|
|
340
373
|
bounds = unionOptionalBounds(bounds, widgetClippedDirtyBounds(layout, index, widgetRenderStatePaintChangeBounds(previous_widget, next_widget, tokens)));
|
|
341
374
|
}
|
|
375
|
+
// With no runtime focus ids, baked `WidgetState.focused` is the
|
|
376
|
+
// renderer's source of truth. A keyboard-active transition still
|
|
377
|
+
// changes a baked-focused terminal cursor, but the targeted id list
|
|
378
|
+
// above is empty in exactly that state. Walk the layout only for
|
|
379
|
+
// this rare window/app activity edge so the dirty-bounds API mirrors
|
|
380
|
+
// the pixels without taxing ordinary hover/press/focus changes.
|
|
381
|
+
if (previous.keyboard_active != next.keyboard_active and
|
|
382
|
+
renderStateUsesBakedFocus(previous) and
|
|
383
|
+
renderStateUsesBakedFocus(next))
|
|
384
|
+
{
|
|
385
|
+
for (layout.nodes, 0..) |node, index| {
|
|
386
|
+
const base = widgetWithFrame(node.widget, node.frame);
|
|
387
|
+
if (!terminalLogicalFocusPaintChanged(base, previous, next)) continue;
|
|
388
|
+
bounds = unionOptionalBounds(bounds, widgetClippedDirtyBounds(
|
|
389
|
+
layout,
|
|
390
|
+
index,
|
|
391
|
+
widgetFullPaintBoundsWithTransform(node, widgetAccumulatedTransform(layout, index), tokens),
|
|
392
|
+
));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
342
395
|
// Focus-within chrome: an `.input_group` ancestor wears the focus
|
|
343
396
|
// ring FOR its focused descendant, so a focus-visible change dirties
|
|
344
397
|
// the group's ring region too — the group's own id never appears in
|
|
@@ -358,6 +411,29 @@ pub fn widgetRenderStateDirtyBounds(layout: anytype, previous: WidgetRenderState
|
|
|
358
411
|
return bounds;
|
|
359
412
|
}
|
|
360
413
|
|
|
414
|
+
/// Whether a live, visible terminal cursor changes fill-vs-outline
|
|
415
|
+
/// because logical keyboard focus moved. Ended sessions are always
|
|
416
|
+
/// hollow and a grid without a cursor paints no focus-dependent pixels.
|
|
417
|
+
fn terminalLogicalFocusPaintChanged(widget: Widget, previous: WidgetRenderState, next: WidgetRenderState) bool {
|
|
418
|
+
if (widget.kind != .terminal) return false;
|
|
419
|
+
const grid = widget.terminal.grid orelse return false;
|
|
420
|
+
if (!grid.running or grid.cursor == null) return false;
|
|
421
|
+
return widgetHasLogicalFocus(widget, previous) != widgetHasLogicalFocus(widget, next);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
fn widgetHasLogicalFocus(widget: Widget, state: WidgetRenderState) bool {
|
|
425
|
+
if (!state.keyboard_active) return false;
|
|
426
|
+
if (state.focused_id != null or state.focus_visible_id != null) {
|
|
427
|
+
const focused_id = state.focused_id orelse return false;
|
|
428
|
+
return widget.id != 0 and widget.id == focused_id;
|
|
429
|
+
}
|
|
430
|
+
return widget.state.focused;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
fn renderStateUsesBakedFocus(state: WidgetRenderState) bool {
|
|
434
|
+
return state.focused_id == null and state.focus_visible_id == null;
|
|
435
|
+
}
|
|
436
|
+
|
|
361
437
|
fn optionalPointsEqual(a: ?geometry.PointF, b: ?geometry.PointF) bool {
|
|
362
438
|
if (a) |point_a| {
|
|
363
439
|
const point_b = b orelse return false;
|
|
@@ -632,6 +708,10 @@ fn widgetFocusStrokeWidth(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
632
708
|
.switch_control,
|
|
633
709
|
.toggle,
|
|
634
710
|
.slider,
|
|
711
|
+
// The terminal wears the same ring-offset focus stroke, so a
|
|
712
|
+
// focus enter/leave must reserve the same outside-the-frame
|
|
713
|
+
// damage or a retained renderer leaves the ring stale.
|
|
714
|
+
.terminal,
|
|
635
715
|
=> tokens.stroke.focus,
|
|
636
716
|
else => 0,
|
|
637
717
|
};
|
|
@@ -103,7 +103,7 @@ pub fn layoutWidgetDepth(
|
|
|
103
103
|
.scroll_view => if (widget.layout.virtualized)
|
|
104
104
|
try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
105
105
|
else
|
|
106
|
-
try layoutScrollChildren(widget.children, content, index, depth, output, len, widget
|
|
106
|
+
try layoutScrollChildren(widget.children, content, index, depth, output, len, scrollLayoutOffset(widget), tokens),
|
|
107
107
|
.list => if (widget.layout.virtualized)
|
|
108
108
|
try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
109
109
|
else
|
|
@@ -144,7 +144,7 @@ pub fn layoutWidgetDepth(
|
|
|
144
144
|
// Span paragraphs and span-carrying table cells share the link
|
|
145
145
|
// hotspot child convention (no spans or no children is a no-op).
|
|
146
146
|
.text, .data_cell => try layoutTextSpanLinkChildren(widget, content, index, depth, output, len, tokens),
|
|
147
|
-
.icon, .image, .avatar, .badge, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .tooltip, .menu_item, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .separator, .skeleton, .spinner, .chart, .split_divider, .media_surface => {},
|
|
147
|
+
.icon, .image, .avatar, .badge, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .tooltip, .menu_item, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .separator, .skeleton, .spinner, .chart, .split_divider, .media_surface, .terminal => {},
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// Anchored floating children are excluded from every flow above (they
|
|
@@ -291,7 +291,9 @@ fn widgetIsWindowControlContent(widget: Widget) bool {
|
|
|
291
291
|
// A text leaf with no bytes and no spans is a hit/semantics
|
|
292
292
|
// overlay, not readable content.
|
|
293
293
|
.text => widget.text.len > 0 or widget.spans.len > 0,
|
|
294
|
-
|
|
294
|
+
// The terminal's grid is readable content edge to edge — the
|
|
295
|
+
// cluster must never cover its rows.
|
|
296
|
+
.data_cell, .icon, .avatar, .badge, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .tooltip, .menu_item, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .spinner, .chart, .terminal => true,
|
|
295
297
|
};
|
|
296
298
|
}
|
|
297
299
|
|
|
@@ -316,7 +318,11 @@ fn layoutAnchoredChildren(
|
|
|
316
318
|
/// width), placed on the preferred side of the anchor rect — flipping to
|
|
317
319
|
/// the other side when it does not fit and the other side has more room —
|
|
318
320
|
/// with height clamped to the chosen side's space and both axes clamped
|
|
319
|
-
/// into the window.
|
|
321
|
+
/// into the window. A point anchor (`anchor.point`) replaces the anchor
|
|
322
|
+
/// rect with a zero-size rect at that point (clamped into the window), so
|
|
323
|
+
/// the same flip and clamp rules position a surface against an explicit
|
|
324
|
+
/// coordinate — the context-menu-at-the-pointer shape. Pure geometry,
|
|
325
|
+
/// unit-testable on its own.
|
|
320
326
|
pub fn anchoredWidgetFrame(
|
|
321
327
|
child: Widget,
|
|
322
328
|
anchor: widget_model.WidgetAnchor,
|
|
@@ -325,7 +331,12 @@ pub fn anchoredWidgetFrame(
|
|
|
325
331
|
tokens: DesignTokens,
|
|
326
332
|
) geometry.RectF {
|
|
327
333
|
const window = window_rect.normalized();
|
|
328
|
-
const anchor_frame =
|
|
334
|
+
const anchor_frame = if (anchor.point) |point| geometry.RectF.init(
|
|
335
|
+
std.math.clamp(point.x, window.x, window.maxX()),
|
|
336
|
+
std.math.clamp(point.y, window.y, window.maxY()),
|
|
337
|
+
0,
|
|
338
|
+
0,
|
|
339
|
+
) else anchor_rect.normalized();
|
|
329
340
|
const intrinsic = intrinsicWidgetSize(child, tokens);
|
|
330
341
|
|
|
331
342
|
var width = if (child.frame.width > 0) child.frame.width else intrinsic.width;
|
|
@@ -522,7 +533,22 @@ fn widgetInsideVerticalScrollScope(output: []const WidgetLayoutNode, parent_inde
|
|
|
522
533
|
var current: ?usize = parent_index;
|
|
523
534
|
while (current) |index| {
|
|
524
535
|
const widget = output[index].widget;
|
|
525
|
-
if (widget.kind == .scroll_view or widget.layout.virtualized) return true;
|
|
536
|
+
if ((widget.kind == .scroll_view and widget.scroll_axes.scrollsVertically()) or widget.layout.virtualized) return true;
|
|
537
|
+
if (widget.layout.anchor != null) return false;
|
|
538
|
+
current = output[index].parent_index;
|
|
539
|
+
}
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/// The horizontal twin of `widgetInsideVerticalScrollScope`: inside a
|
|
544
|
+
/// HORIZONTALLY scrolling scope (a `.scroll_view` ancestor granting the
|
|
545
|
+
/// horizontal axis), content wider than the viewport is the operating
|
|
546
|
+
/// mode, so the horizontal overflow diagnostic stays quiet there.
|
|
547
|
+
fn widgetInsideHorizontalScrollScope(output: []const WidgetLayoutNode, parent_index: usize) bool {
|
|
548
|
+
var current: ?usize = parent_index;
|
|
549
|
+
while (current) |index| {
|
|
550
|
+
const widget = output[index].widget;
|
|
551
|
+
if (widget.kind == .scroll_view and widget.scroll_axes.scrollsHorizontally() and !widget.layout.virtualized) return true;
|
|
526
552
|
if (widget.layout.anchor != null) return false;
|
|
527
553
|
current = output[index].parent_index;
|
|
528
554
|
}
|
|
@@ -540,13 +566,15 @@ fn widgetInsideVerticalScrollScope(output: []const WidgetLayoutNode, parent_inde
|
|
|
540
566
|
/// virtualized scroll's content wrapper is sized to the viewport and
|
|
541
567
|
/// its children legitimately extend past it on every rebuild, which
|
|
542
568
|
/// used to repeat this line hundreds of times for a perfectly correct
|
|
543
|
-
/// layout. Horizontal overflow
|
|
544
|
-
///
|
|
569
|
+
/// layout. Horizontal overflow warns there UNLESS a horizontally
|
|
570
|
+
/// scrolling scope encloses it — a `horizontal`/`both` scroll view
|
|
571
|
+
/// exists precisely to reveal sideways content.
|
|
545
572
|
/// - The line names the concrete widget (root-first kind path, label
|
|
546
573
|
/// snippet, id — the same identity the layout audit prints), because
|
|
547
574
|
/// a bare kind like "column" is unactionable in any real tree.
|
|
548
575
|
fn logAxisChildrenOverflow(output: []const WidgetLayoutNode, parent_index: usize, axis: LayoutAxis, available_extent: f32, used_extent: f32, overflow: f32) void {
|
|
549
576
|
if (axis == .vertical and widgetInsideVerticalScrollScope(output, parent_index)) return;
|
|
577
|
+
if (axis == .horizontal and widgetInsideHorizontalScrollScope(output, parent_index)) return;
|
|
550
578
|
if (builtin.is_test) test_axis_overflow_diagnostics += 1;
|
|
551
579
|
if (builtin.mode != .Debug) return;
|
|
552
580
|
var path_buffer: [256]u8 = undefined;
|
|
@@ -1005,6 +1033,17 @@ fn preferredGridRowExtent(children: []const Widget, columns: usize, tokens: Desi
|
|
|
1005
1033
|
return max_height;
|
|
1006
1034
|
}
|
|
1007
1035
|
|
|
1036
|
+
/// The layout-time scroll displacement of a non-virtualized scroll
|
|
1037
|
+
/// view: each offset applies only on an axis the region grants, so a
|
|
1038
|
+
/// stale `value_x` on a vertical-only region can never shear its
|
|
1039
|
+
/// content sideways — and a stale `value` on a horizontal-only one can
|
|
1040
|
+
/// never leave it displaced upward.
|
|
1041
|
+
fn scrollLayoutOffset(widget: Widget) geometry.OffsetF {
|
|
1042
|
+
const scroll_x = if (widget.scroll_axes.scrollsHorizontally()) widget.value_x else 0;
|
|
1043
|
+
const scroll_y = if (widget.scroll_axes.scrollsVertically()) widget.value else 0;
|
|
1044
|
+
return geometry.OffsetF.init(scroll_x, scroll_y);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1008
1047
|
fn layoutScrollChildren(
|
|
1009
1048
|
children: []const Widget,
|
|
1010
1049
|
content: geometry.RectF,
|
|
@@ -1012,10 +1051,10 @@ fn layoutScrollChildren(
|
|
|
1012
1051
|
depth: usize,
|
|
1013
1052
|
output: []WidgetLayoutNode,
|
|
1014
1053
|
len: *usize,
|
|
1015
|
-
|
|
1054
|
+
scroll_offset: geometry.OffsetF,
|
|
1016
1055
|
tokens: DesignTokens,
|
|
1017
1056
|
) Error!void {
|
|
1018
|
-
const scrolled_content = content.translate(geometry.OffsetF.init(
|
|
1057
|
+
const scrolled_content = content.translate(geometry.OffsetF.init(-scroll_offset.dx, -scroll_offset.dy));
|
|
1019
1058
|
for (children) |child| {
|
|
1020
1059
|
if (child.layout.anchor != null) continue;
|
|
1021
1060
|
_ = try layoutWidgetDepth(child, stackChildFrame(scrolled_content, child), parent_index, depth + 1, output, len, tokens);
|
|
@@ -1506,6 +1545,12 @@ pub fn intrinsicWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF
|
|
|
1506
1545
|
}
|
|
1507
1546
|
|
|
1508
1547
|
fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
1548
|
+
// The composed-media contract (`WidgetLayoutStyle.zero_intrinsic`):
|
|
1549
|
+
// the container measures like the media-surface leaf regardless of
|
|
1550
|
+
// what chrome it composes. Declared width/height still apply — they
|
|
1551
|
+
// ride the widget frame and the min/max bounds, which every caller
|
|
1552
|
+
// maxes against this measure.
|
|
1553
|
+
if (widget.layout.zero_intrinsic) return geometry.SizeF.zero();
|
|
1509
1554
|
return switch (widget.kind) {
|
|
1510
1555
|
.text => intrinsicTextWidgetSize(widget, tokens, widgetBodyTextSize(widget, tokens)),
|
|
1511
1556
|
.icon => geometry.SizeF.init(intrinsicIconExtent(widget, tokens), intrinsicIconExtent(widget, tokens)),
|
|
@@ -1592,7 +1637,10 @@ fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize)
|
|
|
1592
1637
|
// Media surfaces measure like images: the texture is external
|
|
1593
1638
|
// content with no natural layout size — definite width/height
|
|
1594
1639
|
// (or flex grow) size the surface, exactly like an image leaf.
|
|
1595
|
-
|
|
1640
|
+
// Terminals join them: the grid derives its cols/rows FROM the
|
|
1641
|
+
// space it is given (the runtime resizes the pty to fit), so
|
|
1642
|
+
// reporting an intrinsic size would invert the contract.
|
|
1643
|
+
.scroll_view, .image, .split, .media_surface, .terminal => geometry.SizeF.zero(),
|
|
1596
1644
|
};
|
|
1597
1645
|
}
|
|
1598
1646
|
|