@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
|
@@ -196,6 +196,7 @@ const SpringToken = support.SpringToken;
|
|
|
196
196
|
const BlurTokenRef = support.BlurTokenRef;
|
|
197
197
|
const ScrollPhysics = support.ScrollPhysics;
|
|
198
198
|
const ScrollState = support.ScrollState;
|
|
199
|
+
const ScrollAxisState = support.ScrollAxisState;
|
|
199
200
|
const VirtualListOptions = support.VirtualListOptions;
|
|
200
201
|
const VirtualListRange = support.VirtualListRange;
|
|
201
202
|
const virtualListRange = support.virtualListRange;
|
|
@@ -1412,6 +1413,126 @@ test "widget scroll view scrollbars use control visual tokens" {
|
|
|
1412
1413
|
}
|
|
1413
1414
|
}
|
|
1414
1415
|
|
|
1416
|
+
test "horizontal scroll views draw the bottom-edge scrollbar and two-axis regions reserve the corner" {
|
|
1417
|
+
const tokens: DesignTokens = .{};
|
|
1418
|
+
|
|
1419
|
+
// A horizontal shelf: content reaches x = 460 in a 120-wide
|
|
1420
|
+
// viewport. Only the horizontal bar (part slots 4/5) exists.
|
|
1421
|
+
const tiles = [_]Widget{
|
|
1422
|
+
.{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 140, 40) },
|
|
1423
|
+
.{ .id = 3, .kind = .panel, .frame = geometry.RectF.init(320, 0, 140, 40) },
|
|
1424
|
+
};
|
|
1425
|
+
const shelf = Widget{
|
|
1426
|
+
.id = 1,
|
|
1427
|
+
.kind = .scroll_view,
|
|
1428
|
+
.scroll_axes = .horizontal,
|
|
1429
|
+
.value_x = 20,
|
|
1430
|
+
.children = &tiles,
|
|
1431
|
+
};
|
|
1432
|
+
var shelf_nodes: [4]WidgetLayoutNode = undefined;
|
|
1433
|
+
const shelf_layout = try layoutWidgetTree(shelf, geometry.RectF.init(0, 0, 120, 60), &shelf_nodes);
|
|
1434
|
+
// The horizontal offset displaces children leftward at layout time,
|
|
1435
|
+
// exactly as the vertical offset displaces them upward.
|
|
1436
|
+
try expectLayoutFrame(shelf_layout, 2, geometry.RectF.init(-20, 0, 140, 40));
|
|
1437
|
+
try expectLayoutFrame(shelf_layout, 3, geometry.RectF.init(300, 0, 140, 40));
|
|
1438
|
+
|
|
1439
|
+
var commands: [16]CanvasCommand = undefined;
|
|
1440
|
+
var builder = Builder.init(&commands);
|
|
1441
|
+
try shelf_layout.emitDisplayList(&builder, tokens);
|
|
1442
|
+
const display_list = builder.displayList();
|
|
1443
|
+
try std.testing.expect(display_list.findCommandById(widgetPartId(1, 2)) == null);
|
|
1444
|
+
try std.testing.expect(display_list.findCommandById(widgetPartId(1, 3)) == null);
|
|
1445
|
+
switch (display_list.findCommandById(widgetPartId(1, 4)).?.command) {
|
|
1446
|
+
.fill_rounded_rect => |track| {
|
|
1447
|
+
// Bottom edge: inset 3, thickness 3, full width minus insets.
|
|
1448
|
+
try expectRect(geometry.RectF.init(3, 54, 114, 3), track.rect);
|
|
1449
|
+
},
|
|
1450
|
+
else => return error.TestUnexpectedResult,
|
|
1451
|
+
}
|
|
1452
|
+
switch (display_list.findCommandById(widgetPartId(1, 5)).?.command) {
|
|
1453
|
+
.fill_rounded_rect => |thumb| {
|
|
1454
|
+
try std.testing.expectEqual(@as(f32, 54), thumb.rect.y);
|
|
1455
|
+
try std.testing.expect(thumb.rect.width < 114);
|
|
1456
|
+
try std.testing.expect(thumb.rect.x > 3);
|
|
1457
|
+
},
|
|
1458
|
+
else => return error.TestUnexpectedResult,
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// A both-axes region with overflow on both axes draws BOTH bars,
|
|
1462
|
+
// each track ending short of the shared corner.
|
|
1463
|
+
const sheet = Widget{
|
|
1464
|
+
.id = 1,
|
|
1465
|
+
.kind = .scroll_view,
|
|
1466
|
+
.scroll_axes = .both,
|
|
1467
|
+
.children = &[_]Widget{.{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 400, 300) }},
|
|
1468
|
+
};
|
|
1469
|
+
var sheet_nodes: [3]WidgetLayoutNode = undefined;
|
|
1470
|
+
const sheet_layout = try layoutWidgetTree(sheet, geometry.RectF.init(0, 0, 120, 60), &sheet_nodes);
|
|
1471
|
+
var sheet_commands: [16]CanvasCommand = undefined;
|
|
1472
|
+
var sheet_builder = Builder.init(&sheet_commands);
|
|
1473
|
+
try sheet_layout.emitDisplayList(&sheet_builder, tokens);
|
|
1474
|
+
const sheet_list = sheet_builder.displayList();
|
|
1475
|
+
switch (sheet_list.findCommandById(widgetPartId(1, 2)).?.command) {
|
|
1476
|
+
.fill_rounded_rect => |track| {
|
|
1477
|
+
// The vertical track gives up thickness + inset (6) at the
|
|
1478
|
+
// bottom corner: 60 - 2*3 - 6 = 48.
|
|
1479
|
+
try expectRect(geometry.RectF.init(114, 3, 3, 48), track.rect);
|
|
1480
|
+
},
|
|
1481
|
+
else => return error.TestUnexpectedResult,
|
|
1482
|
+
}
|
|
1483
|
+
switch (sheet_list.findCommandById(widgetPartId(1, 4)).?.command) {
|
|
1484
|
+
.fill_rounded_rect => |track| {
|
|
1485
|
+
try expectRect(geometry.RectF.init(3, 54, 108, 3), track.rect);
|
|
1486
|
+
},
|
|
1487
|
+
else => return error.TestUnexpectedResult,
|
|
1488
|
+
}
|
|
1489
|
+
try std.testing.expect(sheet_list.findCommandById(widgetPartId(1, 3)) != null);
|
|
1490
|
+
try std.testing.expect(sheet_list.findCommandById(widgetPartId(1, 5)) != null);
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
test "a both-axes region whose content only overflows sideways reports horizontal scroll semantics" {
|
|
1494
|
+
// 500-wide content in a 200 x 100 both-axes viewport: no vertical
|
|
1495
|
+
// range, real horizontal range. The assistive node must read the
|
|
1496
|
+
// LIVE axis — scrollable, with the horizontal offset/extents — not
|
|
1497
|
+
// a permanently unscrollable vertical axis.
|
|
1498
|
+
const sheet = Widget{
|
|
1499
|
+
.id = 1,
|
|
1500
|
+
.kind = .scroll_view,
|
|
1501
|
+
.scroll_axes = .both,
|
|
1502
|
+
.value_x = 60,
|
|
1503
|
+
.children = &[_]Widget{.{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 500, 100) }},
|
|
1504
|
+
};
|
|
1505
|
+
var nodes: [3]WidgetLayoutNode = undefined;
|
|
1506
|
+
const layout = try layoutWidgetTree(sheet, geometry.RectF.init(0, 0, 200, 100), &nodes);
|
|
1507
|
+
|
|
1508
|
+
var semantics_buffer: [3]WidgetSemanticsNode = undefined;
|
|
1509
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1510
|
+
try std.testing.expect(semantics[0].scroll.present);
|
|
1511
|
+
try std.testing.expectEqual(@as(f32, 60), semantics[0].scroll.offset);
|
|
1512
|
+
try std.testing.expectEqual(@as(f32, 200), semantics[0].scroll.viewport_extent);
|
|
1513
|
+
try std.testing.expectEqual(@as(f32, 500), semantics[0].scroll.content_extent);
|
|
1514
|
+
try std.testing.expectApproxEqAbs(@as(f32, 60.0 / 300.0), semantics[0].value.?, 0.001);
|
|
1515
|
+
try std.testing.expect(semantics[0].actions.increment);
|
|
1516
|
+
try std.testing.expect(semantics[0].actions.decrement);
|
|
1517
|
+
|
|
1518
|
+
// With VERTICAL range present the vertical axis stays primary — the
|
|
1519
|
+
// pre-axis behavior for every region that scrolls down.
|
|
1520
|
+
const tall = Widget{
|
|
1521
|
+
.id = 1,
|
|
1522
|
+
.kind = .scroll_view,
|
|
1523
|
+
.scroll_axes = .both,
|
|
1524
|
+
.value = 30,
|
|
1525
|
+
.children = &[_]Widget{.{ .id = 2, .kind = .panel, .frame = geometry.RectF.init(0, 0, 500, 400) }},
|
|
1526
|
+
};
|
|
1527
|
+
var tall_nodes: [3]WidgetLayoutNode = undefined;
|
|
1528
|
+
const tall_layout = try layoutWidgetTree(tall, geometry.RectF.init(0, 0, 200, 100), &tall_nodes);
|
|
1529
|
+
var tall_buffer: [3]WidgetSemanticsNode = undefined;
|
|
1530
|
+
const tall_semantics = try tall_layout.collectSemantics(&tall_buffer);
|
|
1531
|
+
try std.testing.expectEqual(@as(f32, 30), tall_semantics[0].scroll.offset);
|
|
1532
|
+
try std.testing.expectEqual(@as(f32, 100), tall_semantics[0].scroll.viewport_extent);
|
|
1533
|
+
try std.testing.expectEqual(@as(f32, 400), tall_semantics[0].scroll.content_extent);
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1415
1536
|
test "widget focus traversal skips scroll clipped children" {
|
|
1416
1537
|
const children = [_]Widget{
|
|
1417
1538
|
.{ .id = 2, .kind = .button, .frame = geometry.RectF.init(0, 0, 0, 32), .text = "One" },
|
|
@@ -1446,7 +1567,7 @@ test "scroll state applies wheel deltas kinetic decay and bounds" {
|
|
|
1446
1567
|
.deceleration_per_second = 0.5,
|
|
1447
1568
|
.stop_velocity = 1,
|
|
1448
1569
|
};
|
|
1449
|
-
const start =
|
|
1570
|
+
const start = ScrollAxisState{
|
|
1450
1571
|
.offset = 10,
|
|
1451
1572
|
.viewport_extent = 100,
|
|
1452
1573
|
.content_extent = 360,
|
|
@@ -1471,7 +1592,7 @@ test "scroll state applies wheel deltas kinetic decay and bounds" {
|
|
|
1471
1592
|
}
|
|
1472
1593
|
|
|
1473
1594
|
test "scroll overscroll gates rubber-band: none pins at the edges, rubber_band excursions recover" {
|
|
1474
|
-
const start =
|
|
1595
|
+
const start = ScrollAxisState{
|
|
1475
1596
|
.offset = 250,
|
|
1476
1597
|
.viewport_extent = 100,
|
|
1477
1598
|
.content_extent = 360,
|
|
@@ -1485,7 +1606,7 @@ test "scroll overscroll gates rubber-band: none pins at the edges, rubber_band e
|
|
|
1485
1606
|
const pinned = start.applyWheel(1000, pinned_physics);
|
|
1486
1607
|
try std.testing.expectEqual(@as(f32, 260), pinned.offset);
|
|
1487
1608
|
try std.testing.expectEqual(@as(f32, 0), pinned.velocity);
|
|
1488
|
-
var rolling =
|
|
1609
|
+
var rolling = ScrollAxisState{
|
|
1489
1610
|
.offset = 250,
|
|
1490
1611
|
.velocity = 400,
|
|
1491
1612
|
.viewport_extent = 100,
|
|
@@ -1512,7 +1633,7 @@ test "scroll overscroll gates rubber-band: none pins at the edges, rubber_band e
|
|
|
1512
1633
|
|
|
1513
1634
|
// A stale out-of-range offset on a pinned region self-heals in one
|
|
1514
1635
|
// kinetic step instead of animating a return.
|
|
1515
|
-
const stale =
|
|
1636
|
+
const stale = ScrollAxisState{
|
|
1516
1637
|
.offset = 300,
|
|
1517
1638
|
.viewport_extent = 100,
|
|
1518
1639
|
.content_extent = 360,
|
|
@@ -235,6 +235,7 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
235
235
|
.icon => try emitIconWidget(builder, paint_widget, tokens),
|
|
236
236
|
.image => try emitImageWidget(builder, paint_widget),
|
|
237
237
|
.media_surface => try emitMediaSurfaceWidget(builder, paint_widget),
|
|
238
|
+
.terminal => try emitTerminalWidget(builder, paint_widget, tokens, paint_widget.state.focused),
|
|
238
239
|
.avatar => try emitAvatarWidget(builder, paint_widget, tokens),
|
|
239
240
|
.badge => try emitBadgeWidget(builder, paint_widget, tokens),
|
|
240
241
|
.button, .toggle_button, .toggle => try widget_render_controls.emitButtonWidget(builder, paint_widget, tokens),
|
|
@@ -510,7 +511,14 @@ fn emitWidgetLayoutNodeContent(
|
|
|
510
511
|
try builder.popClip();
|
|
511
512
|
// Native scroll drivers own the (OS overlay) scrollbar.
|
|
512
513
|
if (!paint_widget.native_scroll) {
|
|
513
|
-
try widget_render_scroll.
|
|
514
|
+
try widget_render_scroll.emitScrollViewScrollbars(
|
|
515
|
+
builder,
|
|
516
|
+
paint_widget.frame,
|
|
517
|
+
widgetScrollAxisMetrics(layout, node_index, .vertical),
|
|
518
|
+
widgetScrollAxisMetrics(layout, node_index, .horizontal),
|
|
519
|
+
tokens,
|
|
520
|
+
paint_widget.id,
|
|
521
|
+
);
|
|
514
522
|
}
|
|
515
523
|
return;
|
|
516
524
|
},
|
|
@@ -570,6 +578,7 @@ fn emitWidgetLayoutNodeContent(
|
|
|
570
578
|
.icon => try emitIconWidget(builder, paint_widget, tokens),
|
|
571
579
|
.image => try emitImageWidget(builder, paint_widget),
|
|
572
580
|
.media_surface => try emitMediaSurfaceWidget(builder, paint_widget),
|
|
581
|
+
.terminal => try emitTerminalWidget(builder, paint_widget, tokens, widgetHasLogicalFocus(paint_widget, state)),
|
|
573
582
|
.avatar => try emitAvatarWidget(builder, paint_widget, tokens),
|
|
574
583
|
.badge => try emitBadgeWidget(builder, paint_widget, tokens),
|
|
575
584
|
.button, .toggle_button, .toggle => try widget_render_controls.emitButtonWidget(builder, paint_widget, tokens),
|
|
@@ -629,9 +638,18 @@ fn emitWidgetLayoutScrollableChildren(
|
|
|
629
638
|
try builder.pushClip(clip);
|
|
630
639
|
try emitWidgetLayoutChildren(builder, layout, parent_index, tokens, state);
|
|
631
640
|
try builder.popClip();
|
|
632
|
-
// Native scroll drivers own the (OS overlay) scrollbar.
|
|
641
|
+
// Native scroll drivers own the (OS overlay) scrollbar. These are
|
|
642
|
+
// the virtualized containers — vertical machinery, so only the
|
|
643
|
+
// vertical bar can exist.
|
|
633
644
|
if (!widget.native_scroll) {
|
|
634
|
-
try widget_render_scroll.
|
|
645
|
+
try widget_render_scroll.emitScrollViewScrollbars(
|
|
646
|
+
builder,
|
|
647
|
+
widget.frame,
|
|
648
|
+
widgetScrollAxisMetrics(layout, parent_index, .vertical),
|
|
649
|
+
.{},
|
|
650
|
+
tokens,
|
|
651
|
+
widget.id,
|
|
652
|
+
);
|
|
635
653
|
}
|
|
636
654
|
}
|
|
637
655
|
|
|
@@ -864,7 +882,14 @@ fn emitScrollViewWidget(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
864
882
|
try builder.popClip();
|
|
865
883
|
// Native scroll drivers own the (OS overlay) scrollbar.
|
|
866
884
|
if (!widget.native_scroll) {
|
|
867
|
-
try widget_render_scroll.
|
|
885
|
+
try widget_render_scroll.emitScrollViewScrollbars(
|
|
886
|
+
builder,
|
|
887
|
+
widget.frame,
|
|
888
|
+
widget_render_scroll.widgetScrollAxisMetricsForWidget(widget, tokens, .vertical),
|
|
889
|
+
widget_render_scroll.widgetScrollAxisMetricsForWidget(widget, tokens, .horizontal),
|
|
890
|
+
tokens,
|
|
891
|
+
widget.id,
|
|
892
|
+
);
|
|
868
893
|
}
|
|
869
894
|
}
|
|
870
895
|
|
|
@@ -878,6 +903,16 @@ fn widgetScrollSemantics(layout: anytype, node_index: usize) widget_semantics.Wi
|
|
|
878
903
|
return widget_semantics.widgetScrollSemantics(layout, node_index, widget_layout.virtualWidgetScrollContentExtent);
|
|
879
904
|
}
|
|
880
905
|
|
|
906
|
+
/// Per-axis scrollbar metrics for a layout-walk scroll region (present
|
|
907
|
+
/// = false on an ungranted axis or an empty viewport).
|
|
908
|
+
fn widgetScrollAxisMetrics(layout: anytype, node_index: usize, comptime axis: canvas.ScrollAxis) event_model.WidgetScrollMetrics {
|
|
909
|
+
if (node_index >= layout.nodes.len) return .{};
|
|
910
|
+
const node = layout.nodes[node_index];
|
|
911
|
+
const viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
912
|
+
if (viewport.isEmpty()) return .{};
|
|
913
|
+
return widget_semantics.widgetScrollAxisMetrics(layout, node_index, widget_layout.virtualWidgetScrollContentExtent, axis, viewport);
|
|
914
|
+
}
|
|
915
|
+
|
|
881
916
|
fn emitWidgetLayoutClippedChildren(
|
|
882
917
|
builder: *Builder,
|
|
883
918
|
layout: anytype,
|
|
@@ -1148,6 +1183,44 @@ pub fn mediaSurfacePlaceholderColor(surface_id: u64) Color {
|
|
|
1148
1183
|
);
|
|
1149
1184
|
}
|
|
1150
1185
|
|
|
1186
|
+
/// The video stream's reported dimensions for a contain-fitted media
|
|
1187
|
+
/// surface (`Widget.stream_size`, stamped by `Ui.stampVideoSurfaceFit`
|
|
1188
|
+
/// from the LOADED event's journaled report). Null until the
|
|
1189
|
+
/// dimensions are honestly known, so the fit math never runs on
|
|
1190
|
+
/// guessed or zero geometry — and only under `.contain`, the video
|
|
1191
|
+
/// surface's mode.
|
|
1192
|
+
fn mediaSurfaceStreamSize(widget: Widget) ?geometry.SizeF {
|
|
1193
|
+
if (widget.image_fit != .contain) return null;
|
|
1194
|
+
const size = widget.stream_size orelse return null;
|
|
1195
|
+
if (size.width <= 0 or size.height <= 0) return null;
|
|
1196
|
+
return size;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/// A letterbox bar extent below this is nothing to draw: the quad
|
|
1200
|
+
/// covers the frame on that axis (float wobble from centering math
|
|
1201
|
+
/// never conjures a phantom bar, and a full-frame quad keeps the
|
|
1202
|
+
/// frame's own corner radius).
|
|
1203
|
+
const media_surface_bar_epsilon: f32 = 0.001;
|
|
1204
|
+
|
|
1205
|
+
/// The tight rounded-rect mask for a fitted quad inset `bar` inside a
|
|
1206
|
+
/// frame corner of radius `corner`: `max(0, corner - bar)`. The mask's
|
|
1207
|
+
/// corner circle is then INTERNALLY TANGENT to the frame's corner
|
|
1208
|
+
/// circle (center distance equals the radius difference exactly), so
|
|
1209
|
+
/// the masked quad never paints outside the surface's rounded
|
|
1210
|
+
/// silhouette while removing the provable minimum of picture — any
|
|
1211
|
+
/// smaller radius leaks square corners past the silhouette, any larger
|
|
1212
|
+
/// notches more picture than the silhouette demands. Bars at or past
|
|
1213
|
+
/// the corner radius mask nothing (0): the quad's corners sit fully
|
|
1214
|
+
/// inside the straight-edged part of the frame.
|
|
1215
|
+
fn mediaSurfaceQuadRadius(radius: Radius, bar: f32) Radius {
|
|
1216
|
+
return .{
|
|
1217
|
+
.top_left = @max(0, radius.top_left - bar),
|
|
1218
|
+
.top_right = @max(0, radius.top_right - bar),
|
|
1219
|
+
.bottom_right = @max(0, radius.bottom_right - bar),
|
|
1220
|
+
.bottom_left = @max(0, radius.bottom_left - bar),
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1151
1224
|
/// The media surface: an id-derived placeholder fill with the surface's
|
|
1152
1225
|
/// externally produced texture composited over it. ONE display list
|
|
1153
1226
|
/// serves both renderers — the texture rides a `draw_image` whose
|
|
@@ -1157,33 +1230,200 @@ pub fn mediaSurfacePlaceholderColor(surface_id: u64) Color {
|
|
|
1157
1230
|
/// composite the real texture. `image_id` is the SURFACE id (0 = the
|
|
1158
1231
|
/// unbound sentinel: placeholder only, like an image leaf with id 0
|
|
1159
1232
|
/// draws nothing).
|
|
1233
|
+
///
|
|
1234
|
+
/// CONTAIN fit is the video-surface mode (`Ui` stamps it on every
|
|
1235
|
+
/// surface the video channel feeds): with the stream's reported
|
|
1236
|
+
/// dimensions known (`Widget.stream_size`), THIS emit computes the
|
|
1237
|
+
/// aspect-fitted quad — centered, letterboxed/pillarboxed — so every
|
|
1238
|
+
/// host composites the identical geometry with no fit math of its own.
|
|
1239
|
+
/// The fitted shape is three commands: a BLACK fill over the whole
|
|
1240
|
+
/// frame at the frame's own radius (the letterbox field, so the
|
|
1241
|
+
/// surface silhouette is exact by construction — no per-bar corner
|
|
1242
|
+
/// The terminal leaf: the widget's RESOLVED grid snapshot painted
|
|
1243
|
+
/// through the terminal grid painter — real text runs, geometric box
|
|
1244
|
+
/// drawing, selection, cursor, and the scrollback thumb, clipped to the
|
|
1245
|
+
/// frame and degrading row-atomically under the shared per-view budgets
|
|
1246
|
+
/// (`terminal_grid.widget_command_reserve` and friends hold back room
|
|
1247
|
+
/// for the widgets around it). Unbound — no session published a grid
|
|
1248
|
+
/// yet — it paints the honest empty surface: the theme background under
|
|
1249
|
+
/// the widget's frame, so a terminal awaiting its pty reads as an empty
|
|
1250
|
+
/// terminal, never a hole. Focus wears the house ring like every other
|
|
1251
|
+
/// focusable control.
|
|
1252
|
+
fn emitTerminalWidget(builder: *Builder, widget: Widget, tokens: DesignTokens, focused: bool) Error!void {
|
|
1253
|
+
const frame = widget.frame.normalized();
|
|
1254
|
+
if (frame.isEmpty()) return;
|
|
1255
|
+
if (widget.terminal.grid) |grid| {
|
|
1256
|
+
// The grid text region sits inside the widget's own padding
|
|
1257
|
+
// (the house inset when none is declared), on a full-bleed
|
|
1258
|
+
// background — one seamless surface edge to edge.
|
|
1259
|
+
const padding = widget.layout.padding;
|
|
1260
|
+
const declared = padding.left + padding.top + padding.right + padding.bottom > 0;
|
|
1261
|
+
const inset: geometry.InsetsF = if (declared) padding else geometry.InsetsF.all(8);
|
|
1262
|
+
const content = geometry.RectF.init(
|
|
1263
|
+
frame.x + inset.left,
|
|
1264
|
+
frame.y + inset.top,
|
|
1265
|
+
@max(0, frame.width - inset.left - inset.right),
|
|
1266
|
+
@max(0, frame.height - inset.top - inset.bottom),
|
|
1267
|
+
);
|
|
1268
|
+
// The command budget the grid degrades against: the builder's
|
|
1269
|
+
// capacity minus the reserve held back for the widgets around it.
|
|
1270
|
+
// When the whole builder is smaller than that reserve (a tiny
|
|
1271
|
+
// test buffer), there is no room to hold back for siblings, so
|
|
1272
|
+
// the grid gets the whole capacity — flooring to 1 instead would
|
|
1273
|
+
// fall under the painter's fixed prologue overhead and paint
|
|
1274
|
+
// nothing at all. Capacity is never 0 here (the frame is
|
|
1275
|
+
// non-empty), so this never hands the painter its unbounded (0)
|
|
1276
|
+
// mode.
|
|
1277
|
+
const capacity = builder.commands.len;
|
|
1278
|
+
const command_budget = if (capacity > canvas.terminal_grid.widget_command_reserve)
|
|
1279
|
+
capacity - canvas.terminal_grid.widget_command_reserve
|
|
1280
|
+
else
|
|
1281
|
+
capacity;
|
|
1282
|
+
try canvas.terminal_grid.paint(grid.*, builder, .{
|
|
1283
|
+
.frame = content,
|
|
1284
|
+
.background_frame = frame,
|
|
1285
|
+
.tokens = tokens,
|
|
1286
|
+
.focused = focused,
|
|
1287
|
+
.id_base = widget.id,
|
|
1288
|
+
.command_budget = command_budget,
|
|
1289
|
+
.text_reserve = canvas.terminal_grid.widget_text_reserve,
|
|
1290
|
+
.path_reserve = canvas.terminal_grid.widget_path_reserve,
|
|
1291
|
+
.glyph_budget = canvas.terminal_grid.widget_glyph_budget,
|
|
1292
|
+
});
|
|
1293
|
+
} else {
|
|
1294
|
+
try builder.fillRect(.{
|
|
1295
|
+
.id = widgetPartId(widget.id, 1),
|
|
1296
|
+
.rect = frame,
|
|
1297
|
+
.fill = colorFill(widget.style.background orelse tokens.colors.surface),
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
if (widget.state.focused) {
|
|
1301
|
+
// The ring id must be disjoint from whatever the surface below
|
|
1302
|
+
// emitted. A BOUND terminal's grid owns the painter's id space
|
|
1303
|
+
// (`paintIdBase(widget.id)` spread across the u64 range), which a
|
|
1304
|
+
// `widgetPartId(widget.id, 2)` ring can alias; take the ring from
|
|
1305
|
+
// the painter's own reserved offset so the two never collide. The
|
|
1306
|
+
// UNBOUND surface uses `widgetPartId(widget.id, 1)`, so its ring
|
|
1307
|
+
// stays the adjacent part slot.
|
|
1308
|
+
const ring_id = if (widget.terminal.grid != null)
|
|
1309
|
+
canvas.terminal_grid.paintIdBase(widget.id) +% canvas.terminal_grid.reserved_id_offset
|
|
1310
|
+
else
|
|
1311
|
+
widgetPartId(widget.id, 2);
|
|
1312
|
+
try builder.strokeRect(snapHairlineStrokeRect(tokens, .{
|
|
1313
|
+
.id = ring_id,
|
|
1314
|
+
.rect = widget_render_style.focusRingRect(frame, tokens),
|
|
1315
|
+
.radius = widget_render_style.focusRingRadius(widgetRadius(widget, 0), tokens),
|
|
1316
|
+
.stroke = .{
|
|
1317
|
+
.fill = widget_render_style.widgetFocusRingFill(widget, tokens),
|
|
1318
|
+
.width = tokens.stroke.focus,
|
|
1319
|
+
},
|
|
1320
|
+
}));
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/// approximation), the deterministic placeholder confined to the quad
|
|
1325
|
+
/// (goldens and replay screenshots, which skip the texture by policy,
|
|
1326
|
+
/// show the placeholder exactly where the picture goes, in the
|
|
1327
|
+
/// journaled-truth black field), and the picture quad — always the
|
|
1328
|
+
/// WHOLE frame at the stream's aspect (`image_src` crops do not apply
|
|
1329
|
+
/// here: see the coordinate-space teaching at the quad computation).
|
|
1330
|
+
/// Unknown dimensions (pre-LOADED) keep the plain full-frame
|
|
1331
|
+
/// placeholder draw: no guessed geometry, no divide-by-zero.
|
|
1160
1332
|
fn emitMediaSurfaceWidget(builder: *Builder, widget: Widget) Error!void {
|
|
1161
1333
|
if (widget.image_id == 0 or widget.frame.normalized().isEmpty()) return;
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1334
|
+
const frame = widget.frame.normalized();
|
|
1335
|
+
// The frame's EFFECTIVE corner radius: renderers clamp every corner
|
|
1336
|
+
// to half the rect's short side, so the tangent-mask math below must
|
|
1337
|
+
// start from the same value — an unbounded style radius (100 on a
|
|
1338
|
+
// 32x16 surface) otherwise derives an inset-quad mask far past the
|
|
1339
|
+
// real silhouette and renderers clamp THAT into a circular picture.
|
|
1340
|
+
const radius = Radius.all(std.math.clamp(
|
|
1341
|
+
widget.style.radius orelse 0,
|
|
1342
|
+
0,
|
|
1343
|
+
@min(frame.width, frame.height) * 0.5,
|
|
1344
|
+
));
|
|
1345
|
+
// The fitted quad, computed once here: one authority for the
|
|
1346
|
+
// geometry, always the STREAM's reported aspect. A declared
|
|
1347
|
+
// `image_src` crop does NOT ride the fitted draw: `DrawImage.src`
|
|
1348
|
+
// is adopted-TEXTURE pixel coordinates, and the video texture's
|
|
1349
|
+
// size is unknowable at emit time (macOS budget-fits large decodes
|
|
1350
|
+
// — a 3840x2160 stream lands as a smaller texture — so a
|
|
1351
|
+
// stream-coordinate crop cannot be translated here, and forwarding
|
|
1352
|
+
// it raw would sample the wrong region or nothing). Crops remain a
|
|
1353
|
+
// GENERIC-producer facility in texture coordinates; the video
|
|
1354
|
+
// surface always composites the whole frame.
|
|
1355
|
+
const stream_size = mediaSurfaceStreamSize(widget);
|
|
1356
|
+
const dst = if (stream_size) |size|
|
|
1357
|
+
canvas.containDestinationRect(frame, size.width, size.height)
|
|
1358
|
+
else
|
|
1359
|
+
frame;
|
|
1360
|
+
const draw_src = if (stream_size != null) null else widget.image_src;
|
|
1361
|
+
const letterboxed = frame.height - dst.height > media_surface_bar_epsilon;
|
|
1362
|
+
const pillarboxed = frame.width - dst.width > media_surface_bar_epsilon;
|
|
1363
|
+
const fitted = letterboxed or pillarboxed;
|
|
1364
|
+
const bar_extent = if (letterboxed)
|
|
1365
|
+
(frame.height - dst.height) * 0.5
|
|
1366
|
+
else if (pillarboxed)
|
|
1367
|
+
(frame.width - dst.width) * 0.5
|
|
1368
|
+
else
|
|
1369
|
+
0;
|
|
1370
|
+
const quad_radius = if (fitted) mediaSurfaceQuadRadius(radius, bar_extent) else radius;
|
|
1371
|
+
if (fitted) {
|
|
1372
|
+
// The letterbox field: black across the whole frame at the
|
|
1373
|
+
// frame's radius — the silhouette, exactly.
|
|
1374
|
+
try builder.fillRoundedRect(.{
|
|
1375
|
+
.id = widgetPartId(widget.id, 1),
|
|
1376
|
+
.rect = frame,
|
|
1377
|
+
.radius = radius,
|
|
1378
|
+
.fill = colorFill(Color.rgba8(0x00, 0x00, 0x00, 0xff)),
|
|
1379
|
+
});
|
|
1380
|
+
// The placeholder, confined to the quad under the picture
|
|
1381
|
+
// (same tight mask, so it tracks the picture's shape).
|
|
1382
|
+
try builder.fillRoundedRect(.{
|
|
1383
|
+
.id = widgetPartId(widget.id, 4),
|
|
1384
|
+
.rect = dst,
|
|
1385
|
+
.radius = quad_radius,
|
|
1386
|
+
.fill = colorFill(mediaSurfacePlaceholderColor(widget.image_id)),
|
|
1387
|
+
});
|
|
1388
|
+
} else {
|
|
1389
|
+
try builder.fillRoundedRect(.{
|
|
1390
|
+
.id = widgetPartId(widget.id, 1),
|
|
1391
|
+
.rect = frame,
|
|
1392
|
+
.radius = radius,
|
|
1393
|
+
.fill = colorFill(mediaSurfacePlaceholderColor(widget.image_id)),
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1169
1396
|
// Cover fit expands the drawn texture past the widget frame on one
|
|
1170
1397
|
// axis; the rectangular clip is what crops the overflow — exactly
|
|
1171
1398
|
// emitImageWidget's cover clip. The draw's own radius mask below is
|
|
1172
1399
|
// NOT a substitute: hosts that only mask radii paint a zero-radius
|
|
1173
|
-
// cover surface outside its bounds, over its siblings.
|
|
1400
|
+
// cover surface outside its bounds, over its siblings. (Cover and
|
|
1401
|
+
// the fitted path are mutually exclusive: stream geometry rides
|
|
1402
|
+
// only `.contain` surfaces.)
|
|
1174
1403
|
const clips_image = widget.image_fit == .cover;
|
|
1175
|
-
if (clips_image) try builder.pushClip(.{ .id = widgetPartId(widget.id, 3), .rect =
|
|
1404
|
+
if (clips_image) try builder.pushClip(.{ .id = widgetPartId(widget.id, 3), .rect = frame });
|
|
1176
1405
|
try builder.drawImage(.{
|
|
1177
1406
|
.id = widgetPartId(widget.id, 2),
|
|
1178
1407
|
.image_id = canvas.mediaSurfaceTextureImageId(widget.image_id),
|
|
1179
|
-
.src =
|
|
1180
|
-
.dst =
|
|
1408
|
+
.src = draw_src,
|
|
1409
|
+
.dst = dst,
|
|
1181
1410
|
.opacity = widget.image_opacity,
|
|
1182
|
-
|
|
1411
|
+
// Known geometry draws STRETCH: the quad is the fit, computed
|
|
1412
|
+
// once from the reported dimensions. A
|
|
1413
|
+
// second host-side contain against the real texture would open
|
|
1414
|
+
// sub-pixel seams whenever a decoder's true dimensions round
|
|
1415
|
+
// off the report (macOS floors scaled decode sizes); the
|
|
1416
|
+
// sub-percent aspect nudge stretch absorbs is invisible, the
|
|
1417
|
+
// seam is not — and any residue lands on the black field, not
|
|
1418
|
+
// a colored fringe. Without known geometry the widget's own
|
|
1419
|
+
// fit passes through.
|
|
1420
|
+
.fit = if (stream_size != null) .stretch else widget.image_fit,
|
|
1183
1421
|
.sampling = widget.image_sampling,
|
|
1184
1422
|
// The render plan flattens clip stacks to rects, so a rounded
|
|
1185
|
-
// surface masks on the draw itself (the avatar convention)
|
|
1186
|
-
|
|
1423
|
+
// surface masks on the draw itself (the avatar convention); a
|
|
1424
|
+
// fitted quad carries the TIGHT inset mask
|
|
1425
|
+
// (`mediaSurfaceQuadRadius`), tangent to the silhouette.
|
|
1426
|
+
.radius = quad_radius,
|
|
1187
1427
|
});
|
|
1188
1428
|
if (clips_image) try builder.popClip();
|
|
1189
1429
|
}
|
|
@@ -2555,6 +2795,20 @@ fn widgetWithRenderState(widget: Widget, state: WidgetRenderState) Widget {
|
|
|
2555
2795
|
return copy;
|
|
2556
2796
|
}
|
|
2557
2797
|
|
|
2798
|
+
/// The terminal cursor follows logical keyboard focus, not merely
|
|
2799
|
+
/// focus-visible: the outer ring is a modality affordance, while the
|
|
2800
|
+
/// filled-vs-hollow cursor answers whether typed bytes go to this pty.
|
|
2801
|
+
/// With no runtime state, a baked focused widget remains the static
|
|
2802
|
+
/// scene/test source of truth.
|
|
2803
|
+
fn widgetHasLogicalFocus(widget: Widget, state: WidgetRenderState) bool {
|
|
2804
|
+
if (!state.keyboard_active) return false;
|
|
2805
|
+
if (state.focused_id != null or state.focus_visible_id != null) {
|
|
2806
|
+
const focused_id = state.focused_id orelse return false;
|
|
2807
|
+
return widget.id != 0 and widget.id == focused_id;
|
|
2808
|
+
}
|
|
2809
|
+
return widget.state.focused;
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2558
2812
|
fn accordionChildrenVisible(widget: Widget) bool {
|
|
2559
2813
|
return widget.kind != .accordion or booleanControlSelected(widget);
|
|
2560
2814
|
}
|