@native-sdk/cli 0.5.0 → 0.5.2
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 +198 -13
- package/build/ts_run.mjs +58 -19
- package/build.zig +42 -0
- package/package.json +13 -9
- package/packages/core/package-lock.json +4 -3
- package/packages/core/package.json +3 -2
- package/packages/core/src/typed_ast.ts +11 -1
- package/skill-data/native-ui/SKILL.md +2 -2
- package/src/platform/types.zig +9 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/tokens.zig +185 -7
- package/src/primitives/canvas/ui.zig +27 -5
- package/src/primitives/canvas/ui_markup.zig +27 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +47 -0
- package/src/primitives/canvas/ui_markup_view.zig +10 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +78 -0
- package/src/primitives/canvas/ui_schema.zig +15 -1
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +439 -5
- package/src/primitives/canvas/widget_layout.zig +142 -3
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +12 -0
- package/src/runtime/automation_widget_dispatch.zig +95 -28
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_events.zig +1271 -3
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +82 -5
- package/src/runtime/core.zig +30 -0
- package/src/runtime/effects.zig +1037 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/flow.zig +24 -1
- package/src/runtime/gpu_surface_events.zig +44 -5
- package/src/runtime/session_journal.zig +25 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +453 -0
- package/src/runtime/ui_app.zig +137 -39
- package/src/runtime/ui_app_tests.zig +681 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view.zig +86 -0
- package/src/runtime/view_widget_text.zig +18 -1
- package/src/runtime/view_widget_tree.zig +339 -20
- package/src/runtime/widget_bridge.zig +26 -0
- package/src/runtime/window_storage.zig +61 -15
- package/src/runtime/window_view_runtime.zig +13 -0
- package/src/runtime/window_views.zig +6 -0
- package/src/tooling/package.zig +311 -8
- package/src/tooling/templates.zig +97 -9
- package/src/tooling/ts_core.zig +626 -13
- package/src/tooling/verbs.zig +88 -2
|
@@ -716,6 +716,84 @@ test "resize-duration and resize-easing on split stamp the layout-tween declarat
|
|
|
716
716
|
try testing.expectEqual(canvas.Easing.standard, plain.resize_easing);
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
+
test "anchor and tooltip-delay on tooltip stamp the hover-intent declaration" {
|
|
720
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
721
|
+
defer arena_state.deinit();
|
|
722
|
+
const arena = arena_state.allocator();
|
|
723
|
+
const model = Model{};
|
|
724
|
+
|
|
725
|
+
// An anchored tooltip declaring its own delay, an anchored tooltip
|
|
726
|
+
// on the token default, and a bare static tooltip that keeps the
|
|
727
|
+
// classic paints-when-rendered leaf — so existing documents lower
|
|
728
|
+
// byte-identically.
|
|
729
|
+
var view = try InboxMarkup.init(arena, "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"250\">Bold the selection</tooltip>\n </stack>\n <stack>\n <text>Link</text>\n <tooltip anchor=\"below\">Insert a link</tooltip>\n </stack>\n <tooltip>Copied!</tooltip>\n</column>");
|
|
730
|
+
var ui = InboxUi.init(arena);
|
|
731
|
+
const tree = try ui.finalize(try view.build(&ui, &model));
|
|
732
|
+
|
|
733
|
+
const declared = findByText(tree.root, .tooltip, "Bold the selection").?;
|
|
734
|
+
try testing.expectEqual(@as(i32, 250), declared.tooltip_delay_ms);
|
|
735
|
+
try testing.expectEqual(canvas.WidgetAnchorPlacement.above, declared.layout.anchor.?.placement);
|
|
736
|
+
|
|
737
|
+
const defaulted = findByText(tree.root, .tooltip, "Insert a link").?;
|
|
738
|
+
try testing.expectEqual(@as(i32, -1), defaulted.tooltip_delay_ms);
|
|
739
|
+
try testing.expectEqual(canvas.WidgetAnchorPlacement.below, defaulted.layout.anchor.?.placement);
|
|
740
|
+
|
|
741
|
+
const static = findByText(tree.root, .tooltip, "Copied!").?;
|
|
742
|
+
try testing.expectEqual(@as(i32, -1), static.tooltip_delay_ms);
|
|
743
|
+
try testing.expectEqual(@as(?canvas.WidgetAnchor, null), static.layout.anchor);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
test "tooltip-delay past i32 max fails the build instead of trapping" {
|
|
747
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
748
|
+
defer arena_state.deinit();
|
|
749
|
+
const arena = arena_state.allocator();
|
|
750
|
+
const model = Model{};
|
|
751
|
+
|
|
752
|
+
// One past maxInt(i32): the option field's own type is the bound,
|
|
753
|
+
// so the cast that used to trap is now the grid-lines teaching
|
|
754
|
+
// error. The value parses fine as a 64-bit literal — the failure
|
|
755
|
+
// must come from the attribute seam, not the expression parser.
|
|
756
|
+
var overflow_view = try InboxMarkup.init(arena, "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"2147483648\">Bold the selection</tooltip>\n </stack>\n</column>");
|
|
757
|
+
var overflow_ui = InboxUi.init(arena);
|
|
758
|
+
try testing.expectError(error.MarkupBuild, overflow_view.build(&overflow_ui, &model));
|
|
759
|
+
try testing.expectEqualStrings("expected a non-negative whole number", overflow_view.diagnostic.message);
|
|
760
|
+
|
|
761
|
+
// Boundary values pass: 0 (the instant-show escape hatch) and the
|
|
762
|
+
// type's exact max.
|
|
763
|
+
var boundary_view = try InboxMarkup.init(arena, "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"0\">Bold the selection</tooltip>\n </stack>\n <stack>\n <text>Link</text>\n <tooltip anchor=\"below\" tooltip-delay=\"2147483647\">Insert a link</tooltip>\n </stack>\n</column>");
|
|
764
|
+
var boundary_ui = InboxUi.init(arena);
|
|
765
|
+
const tree = try boundary_ui.finalize(try boundary_view.build(&boundary_ui, &model));
|
|
766
|
+
try testing.expectEqual(@as(i32, 0), findByText(tree.root, .tooltip, "Bold the selection").?.tooltip_delay_ms);
|
|
767
|
+
try testing.expectEqual(@as(i32, std.math.maxInt(i32)), findByText(tree.root, .tooltip, "Insert a link").?.tooltip_delay_ms);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
test "tooltip-delay model binding past i32 max fails the build instead of trapping" {
|
|
771
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
772
|
+
defer arena_state.deinit();
|
|
773
|
+
const arena = arena_state.allocator();
|
|
774
|
+
|
|
775
|
+
// Bindings deliver i64 model values straight into the same cast
|
|
776
|
+
// seam the literal path uses, so an out-of-range model value must
|
|
777
|
+
// produce the same teaching error — per-build, since only the
|
|
778
|
+
// value (not the document) is wrong.
|
|
779
|
+
const DelayModel = struct { delay: i64 = 0 };
|
|
780
|
+
const DelayMarkup = markup_view.MarkupView(DelayModel, Msg);
|
|
781
|
+
const source = "<column>\n <stack>\n <text>Bold</text>\n <tooltip anchor=\"above\" tooltip-delay=\"{delay}\">Bold the selection</tooltip>\n </stack>\n</column>";
|
|
782
|
+
|
|
783
|
+
var overflow_view = try DelayMarkup.init(arena, source);
|
|
784
|
+
var overflow_ui = InboxUi.init(arena);
|
|
785
|
+
const overflow_model = DelayModel{ .delay = @as(i64, std.math.maxInt(i32)) + 1 };
|
|
786
|
+
try testing.expectError(error.MarkupBuild, overflow_view.build(&overflow_ui, &overflow_model));
|
|
787
|
+
try testing.expectEqualStrings("expected a non-negative whole number", overflow_view.diagnostic.message);
|
|
788
|
+
|
|
789
|
+
// The same document lowers when the model holds an in-range value.
|
|
790
|
+
var ok_view = try DelayMarkup.init(arena, source);
|
|
791
|
+
var ok_ui = InboxUi.init(arena);
|
|
792
|
+
const ok_model = DelayModel{ .delay = 250 };
|
|
793
|
+
const tree = try ok_ui.finalize(try ok_view.build(&ok_ui, &ok_model));
|
|
794
|
+
try testing.expectEqual(@as(i32, 250), findByText(tree.root, .tooltip, "Bold the selection").?.tooltip_delay_ms);
|
|
795
|
+
}
|
|
796
|
+
|
|
719
797
|
test "resize-easing value vocabulary mirrors the live Easing enum" {
|
|
720
798
|
// The validator's std-only mirror of the enum's member names; a new
|
|
721
799
|
// member cannot ship without its markup spelling.
|
|
@@ -249,7 +249,13 @@ pub const elements = [_]ElementInfo{
|
|
|
249
249
|
.{ .code = 36, .name = "switch", .widget_kind = "switch_control", .takes_text = true, .a11y_name = .control },
|
|
250
250
|
.{ .code = 37, .name = "table-cell", .widget_kind = "data_cell", .takes_text = true },
|
|
251
251
|
.{ .code = 38, .name = "toggle-button", .widget_kind = "toggle_button", .takes_text = true, .icon_attr = true, .a11y_name = .control },
|
|
252
|
-
|
|
252
|
+
// Tooltip is anchorable: `anchor="above|below"` floats it against
|
|
253
|
+
// its PARENT's frame (the trigger, or the stack wrapping trigger +
|
|
254
|
+
// tooltip), and the RUNTIME owns its visibility — hidden until the
|
|
255
|
+
// hover-intent delay on the trigger fires (see `tooltip-delay`).
|
|
256
|
+
// Without `anchor` it stays the classic static text leaf that
|
|
257
|
+
// paints whenever the view renders it.
|
|
258
|
+
.{ .code = 39, .name = "tooltip", .widget_kind = "tooltip", .takes_text = true, .hit_target = false, .anchorable = true },
|
|
253
259
|
// Value controls and text entry.
|
|
254
260
|
.{ .code = 40, .name = "checkbox", .widget_kind = "checkbox", .a11y_name = .control },
|
|
255
261
|
.{ .code = 41, .name = "radio", .widget_kind = "radio", .a11y_name = .control },
|
|
@@ -450,6 +456,14 @@ pub const attrs = [_]AttrInfo{
|
|
|
450
456
|
// silently inert). No `field`: the engines apply it to
|
|
451
457
|
// `ElementOptions.style`, not a flat option field.
|
|
452
458
|
.{ .code = 79, .name = "quiet-hover", .class = .flag, .group = .option },
|
|
459
|
+
// Hover-intent show delay for ANCHORED tooltips (tooltip only, and
|
|
460
|
+
// only beside `anchor`; the validator scopes both), in whole
|
|
461
|
+
// milliseconds. The runtime shows an anchored tooltip after its
|
|
462
|
+
// trigger has been hovered this long on the recorded frame clock —
|
|
463
|
+
// 0 shows the instant the trigger is hovered. Negative is
|
|
464
|
+
// unreachable from markup; absent keeps the token default
|
|
465
|
+
// (`ControlMetricTokens.tooltip_show_delay_ms`).
|
|
466
|
+
.{ .code = 80, .name = "tooltip-delay", .class = .whole, .group = .option, .field = "tooltip_delay" },
|
|
453
467
|
};
|
|
454
468
|
|
|
455
469
|
// ----------------------------------------------------------------- events
|
|
@@ -22,7 +22,7 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
22
22
|
// the new fingerprint ONLY for additions; renames/renumbers are
|
|
23
23
|
// schema-version-bump events, not silent edits.
|
|
24
24
|
try testing.expectEqual(@as(usize, 65), schema.elements.len);
|
|
25
|
-
try testing.expectEqual(@as(usize,
|
|
25
|
+
try testing.expectEqual(@as(usize, 80), schema.attrs.len);
|
|
26
26
|
try testing.expectEqual(@as(usize, 10), schema.events.len);
|
|
27
27
|
// The element table runs through the span composite (64) and the
|
|
28
28
|
// bubble-reactions composite (65); the reaction pill's dock rides
|
|
@@ -36,10 +36,11 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
36
36
|
// resize-duration (71) and resize-easing (72), the chart axis/hover
|
|
37
37
|
// attributes x-labels (73), y-labels (74), and hover-details (75),
|
|
38
38
|
// the later span additions scale (76) and underline (77), the
|
|
39
|
-
// split enter-from attribute resize-origin (78),
|
|
40
|
-
//
|
|
39
|
+
// split enter-from attribute resize-origin (78), the quiet-surface
|
|
40
|
+
// hover knob quiet-hover (79), and the anchored-tooltip hover-intent
|
|
41
|
+
// delay tooltip-delay (80).
|
|
41
42
|
try testing.expectEqual(
|
|
42
|
-
@as(u64,
|
|
43
|
+
@as(u64, 0x5348b0f92c314d2a),
|
|
43
44
|
tableFingerprint(schema.AttrInfo, &schema.attrs),
|
|
44
45
|
);
|
|
45
46
|
try testing.expectEqual(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const support = @import("test_support.zig");
|
|
2
|
+
const widget_metrics = @import("widget_metrics.zig");
|
|
2
3
|
const std = support.std;
|
|
3
4
|
const geometry = support.geometry;
|
|
4
5
|
const canvas = support.canvas;
|
|
@@ -1414,6 +1415,136 @@ test "design tokens provide theme and contrast palettes" {
|
|
|
1414
1415
|
try std.testing.expectEqual(Easing.linear, reduced_motion.motion.easing);
|
|
1415
1416
|
}
|
|
1416
1417
|
|
|
1418
|
+
test "the accent override desaturates its dark-scheme focus ring" {
|
|
1419
|
+
const accent = Color.rgb8(223, 38, 112);
|
|
1420
|
+
|
|
1421
|
+
// Light keeps the raw accent on every identity slot, ring included.
|
|
1422
|
+
const light = canvas.accentOverrides(accent, .light);
|
|
1423
|
+
try std.testing.expectEqualDeep(accent, light.colors.accent.?);
|
|
1424
|
+
try std.testing.expectEqualDeep(accent, light.colors.focus_ring.?);
|
|
1425
|
+
|
|
1426
|
+
// Dark keeps the accent identity but derives the ring at half the
|
|
1427
|
+
// accent's HSL saturation — a quiet outline instead of a neon glare
|
|
1428
|
+
// — through the exported derivation, so hand-authored token sets
|
|
1429
|
+
// can state the same value.
|
|
1430
|
+
const dark = canvas.accentOverrides(accent, .dark);
|
|
1431
|
+
try std.testing.expectEqualDeep(accent, dark.colors.accent.?);
|
|
1432
|
+
const ring = dark.colors.focus_ring.?;
|
|
1433
|
+
try std.testing.expectEqualDeep(canvas.accentFocusRing(accent, .dark), ring);
|
|
1434
|
+
try std.testing.expect(!std.meta.eql(accent, ring));
|
|
1435
|
+
// Same lightness (HSL max+min preserved), lower chroma: the channel
|
|
1436
|
+
// spread shrinks to half while the hue's ordering holds.
|
|
1437
|
+
const accent_spread = @max(accent.r, @max(accent.g, accent.b)) - @min(accent.r, @min(accent.g, accent.b));
|
|
1438
|
+
const ring_spread = @max(ring.r, @max(ring.g, ring.b)) - @min(ring.r, @min(ring.g, ring.b));
|
|
1439
|
+
try std.testing.expect(ring_spread < accent_spread);
|
|
1440
|
+
try std.testing.expect(ring.r > ring.b and ring.b > ring.g);
|
|
1441
|
+
|
|
1442
|
+
// An achromatic accent has no saturation to halve: the ring passes
|
|
1443
|
+
// through untouched.
|
|
1444
|
+
const gray = Color.rgb8(115, 115, 115);
|
|
1445
|
+
try std.testing.expectEqualDeep(gray, canvas.accentFocusRing(gray, .dark));
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
test "the dark accent focus ring holds the non-text contrast floor across hues" {
|
|
1449
|
+
// Rings draw OUTSIDE controls, so the tones that matter are the
|
|
1450
|
+
// dark containers controls commonly sit on, across BOTH shipped
|
|
1451
|
+
// packs: page background, card/popover surface, and the muted
|
|
1452
|
+
// surface (the tabs-list pill container focusable triggers sit
|
|
1453
|
+
// inside). accentFocusRing floors against the LIGHTEST of these
|
|
1454
|
+
// (house surface_subtle #262626) — a ring clearing 3:1 there
|
|
1455
|
+
// clears every darker tone in the set too; each is asserted below.
|
|
1456
|
+
const house_dark = DesignTokens.theme(.{ .color_scheme = .dark }).colors;
|
|
1457
|
+
const geist_dark = DesignTokens.theme(.{ .pack = .geist, .color_scheme = .dark }).colors;
|
|
1458
|
+
const adjacent_tones = [_]Color{
|
|
1459
|
+
house_dark.background, // #0a0a0a
|
|
1460
|
+
house_dark.surface, // #171717
|
|
1461
|
+
house_dark.surface_subtle, // #262626 — the floor's reference
|
|
1462
|
+
geist_dark.background, // #000000 (Geist surface is the same black)
|
|
1463
|
+
geist_dark.surface_subtle, // #1a1a1a
|
|
1464
|
+
};
|
|
1465
|
+
const reference_tone = house_dark.surface_subtle;
|
|
1466
|
+
const cases = [_]Color{
|
|
1467
|
+
// Green: the input clears 3:1 on the background AND the card
|
|
1468
|
+
// surface; desaturation alone dropped to ~2.6:1 on the
|
|
1469
|
+
// background (worse still on the surface) — the floor lifts it
|
|
1470
|
+
// back over the bar on both. Against the muted reference the
|
|
1471
|
+
// input itself sits just under 3:1 (~2.94), so the ring holds
|
|
1472
|
+
// exactly that there — restored, never invented.
|
|
1473
|
+
Color.rgb8(0, 128, 0),
|
|
1474
|
+
// Deep blue: below 3:1 on its own; the ring must not get worse.
|
|
1475
|
+
Color.rgb8(0, 0, 204),
|
|
1476
|
+
// Dark red: below 3:1 on its own AND desaturation costs more —
|
|
1477
|
+
// the floor restores the accent's own contrast, no further.
|
|
1478
|
+
Color.rgb8(139, 0, 0),
|
|
1479
|
+
// The soundboard pink: clears the bar before and after halving.
|
|
1480
|
+
Color.rgb8(223, 38, 112),
|
|
1481
|
+
// Achromatic gray: nothing to desaturate, passes through.
|
|
1482
|
+
Color.rgb8(115, 115, 115),
|
|
1483
|
+
};
|
|
1484
|
+
for (cases) |accent| {
|
|
1485
|
+
// Light passes the accent through untouched, every hue.
|
|
1486
|
+
try std.testing.expectEqualDeep(accent, canvas.accentFocusRing(accent, .light));
|
|
1487
|
+
|
|
1488
|
+
const ring = canvas.accentFocusRing(accent, .dark);
|
|
1489
|
+
// Dark never raises saturation; chromatic accents lose half.
|
|
1490
|
+
const accent_saturation = testHslSaturation(accent);
|
|
1491
|
+
const ring_saturation = testHslSaturation(ring);
|
|
1492
|
+
if (accent_saturation > 0) {
|
|
1493
|
+
try std.testing.expect(ring_saturation < accent_saturation);
|
|
1494
|
+
} else {
|
|
1495
|
+
try std.testing.expectEqualDeep(accent, ring);
|
|
1496
|
+
}
|
|
1497
|
+
// The floor, tone by tone: >= 3:1 (WCAG non-text) against EVERY
|
|
1498
|
+
// adjacent tone the accent itself cleared it on. Flooring
|
|
1499
|
+
// against the lightest tone guarantees the rest: where the
|
|
1500
|
+
// accent cleared 3:1 anywhere, the ring's luminance lands at or
|
|
1501
|
+
// above the accent's, so no darker tone can regress.
|
|
1502
|
+
for (adjacent_tones) |tone| {
|
|
1503
|
+
if (testContrastRatio(accent, tone) >= 3.0) {
|
|
1504
|
+
try std.testing.expect(testContrastRatio(ring, tone) >= 3.0);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
// The escape hatch, stated against the SAME reference the floor
|
|
1508
|
+
// measures on: when the accent never cleared 3:1 there, the
|
|
1509
|
+
// ring still never lands below the accent's own contrast.
|
|
1510
|
+
const accent_contrast = testContrastRatio(accent, reference_tone);
|
|
1511
|
+
const ring_contrast = testContrastRatio(ring, reference_tone);
|
|
1512
|
+
if (accent_contrast >= 3.0) {
|
|
1513
|
+
try std.testing.expect(ring_contrast >= 3.0);
|
|
1514
|
+
} else {
|
|
1515
|
+
try std.testing.expect(ring_contrast >= accent_contrast);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
/// HSL saturation of a color, for the desaturation assertions.
|
|
1521
|
+
fn testHslSaturation(color: Color) f32 {
|
|
1522
|
+
const max = @max(color.r, @max(color.g, color.b));
|
|
1523
|
+
const min = @min(color.r, @min(color.g, color.b));
|
|
1524
|
+
const delta = max - min;
|
|
1525
|
+
if (delta <= 0.0001) return 0;
|
|
1526
|
+
const lightness = (max + min) / 2;
|
|
1527
|
+
return delta / (1 - @abs(2 * lightness - 1));
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
/// WCAG contrast ratio between two colors, for the floor assertions.
|
|
1531
|
+
fn testContrastRatio(a: Color, b: Color) f32 {
|
|
1532
|
+
const la = testRelativeLuminance(a);
|
|
1533
|
+
const lb = testRelativeLuminance(b);
|
|
1534
|
+
return (@max(la, lb) + 0.05) / (@min(la, lb) + 0.05);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
fn testRelativeLuminance(color: Color) f32 {
|
|
1538
|
+
return 0.2126 * testSrgbToLinear(color.r) +
|
|
1539
|
+
0.7152 * testSrgbToLinear(color.g) +
|
|
1540
|
+
0.0722 * testSrgbToLinear(color.b);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
fn testSrgbToLinear(channel: f32) f32 {
|
|
1544
|
+
if (channel <= 0.04045) return channel / 12.92;
|
|
1545
|
+
return std.math.pow(f32, (channel + 0.055) / 1.055, 2.4);
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1417
1548
|
test "built-in component catalog covers house component set" {
|
|
1418
1549
|
const expected_names = [_][]const u8{
|
|
1419
1550
|
"Accordion",
|
|
@@ -3116,10 +3247,11 @@ test "themed design tokens flow into widget display lists" {
|
|
|
3116
3247
|
}
|
|
3117
3248
|
|
|
3118
3249
|
test "widget text at intrinsic width does not wrap under geometry pixel snapping" {
|
|
3119
|
-
// Geometry snapping can shave up to
|
|
3120
|
-
// that intrinsic sizing measured
|
|
3121
|
-
//
|
|
3122
|
-
//
|
|
3250
|
+
// Geometry snapping can shave up to a full device pixel off the frame
|
|
3251
|
+
// that intrinsic sizing measured (each edge rounds independently by
|
|
3252
|
+
// up to half); the text emitter hands the snap quantum back to the
|
|
3253
|
+
// wrap budget so an exact-fit label ("Sort") never breaks into
|
|
3254
|
+
// "Sor"/"t". Regression for the snapped-frame wrap
|
|
3123
3255
|
// seam surfaced when the estimator became the bundled face's real
|
|
3124
3256
|
// advance table.
|
|
3125
3257
|
const scales = [_]f32{ 1, 2 };
|
|
@@ -3153,7 +3285,7 @@ test "widget text at intrinsic width does not wrap under geometry pixel snapping
|
|
|
3153
3285
|
test "label-exact controls at intrinsic width never elide under geometry pixel snapping" {
|
|
3154
3286
|
// The elision twin of the wrap seam above: a control sized exactly
|
|
3155
3287
|
// to its measured label sits at a fractional width, and render-time
|
|
3156
|
-
// geometry snapping can shave up to
|
|
3288
|
+
// geometry snapping can shave up to a full device pixel off that
|
|
3157
3289
|
// frame — past the elision slack, so real glyphs swap for an
|
|
3158
3290
|
// ellipsis (system monitor's "PID" sort chip painting "PI…").
|
|
3159
3291
|
// Intrinsic measured-label widths now ceil to the snap grid
|
|
@@ -3202,6 +3334,308 @@ test "label-exact controls at intrinsic width never elide under geometry pixel s
|
|
|
3202
3334
|
}
|
|
3203
3335
|
}
|
|
3204
3336
|
|
|
3337
|
+
test "a string never elides inside its own measured width under edge snapping" {
|
|
3338
|
+
// The measurement/ellipsize epsilon policy (see `textWrapMaxWidth`):
|
|
3339
|
+
// geometry snapping rounds each frame edge independently, so a frame
|
|
3340
|
+
// sized exactly to its measured text and sitting at a fractional
|
|
3341
|
+
// position can come back up to a FULL device pixel narrower — the
|
|
3342
|
+
// budget hands that whole quantum back, and the elision slack covers
|
|
3343
|
+
// the residual float dust. Sweep fractional origins across the snap
|
|
3344
|
+
// cell for every digit (the TS scaffold's counter, which painted "…"
|
|
3345
|
+
// instead of "2" on Windows at scale 1) plus longer labels, at every
|
|
3346
|
+
// real scale factor.
|
|
3347
|
+
const scales = [_]f32{ 1, 1.25, 1.5, 2 };
|
|
3348
|
+
const labels = [_][]const u8{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "ticks 7", "Sampling 60 s cadence" };
|
|
3349
|
+
const size: f32 = 14;
|
|
3350
|
+
for (scales) |scale| {
|
|
3351
|
+
const tokens = DesignTokens{ .pixel_snap = .{ .geometry = true, .text = true, .scale = scale } };
|
|
3352
|
+
for (labels) |label| {
|
|
3353
|
+
const measured = canvas.estimateTextWidthForFont(default_sans_font_id, label, size);
|
|
3354
|
+
var step: usize = 0;
|
|
3355
|
+
while (step < 32) : (step += 1) {
|
|
3356
|
+
const origin = 235 + @as(f32, @floatFromInt(step)) / 32.0;
|
|
3357
|
+
// Snap both edges exactly like the renderer's
|
|
3358
|
+
// `pixelSnapGeometryRect` does.
|
|
3359
|
+
const left = @round(origin * scale) / scale;
|
|
3360
|
+
const right = @round((origin + measured) * scale) / scale;
|
|
3361
|
+
const snapped_width = @max(0, right - left);
|
|
3362
|
+
var lines: [2]TextLine = undefined;
|
|
3363
|
+
const layout = try canvas.layoutTextRun(.{
|
|
3364
|
+
.id = 1,
|
|
3365
|
+
.font_id = default_sans_font_id,
|
|
3366
|
+
.size = size,
|
|
3367
|
+
.origin = geometry.PointF.init(left, 20),
|
|
3368
|
+
.color = Color.rgb8(0, 0, 0),
|
|
3369
|
+
.text = label,
|
|
3370
|
+
}, .{
|
|
3371
|
+
.max_width = widget_metrics.textWrapMaxWidth(tokens, snapped_width),
|
|
3372
|
+
.wrap = .none,
|
|
3373
|
+
.overflow = .ellipsis,
|
|
3374
|
+
}, &lines);
|
|
3375
|
+
try std.testing.expectEqual(@as(usize, 1), layout.lineCount());
|
|
3376
|
+
for (layout.lines) |line| try std.testing.expect(!line.isElided());
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
test "hug-sized centered text leaf never elides under geometry pixel snapping" {
|
|
3383
|
+
// The widget-level twin of the sweep above, in the exact scaffold
|
|
3384
|
+
// shape that surfaced it: `<row main="center">` centers a hug-sized
|
|
3385
|
+
// digit between two buttons, landing BOTH its frame edges on
|
|
3386
|
+
// fractional thirds — the left edge snaps up, the right edge snaps
|
|
3387
|
+
// down, and the frame loses more than the old half-pixel hand-back.
|
|
3388
|
+
const digits = [_][]const u8{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
3389
|
+
const scales = [_]f32{ 1, 1.25, 1.5, 2 };
|
|
3390
|
+
for (scales) |scale| {
|
|
3391
|
+
const tokens = DesignTokens{ .pixel_snap = .{ .geometry = true, .text = true, .scale = scale } };
|
|
3392
|
+
for (digits) |digit| {
|
|
3393
|
+
const minus = Widget{ .id = 2, .kind = .button, .text = "-" };
|
|
3394
|
+
const count = Widget{ .id = 3, .kind = .text, .text = digit };
|
|
3395
|
+
const plus = Widget{ .id = 4, .kind = .button, .text = "+" };
|
|
3396
|
+
const children = [_]Widget{ minus, count, plus };
|
|
3397
|
+
const row = Widget{ .id = 1, .kind = .row, .layout = .{
|
|
3398
|
+
.gap = 8,
|
|
3399
|
+
.main_alignment = .center,
|
|
3400
|
+
.cross_alignment = .center,
|
|
3401
|
+
}, .children = &children };
|
|
3402
|
+
|
|
3403
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
3404
|
+
const layout = try canvas.layoutWidgetTreeWithTokens(row, geometry.RectF.init(16, 56, 448, 164), tokens, &nodes);
|
|
3405
|
+
|
|
3406
|
+
var commands: [16]CanvasCommand = undefined;
|
|
3407
|
+
var builder = Builder.init(&commands);
|
|
3408
|
+
try canvas.emitWidgetLayout(&builder, layout, tokens);
|
|
3409
|
+
var seen = false;
|
|
3410
|
+
for (builder.displayList().commands) |command| switch (command) {
|
|
3411
|
+
.draw_text => |text| {
|
|
3412
|
+
if (!std.mem.eql(u8, text.text, digit)) continue;
|
|
3413
|
+
seen = true;
|
|
3414
|
+
var lines: [2]TextLine = undefined;
|
|
3415
|
+
const text_layout = try canvas.layoutTextRun(text, text.text_layout.?, &lines);
|
|
3416
|
+
for (text_layout.lines) |line| try std.testing.expect(!line.isElided());
|
|
3417
|
+
},
|
|
3418
|
+
else => {},
|
|
3419
|
+
};
|
|
3420
|
+
try std.testing.expect(seen);
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
test "window-control clearance trims drag-header content on the cluster's side" {
|
|
3426
|
+
// The engine half of the hidden-titlebar caption fix: when the
|
|
3427
|
+
// runtime stamps the OS window-control cluster into the tokens, a
|
|
3428
|
+
// `window_drag` row lays its content out clear of it — trailing
|
|
3429
|
+
// cluster (Windows caption buttons) trims the content box's end,
|
|
3430
|
+
// leading cluster (macOS traffic lights) its start. Non-drag rows
|
|
3431
|
+
// never move.
|
|
3432
|
+
const spacer = Widget{ .id = 2, .kind = .stack, .layout = .{ .grow = 1 } };
|
|
3433
|
+
const status = Widget{ .id = 3, .kind = .text, .text = "sampling" };
|
|
3434
|
+
const children = [_]Widget{ spacer, status };
|
|
3435
|
+
var row = Widget{ .id = 1, .kind = .row, .layout = .{ .cross_alignment = .center }, .children = &children };
|
|
3436
|
+
row.window_drag = true;
|
|
3437
|
+
const bounds = geometry.RectF.init(0, 0, 400, 40);
|
|
3438
|
+
|
|
3439
|
+
// Trailing cluster: content ends at its leading edge.
|
|
3440
|
+
const trailing_tokens = DesignTokens{ .window_controls = geometry.RectF.init(262, 0, 138, 32) };
|
|
3441
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
3442
|
+
var layout = try canvas.layoutWidgetTreeWithTokens(row, bounds, trailing_tokens, &nodes);
|
|
3443
|
+
try std.testing.expect(layout.findById(3).?.frame.maxX() <= 262 + 0.01);
|
|
3444
|
+
|
|
3445
|
+
// Leading cluster (the macOS mirror): content starts past it.
|
|
3446
|
+
const leading_tokens = DesignTokens{ .window_controls = geometry.RectF.init(0, 0, 78, 32) };
|
|
3447
|
+
const lead_children = [_]Widget{ status, spacer };
|
|
3448
|
+
var lead_row = row;
|
|
3449
|
+
lead_row.children = &lead_children;
|
|
3450
|
+
layout = try canvas.layoutWidgetTreeWithTokens(lead_row, bounds, leading_tokens, &nodes);
|
|
3451
|
+
try std.testing.expect(layout.findById(3).?.frame.x >= 78 - 0.01);
|
|
3452
|
+
|
|
3453
|
+
// Unstamped tokens: byte-identical to a plain row.
|
|
3454
|
+
layout = try canvas.layoutWidgetTreeWithTokens(row, bounds, DesignTokens{}, &nodes);
|
|
3455
|
+
try std.testing.expectEqual(@as(f32, 400), layout.findById(3).?.frame.maxX());
|
|
3456
|
+
|
|
3457
|
+
// A non-drag row ignores the stamp entirely.
|
|
3458
|
+
var plain = row;
|
|
3459
|
+
plain.window_drag = false;
|
|
3460
|
+
layout = try canvas.layoutWidgetTreeWithTokens(plain, bounds, trailing_tokens, &nodes);
|
|
3461
|
+
try std.testing.expectEqual(@as(f32, 400), layout.findById(3).?.frame.maxX());
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
test "window-control collision scan flags readable content only" {
|
|
3465
|
+
// The reservation trigger: text under the cluster inside a drag
|
|
3466
|
+
// header counts; the row itself (its background paints under the
|
|
3467
|
+
// buttons like it does under traffic lights), spacers, and
|
|
3468
|
+
// full-bleed separators never do — and content outside any drag
|
|
3469
|
+
// region is not the header's to fix.
|
|
3470
|
+
const cluster = geometry.RectF.init(262, 0, 138, 32);
|
|
3471
|
+
const bounds = geometry.RectF.init(0, 0, 400, 40);
|
|
3472
|
+
|
|
3473
|
+
const spacer = Widget{ .id = 2, .kind = .stack, .layout = .{ .grow = 1 } };
|
|
3474
|
+
const status = Widget{ .id = 3, .kind = .text, .text = "sampling" };
|
|
3475
|
+
const colliding_children = [_]Widget{ spacer, status };
|
|
3476
|
+
var drag_row = Widget{ .id = 1, .kind = .row, .children = &colliding_children };
|
|
3477
|
+
drag_row.window_drag = true;
|
|
3478
|
+
|
|
3479
|
+
var nodes: [6]WidgetLayoutNode = undefined;
|
|
3480
|
+
var layout = try canvas.layoutWidgetTreeWithTokens(drag_row, bounds, DesignTokens{}, &nodes);
|
|
3481
|
+
try std.testing.expect(canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, DesignTokens{}));
|
|
3482
|
+
|
|
3483
|
+
// The same content already clear of the cluster: no trigger.
|
|
3484
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, geometry.RectF.init(262, 200, 138, 32), DesignTokens{}));
|
|
3485
|
+
|
|
3486
|
+
// Decoration under the cluster: a full-width separator never
|
|
3487
|
+
// triggers (it is expected to run under the band).
|
|
3488
|
+
const separator = Widget{ .id = 4, .kind = .separator };
|
|
3489
|
+
const decor_children = [_]Widget{ spacer, separator };
|
|
3490
|
+
var decor_row = drag_row;
|
|
3491
|
+
decor_row.children = &decor_children;
|
|
3492
|
+
layout = try canvas.layoutWidgetTreeWithTokens(decor_row, bounds, DesignTokens{}, &nodes);
|
|
3493
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, DesignTokens{}));
|
|
3494
|
+
|
|
3495
|
+
// Content under the cluster OUTSIDE any drag region: not the
|
|
3496
|
+
// header's collision to fix, so no trigger.
|
|
3497
|
+
var plain_row = drag_row;
|
|
3498
|
+
plain_row.window_drag = false;
|
|
3499
|
+
layout = try canvas.layoutWidgetTreeWithTokens(plain_row, bounds, DesignTokens{}, &nodes);
|
|
3500
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, DesignTokens{}));
|
|
3501
|
+
}
|
|
3502
|
+
|
|
3503
|
+
test "window-control collision scan judges text by its aligned painted bounds" {
|
|
3504
|
+
// The centered-title pattern: a grow text spanning the header row
|
|
3505
|
+
// has a FRAME under the trailing cluster while its inked glyphs sit
|
|
3506
|
+
// well clear of it. Judging the frame would pay the clearance retry,
|
|
3507
|
+
// and the trimmed content box would visibly shift the centered title
|
|
3508
|
+
// — so the scan measures the aligned painted line instead. A
|
|
3509
|
+
// trailing-aligned grow text whose painted END sits under the
|
|
3510
|
+
// cluster still collides (the system-monitor case), the macOS
|
|
3511
|
+
// leading mirror agrees, and multi-line text keeps the conservative
|
|
3512
|
+
// frame test.
|
|
3513
|
+
const cluster = geometry.RectF.init(262, 0, 138, 32);
|
|
3514
|
+
const bounds = geometry.RectF.init(0, 0, 400, 40);
|
|
3515
|
+
|
|
3516
|
+
var title = Widget{ .id = 2, .kind = .text, .text = "Monitor", .layout = .{ .grow = 1 } };
|
|
3517
|
+
title.text_alignment = .center;
|
|
3518
|
+
const centered_children = [_]Widget{title};
|
|
3519
|
+
var drag_row = Widget{ .id = 1, .kind = .row, .children = ¢ered_children };
|
|
3520
|
+
drag_row.window_drag = true;
|
|
3521
|
+
|
|
3522
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
3523
|
+
var layout = try canvas.layoutWidgetTreeWithTokens(drag_row, bounds, DesignTokens{}, &nodes);
|
|
3524
|
+
// The grow frame really does span the cluster; the painted glyphs
|
|
3525
|
+
// do not — no trigger, so the runtime never retries and the
|
|
3526
|
+
// centered title never moves.
|
|
3527
|
+
try std.testing.expect(layout.findById(2).?.frame.maxX() > cluster.x);
|
|
3528
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, DesignTokens{}));
|
|
3529
|
+
|
|
3530
|
+
// Trailing-aligned grow text: same frame, painted end under the
|
|
3531
|
+
// cluster — still a collision, and the remedy still converges (the
|
|
3532
|
+
// re-laid text ends at the cluster's leading edge, so the re-scan
|
|
3533
|
+
// of the remedied layout stays quiet).
|
|
3534
|
+
var status = title;
|
|
3535
|
+
status.text_alignment = .end;
|
|
3536
|
+
const trailing_children = [_]Widget{status};
|
|
3537
|
+
var trailing_row = drag_row;
|
|
3538
|
+
trailing_row.children = &trailing_children;
|
|
3539
|
+
layout = try canvas.layoutWidgetTreeWithTokens(trailing_row, bounds, DesignTokens{}, &nodes);
|
|
3540
|
+
try std.testing.expect(canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, DesignTokens{}));
|
|
3541
|
+
const trailing_tokens = DesignTokens{ .window_controls = cluster };
|
|
3542
|
+
layout = try canvas.layoutWidgetTreeWithTokens(trailing_row, bounds, trailing_tokens, &nodes);
|
|
3543
|
+
try std.testing.expect(layout.findById(2).?.frame.maxX() <= cluster.x + 0.01);
|
|
3544
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, trailing_tokens));
|
|
3545
|
+
|
|
3546
|
+
// The macOS mirror: a leading cluster collides with leading-aligned
|
|
3547
|
+
// glyphs but not with the same centered title.
|
|
3548
|
+
const leading_cluster = geometry.RectF.init(0, 0, 78, 32);
|
|
3549
|
+
var lead = title;
|
|
3550
|
+
lead.text_alignment = .start;
|
|
3551
|
+
const lead_children = [_]Widget{lead};
|
|
3552
|
+
var lead_row = drag_row;
|
|
3553
|
+
lead_row.children = &lead_children;
|
|
3554
|
+
layout = try canvas.layoutWidgetTreeWithTokens(lead_row, bounds, DesignTokens{}, &nodes);
|
|
3555
|
+
try std.testing.expect(canvas.windowDragContentUnderWindowControls(layout.nodes, leading_cluster, DesignTokens{}));
|
|
3556
|
+
layout = try canvas.layoutWidgetTreeWithTokens(drag_row, bounds, DesignTokens{}, &nodes);
|
|
3557
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, leading_cluster, DesignTokens{}));
|
|
3558
|
+
|
|
3559
|
+
// Multi-line text (an explicit newline) stacks lines with per-line
|
|
3560
|
+
// extents, so the scan keeps the conservative frame test: the same
|
|
3561
|
+
// centered grow leaf triggers once it can break.
|
|
3562
|
+
var wrapped = title;
|
|
3563
|
+
wrapped.text = "Mon\nitor";
|
|
3564
|
+
const wrapped_children = [_]Widget{wrapped};
|
|
3565
|
+
var wrapped_row = drag_row;
|
|
3566
|
+
wrapped_row.children = &wrapped_children;
|
|
3567
|
+
layout = try canvas.layoutWidgetTreeWithTokens(wrapped_row, bounds, DesignTokens{}, &nodes);
|
|
3568
|
+
try std.testing.expect(canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, DesignTokens{}));
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
test "window-control clearance moves a drag header's anchored children too" {
|
|
3572
|
+
// The collision scan counts every content descendant of the drag
|
|
3573
|
+
// header — anchored floaters included — so the remedy must move
|
|
3574
|
+
// them: a drag header's anchored children resolve against the
|
|
3575
|
+
// cleared anchor rect, not the full frame, or the runtime pays its
|
|
3576
|
+
// one retry and the child stays under the caption buttons. Non-drag
|
|
3577
|
+
// widgets' anchored children never move (menus/popovers anchor
|
|
3578
|
+
// everywhere), stamped tokens or not.
|
|
3579
|
+
const cluster = geometry.RectF.init(262, 0, 138, 32);
|
|
3580
|
+
const bounds = geometry.RectF.init(0, 0, 400, 300);
|
|
3581
|
+
const trailing_tokens = DesignTokens{ .window_controls = cluster };
|
|
3582
|
+
|
|
3583
|
+
// A 24pt-tall header (shorter than the 32pt cluster band) whose ONLY
|
|
3584
|
+
// content is an end-aligned floater dropping just below the header —
|
|
3585
|
+
// still inside the cluster band, and under its buttons.
|
|
3586
|
+
const badge = Widget{ .id = 3, .kind = .text, .text = "recording", .layout = .{ .anchor = .{ .placement = .below, .alignment = .end, .offset = 0 } } };
|
|
3587
|
+
const header_children = [_]Widget{badge};
|
|
3588
|
+
var header = Widget{ .id = 2, .kind = .row, .frame = geometry.RectF.init(0, 0, 0, 24), .children = &header_children };
|
|
3589
|
+
header.window_drag = true;
|
|
3590
|
+
const root_children = [_]Widget{header};
|
|
3591
|
+
const root = Widget{ .id = 1, .kind = .column, .children = &root_children };
|
|
3592
|
+
|
|
3593
|
+
// Unstamped: the floater ends at the header's trailing edge, under
|
|
3594
|
+
// the cluster — and the scan fires on it (anchored-only content is
|
|
3595
|
+
// still a collision).
|
|
3596
|
+
var nodes: [6]WidgetLayoutNode = undefined;
|
|
3597
|
+
var layout = try canvas.layoutWidgetTreeWithTokens(root, bounds, DesignTokens{}, &nodes);
|
|
3598
|
+
const naive = layout.findById(3).?.frame;
|
|
3599
|
+
try std.testing.expect(naive.maxX() > cluster.x);
|
|
3600
|
+
try std.testing.expect(!geometry.RectF.intersection(naive.normalized(), cluster).isEmpty());
|
|
3601
|
+
try std.testing.expect(canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, DesignTokens{}));
|
|
3602
|
+
|
|
3603
|
+
// Stamped: the anchor base is trimmed, the floater lands clear of
|
|
3604
|
+
// the cluster, and re-scanning the remedied layout stays quiet —
|
|
3605
|
+
// scan and remedy agree, so the runtime's single retry converges.
|
|
3606
|
+
layout = try canvas.layoutWidgetTreeWithTokens(root, bounds, trailing_tokens, &nodes);
|
|
3607
|
+
try std.testing.expect(layout.findById(3).?.frame.maxX() <= cluster.x + 0.01);
|
|
3608
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, cluster, trailing_tokens));
|
|
3609
|
+
|
|
3610
|
+
// The macOS mirror: a leading cluster pushes a start-aligned floater
|
|
3611
|
+
// past its trailing edge.
|
|
3612
|
+
const leading_cluster = geometry.RectF.init(0, 0, 78, 32);
|
|
3613
|
+
const lead_badge = Widget{ .id = 3, .kind = .text, .text = "recording", .layout = .{ .anchor = .{ .placement = .below, .alignment = .start, .offset = 0 } } };
|
|
3614
|
+
const lead_children = [_]Widget{lead_badge};
|
|
3615
|
+
var lead_header = header;
|
|
3616
|
+
lead_header.children = &lead_children;
|
|
3617
|
+
const lead_root_children = [_]Widget{lead_header};
|
|
3618
|
+
var lead_root = root;
|
|
3619
|
+
lead_root.children = &lead_root_children;
|
|
3620
|
+
layout = try canvas.layoutWidgetTreeWithTokens(lead_root, bounds, DesignTokens{}, &nodes);
|
|
3621
|
+
try std.testing.expect(canvas.windowDragContentUnderWindowControls(layout.nodes, leading_cluster, DesignTokens{}));
|
|
3622
|
+
layout = try canvas.layoutWidgetTreeWithTokens(lead_root, bounds, DesignTokens{ .window_controls = leading_cluster }, &nodes);
|
|
3623
|
+
try std.testing.expect(layout.findById(3).?.frame.x >= leading_cluster.maxX() - 0.01);
|
|
3624
|
+
try std.testing.expect(!canvas.windowDragContentUnderWindowControls(layout.nodes, leading_cluster, DesignTokens{ .window_controls = leading_cluster }));
|
|
3625
|
+
|
|
3626
|
+
// A non-drag row's anchored child is byte-identical with the stamp:
|
|
3627
|
+
// anchoring semantics outside declared titlebars never change.
|
|
3628
|
+
var plain_header = header;
|
|
3629
|
+
plain_header.window_drag = false;
|
|
3630
|
+
const plain_root_children = [_]Widget{plain_header};
|
|
3631
|
+
var plain_root = root;
|
|
3632
|
+
plain_root.children = &plain_root_children;
|
|
3633
|
+
layout = try canvas.layoutWidgetTreeWithTokens(plain_root, bounds, DesignTokens{}, &nodes);
|
|
3634
|
+
const unstamped = layout.findById(3).?.frame;
|
|
3635
|
+
layout = try canvas.layoutWidgetTreeWithTokens(plain_root, bounds, trailing_tokens, &nodes);
|
|
3636
|
+
try std.testing.expectEqual(unstamped, layout.findById(3).?.frame);
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3205
3639
|
test "geometry pixel snapping off keeps label-exact intrinsic widths bit-identical" {
|
|
3206
3640
|
// The ceil-to-grid rule is gated on `pixel_snap.geometry`: themes
|
|
3207
3641
|
// without geometry snapping have no snap shave to defend against,
|