@native-sdk/cli 0.9.1 → 0.9.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 +26 -9
- package/build.zig +55 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/skill-data/native-ui/SKILL.md +7 -7
- package/skill-data/ts-core/SKILL.md +1 -1
- package/src/app_runner/root.zig +93 -6
- package/src/app_runner/ts_core_main.zig +4 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +192 -40
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +154 -9
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ui_app.zig +9 -3
- package/src/runtime/ui_app_tests.zig +119 -19
- package/src/runtime/ui_app_window_tests.zig +13 -1
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +128 -18
- package/src/tooling/web_engine.zig +1 -1
|
@@ -438,15 +438,16 @@ test "icon widgets render built-in vector icons as tinted path commands" {
|
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
test "checkbox check mark
|
|
441
|
+
test "checkbox check mark and label render through their pinned part slots" {
|
|
442
442
|
const checkbox = Widget{
|
|
443
443
|
.id = 63,
|
|
444
444
|
.kind = WidgetKind.checkbox,
|
|
445
|
-
.frame = geometry.RectF.init(0, 0,
|
|
445
|
+
.frame = geometry.RectF.init(0, 0, 80, 24),
|
|
446
446
|
.value = 1,
|
|
447
|
+
.text = "Done",
|
|
447
448
|
};
|
|
448
449
|
const tokens = DesignTokens{};
|
|
449
|
-
var commands: [
|
|
450
|
+
var commands: [9]CanvasCommand = undefined;
|
|
450
451
|
var builder = Builder.init(&commands);
|
|
451
452
|
try emitWidgetTree(&builder, checkbox, tokens);
|
|
452
453
|
const display_list = builder.displayList();
|
|
@@ -465,18 +466,22 @@ test "checkbox check mark strokes one anti-aliased vector path" {
|
|
|
465
466
|
},
|
|
466
467
|
else => return error.TestUnexpectedResult,
|
|
467
468
|
}
|
|
469
|
+
switch (display_list.findCommandById(widgetPartId(63, 6)).?.command) {
|
|
470
|
+
.draw_text => |text| try std.testing.expectEqualStrings("Done", text.text),
|
|
471
|
+
else => return error.TestUnexpectedResult,
|
|
472
|
+
}
|
|
468
473
|
|
|
469
|
-
// Rasterized, the diagonal carries partial-coverage edge pixels
|
|
470
|
-
//
|
|
471
|
-
//
|
|
472
|
-
var render_commands: [
|
|
474
|
+
// Rasterized, the diagonal carries partial-coverage edge pixels and
|
|
475
|
+
// the label is present at its stable part slot. The whole 80x24
|
|
476
|
+
// checkbox-plus-label render pins byte-identical.
|
|
477
|
+
var render_commands: [9]RenderCommand = undefined;
|
|
473
478
|
const plan = try (DisplayList{ .commands = display_list.commands }).renderPlan(&render_commands);
|
|
474
|
-
var pixels: [
|
|
479
|
+
var pixels: [80 * 24 * 4]u8 = undefined;
|
|
475
480
|
@memset(&pixels, 0);
|
|
476
|
-
const surface = try ReferenceRenderSurface.init(
|
|
481
|
+
const surface = try ReferenceRenderSurface.init(80, 24, &pixels);
|
|
477
482
|
try surface.renderPass(.{
|
|
478
483
|
.commands = plan.commands,
|
|
479
|
-
.surface_size = geometry.SizeF.init(
|
|
484
|
+
.surface_size = geometry.SizeF.init(80, 24),
|
|
480
485
|
.full_repaint = true,
|
|
481
486
|
}, Color.rgb8(255, 255, 255));
|
|
482
487
|
// Sample strictly inside the accent fill (the 16px box spans y 4-20;
|
|
@@ -487,12 +492,12 @@ test "checkbox check mark strokes one anti-aliased vector path" {
|
|
|
487
492
|
while (y < 18) : (y += 1) {
|
|
488
493
|
var x: usize = 2;
|
|
489
494
|
while (x < 14) : (x += 1) {
|
|
490
|
-
const value = pixels[(y *
|
|
495
|
+
const value = pixels[(y * 80 + x) * 4];
|
|
491
496
|
if (value > 60 and value < 200) partial += 1;
|
|
492
497
|
}
|
|
493
498
|
}
|
|
494
499
|
try std.testing.expect(partial >= 4);
|
|
495
|
-
try std.testing.expectEqual(@as(u64,
|
|
500
|
+
try std.testing.expectEqual(@as(u64, 516383874562490834), support.referenceSurfaceSignature(&pixels));
|
|
496
501
|
}
|
|
497
502
|
|
|
498
503
|
test "a builder accumulating two widget trees keeps each checkbox mark's own geometry" {
|
|
@@ -545,6 +550,240 @@ test "a builder accumulating two widget trees keeps each checkbox mark's own geo
|
|
|
545
550
|
}
|
|
546
551
|
}
|
|
547
552
|
|
|
553
|
+
test "compact radio and switch chrome stays circular and disabled selection fills wash" {
|
|
554
|
+
const tokens = DesignTokens{};
|
|
555
|
+
const disabled_fill = Color.rgba(
|
|
556
|
+
tokens.colors.surface.r,
|
|
557
|
+
tokens.colors.surface.g,
|
|
558
|
+
tokens.colors.surface.b,
|
|
559
|
+
tokens.colors.surface.a * tokens.states.disabled_alpha,
|
|
560
|
+
);
|
|
561
|
+
const controls = [_]struct { kind: WidgetKind, frame: geometry.RectF }{
|
|
562
|
+
.{ .kind = .checkbox, .frame = geometry.RectF.init(0, 0, 80, 28) },
|
|
563
|
+
.{ .kind = .radio, .frame = geometry.RectF.init(0, 0, 80, 28) },
|
|
564
|
+
};
|
|
565
|
+
for (controls) |control| {
|
|
566
|
+
const widget = Widget{
|
|
567
|
+
.id = 67,
|
|
568
|
+
.kind = control.kind,
|
|
569
|
+
.frame = control.frame,
|
|
570
|
+
.size = .sm,
|
|
571
|
+
.state = .{ .disabled = true },
|
|
572
|
+
};
|
|
573
|
+
var commands: [8]CanvasCommand = undefined;
|
|
574
|
+
var builder = Builder.init(&commands);
|
|
575
|
+
try emitWidgetTree(&builder, widget, tokens);
|
|
576
|
+
switch (builder.displayList().findCommandById(widgetPartId(67, 1)).?.command) {
|
|
577
|
+
.fill_rounded_rect => |fill| {
|
|
578
|
+
try expectFillColor(disabled_fill, fill.fill);
|
|
579
|
+
if (control.kind == .radio) {
|
|
580
|
+
try std.testing.expectApproxEqAbs(fill.rect.height * 0.5, fill.radius.top_left, 0.001);
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
else => return error.TestUnexpectedResult,
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const toggle = Widget{
|
|
588
|
+
.id = 68,
|
|
589
|
+
.kind = .switch_control,
|
|
590
|
+
.frame = geometry.RectF.init(0, 0, 80, 28),
|
|
591
|
+
.size = .sm,
|
|
592
|
+
};
|
|
593
|
+
var toggle_commands: [8]CanvasCommand = undefined;
|
|
594
|
+
var toggle_builder = Builder.init(&toggle_commands);
|
|
595
|
+
try emitWidgetTree(&toggle_builder, toggle, tokens);
|
|
596
|
+
switch (toggle_builder.displayList().findCommandById(widgetPartId(68, 1)).?.command) {
|
|
597
|
+
.fill_rounded_rect => |fill| try std.testing.expectApproxEqAbs(fill.rect.height * 0.5, fill.radius.top_left, 0.001),
|
|
598
|
+
else => return error.TestUnexpectedResult,
|
|
599
|
+
}
|
|
600
|
+
switch (toggle_builder.displayList().findCommandById(widgetPartId(68, 3)).?.command) {
|
|
601
|
+
.fill_rounded_rect => |fill| try std.testing.expectApproxEqAbs(fill.rect.height * 0.5, fill.radius.top_left, 0.001),
|
|
602
|
+
else => return error.TestUnexpectedResult,
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
test "selection controls honor explicit disabled background and foreground tokens" {
|
|
607
|
+
const disabled_background = Color.rgb8(34, 68, 102);
|
|
608
|
+
const disabled_foreground = Color.rgb8(238, 204, 170);
|
|
609
|
+
const disabled_border = Color.rgb8(51, 119, 85);
|
|
610
|
+
const tokens = DesignTokens{ .controls = .{
|
|
611
|
+
.checkbox = .{ .disabled_background = disabled_background, .disabled_foreground = disabled_foreground, .border = disabled_border },
|
|
612
|
+
.radio = .{ .disabled_background = disabled_background, .disabled_foreground = disabled_foreground, .border = disabled_border },
|
|
613
|
+
.switch_control = .{ .disabled_background = disabled_background, .disabled_foreground = disabled_foreground, .border = disabled_border },
|
|
614
|
+
} };
|
|
615
|
+
const cases = [_]struct {
|
|
616
|
+
kind: WidgetKind,
|
|
617
|
+
foreground_slot: ObjectId,
|
|
618
|
+
label_slot: ObjectId,
|
|
619
|
+
}{
|
|
620
|
+
.{ .kind = .checkbox, .foreground_slot = 4, .label_slot = 6 },
|
|
621
|
+
.{ .kind = .radio, .foreground_slot = 4, .label_slot = 5 },
|
|
622
|
+
.{ .kind = .switch_control, .foreground_slot = 3, .label_slot = 5 },
|
|
623
|
+
};
|
|
624
|
+
for (cases, 0..) |case, index| {
|
|
625
|
+
const id: ObjectId = @intCast(80 + index);
|
|
626
|
+
const widget = Widget{
|
|
627
|
+
.id = id,
|
|
628
|
+
.kind = case.kind,
|
|
629
|
+
.frame = geometry.RectF.init(0, 0, 120, 28),
|
|
630
|
+
.text = "Disabled",
|
|
631
|
+
.value = 1,
|
|
632
|
+
.state = .{ .disabled = true },
|
|
633
|
+
};
|
|
634
|
+
var commands: [10]CanvasCommand = undefined;
|
|
635
|
+
var builder = Builder.init(&commands);
|
|
636
|
+
try emitWidgetTree(&builder, widget, tokens);
|
|
637
|
+
const list = builder.displayList();
|
|
638
|
+
switch (list.findCommandById(widgetPartId(id, 1)).?.command) {
|
|
639
|
+
.fill_rounded_rect => |fill| try expectFillColor(disabled_background, fill.fill),
|
|
640
|
+
else => return error.TestUnexpectedResult,
|
|
641
|
+
}
|
|
642
|
+
switch (list.findCommandById(widgetPartId(id, 2)).?.command) {
|
|
643
|
+
.stroke_rect => |stroke| try expectFillColor(disabled_border, stroke.stroke.fill),
|
|
644
|
+
else => return error.TestUnexpectedResult,
|
|
645
|
+
}
|
|
646
|
+
switch (list.findCommandById(widgetPartId(id, case.foreground_slot)).?.command) {
|
|
647
|
+
.fill_rounded_rect => |fill| try expectFillColor(disabled_foreground, fill.fill),
|
|
648
|
+
.stroke_path => |stroke| try expectFillColor(disabled_foreground, stroke.stroke.fill),
|
|
649
|
+
else => return error.TestUnexpectedResult,
|
|
650
|
+
}
|
|
651
|
+
switch (list.findCommandById(widgetPartId(id, case.label_slot)).?.command) {
|
|
652
|
+
.draw_text => |text| try std.testing.expectEqualDeep(disabled_foreground, text.color),
|
|
653
|
+
else => return error.TestUnexpectedResult,
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// Like the slider register, stating either disabled channel opts the
|
|
658
|
+
// control into color-swap mode: an unstated counterpart stays at full
|
|
659
|
+
// rest strength instead of being alpha-washed behind the swap.
|
|
660
|
+
const background_only_tokens = DesignTokens{ .controls = .{
|
|
661
|
+
.checkbox = .{ .disabled_background = disabled_background },
|
|
662
|
+
} };
|
|
663
|
+
const background_only = Widget{
|
|
664
|
+
.id = 83,
|
|
665
|
+
.kind = .checkbox,
|
|
666
|
+
.frame = geometry.RectF.init(0, 0, 120, 28),
|
|
667
|
+
.text = "Background only",
|
|
668
|
+
.value = 1,
|
|
669
|
+
.state = .{ .disabled = true },
|
|
670
|
+
};
|
|
671
|
+
var background_only_commands: [10]CanvasCommand = undefined;
|
|
672
|
+
var background_only_builder = Builder.init(&background_only_commands);
|
|
673
|
+
try emitWidgetTree(&background_only_builder, background_only, background_only_tokens);
|
|
674
|
+
switch (background_only_builder.displayList().findCommandById(widgetPartId(83, 1)).?.command) {
|
|
675
|
+
.fill_rounded_rect => |fill| try expectFillColor(disabled_background, fill.fill),
|
|
676
|
+
else => return error.TestUnexpectedResult,
|
|
677
|
+
}
|
|
678
|
+
switch (background_only_builder.displayList().findCommandById(widgetPartId(83, 4)).?.command) {
|
|
679
|
+
.stroke_path => |stroke| try expectFillColor(background_only_tokens.colors.accent_text, stroke.stroke.fill),
|
|
680
|
+
else => return error.TestUnexpectedResult,
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const foreground_only_tokens = DesignTokens{ .controls = .{
|
|
684
|
+
.checkbox = .{ .disabled_foreground = disabled_foreground },
|
|
685
|
+
} };
|
|
686
|
+
var foreground_only_commands: [10]CanvasCommand = undefined;
|
|
687
|
+
var foreground_only_builder = Builder.init(&foreground_only_commands);
|
|
688
|
+
try emitWidgetTree(&foreground_only_builder, background_only, foreground_only_tokens);
|
|
689
|
+
switch (foreground_only_builder.displayList().findCommandById(widgetPartId(83, 1)).?.command) {
|
|
690
|
+
.fill_rounded_rect => |fill| try expectFillColor(foreground_only_tokens.colors.accent, fill.fill),
|
|
691
|
+
else => return error.TestUnexpectedResult,
|
|
692
|
+
}
|
|
693
|
+
switch (foreground_only_builder.displayList().findCommandById(widgetPartId(83, 4)).?.command) {
|
|
694
|
+
.stroke_path => |stroke| try expectFillColor(disabled_foreground, stroke.stroke.fill),
|
|
695
|
+
else => return error.TestUnexpectedResult,
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
test "radio and switch shape overrides beat circular house fallbacks" {
|
|
700
|
+
const tokens = DesignTokens{
|
|
701
|
+
.controls = .{
|
|
702
|
+
.radio = .{ .radius = 5 },
|
|
703
|
+
.switch_control = .{ .radius = 4 },
|
|
704
|
+
},
|
|
705
|
+
};
|
|
706
|
+
const themed_radio = Widget{
|
|
707
|
+
.id = 70,
|
|
708
|
+
.kind = .radio,
|
|
709
|
+
.frame = geometry.RectF.init(0, 0, 80, 28),
|
|
710
|
+
};
|
|
711
|
+
var themed_radio_commands: [8]CanvasCommand = undefined;
|
|
712
|
+
var themed_radio_builder = Builder.init(&themed_radio_commands);
|
|
713
|
+
try emitWidgetTree(&themed_radio_builder, themed_radio, tokens);
|
|
714
|
+
switch (themed_radio_builder.displayList().findCommandById(widgetPartId(70, 1)).?.command) {
|
|
715
|
+
.fill_rounded_rect => |fill| try std.testing.expectEqualDeep(Radius.all(5), fill.radius),
|
|
716
|
+
else => return error.TestUnexpectedResult,
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const authored_radio = Widget{
|
|
720
|
+
.id = 72,
|
|
721
|
+
.kind = .radio,
|
|
722
|
+
.frame = geometry.RectF.init(0, 0, 80, 28),
|
|
723
|
+
.style = .{ .radius = 3 },
|
|
724
|
+
};
|
|
725
|
+
var authored_radio_commands: [8]CanvasCommand = undefined;
|
|
726
|
+
var authored_radio_builder = Builder.init(&authored_radio_commands);
|
|
727
|
+
try emitWidgetTree(&authored_radio_builder, authored_radio, tokens);
|
|
728
|
+
switch (authored_radio_builder.displayList().findCommandById(widgetPartId(72, 1)).?.command) {
|
|
729
|
+
.fill_rounded_rect => |fill| try std.testing.expectEqualDeep(Radius.all(3), fill.radius),
|
|
730
|
+
else => return error.TestUnexpectedResult,
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const toggle = Widget{
|
|
734
|
+
.id = 71,
|
|
735
|
+
.kind = .switch_control,
|
|
736
|
+
.frame = geometry.RectF.init(0, 0, 80, 28),
|
|
737
|
+
};
|
|
738
|
+
var toggle_commands: [8]CanvasCommand = undefined;
|
|
739
|
+
var toggle_builder = Builder.init(&toggle_commands);
|
|
740
|
+
try emitWidgetTree(&toggle_builder, toggle, tokens);
|
|
741
|
+
inline for (.{ @as(ObjectId, 1), @as(ObjectId, 3) }) |slot| {
|
|
742
|
+
switch (toggle_builder.displayList().findCommandById(widgetPartId(71, slot)).?.command) {
|
|
743
|
+
.fill_rounded_rect => |fill| try std.testing.expectEqualDeep(Radius.all(4), fill.radius),
|
|
744
|
+
else => return error.TestUnexpectedResult,
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
var authored_toggle = toggle;
|
|
749
|
+
authored_toggle.id = 73;
|
|
750
|
+
authored_toggle.style.radius = 2;
|
|
751
|
+
var authored_toggle_commands: [8]CanvasCommand = undefined;
|
|
752
|
+
var authored_toggle_builder = Builder.init(&authored_toggle_commands);
|
|
753
|
+
try emitWidgetTree(&authored_toggle_builder, authored_toggle, tokens);
|
|
754
|
+
inline for (.{ @as(ObjectId, 1), @as(ObjectId, 3) }) |slot| {
|
|
755
|
+
switch (authored_toggle_builder.displayList().findCommandById(widgetPartId(73, slot)).?.command) {
|
|
756
|
+
.fill_rounded_rect => |fill| try std.testing.expectEqualDeep(Radius.all(2), fill.radius),
|
|
757
|
+
else => return error.TestUnexpectedResult,
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
test "an off switch keeps authored track and thumb colors on separate channels" {
|
|
763
|
+
const track_color = Color.rgb8(12, 34, 56);
|
|
764
|
+
const thumb_color = Color.rgb8(240, 244, 248);
|
|
765
|
+
const toggle = Widget{
|
|
766
|
+
.id = 69,
|
|
767
|
+
.kind = .switch_control,
|
|
768
|
+
.frame = geometry.RectF.init(0, 0, 80, 32),
|
|
769
|
+
.style = .{
|
|
770
|
+
.background = track_color,
|
|
771
|
+
.accent_foreground = thumb_color,
|
|
772
|
+
},
|
|
773
|
+
};
|
|
774
|
+
var commands: [8]CanvasCommand = undefined;
|
|
775
|
+
var builder = Builder.init(&commands);
|
|
776
|
+
try emitWidgetTree(&builder, toggle, .{});
|
|
777
|
+
switch (builder.displayList().findCommandById(widgetPartId(69, 1)).?.command) {
|
|
778
|
+
.fill_rounded_rect => |fill| try expectFillColor(track_color, fill.fill),
|
|
779
|
+
else => return error.TestUnexpectedResult,
|
|
780
|
+
}
|
|
781
|
+
switch (builder.displayList().findCommandById(widgetPartId(69, 3)).?.command) {
|
|
782
|
+
.fill_rounded_rect => |fill| try expectFillColor(thumb_color, fill.fill),
|
|
783
|
+
else => return error.TestUnexpectedResult,
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
548
787
|
test "app-registered icons draw through the widget paths like built-ins" {
|
|
549
788
|
var buffer = canvas.svg_icon.IconBuffer{};
|
|
550
789
|
const parsed = try canvas.svg_icon.parse(
|
|
@@ -693,7 +932,7 @@ test "disabled filled buttons match their reference edge treatment" {
|
|
|
693
932
|
// the fill and fallback edge are each washed to half strength, their
|
|
694
933
|
// overlap becomes darker and invents an outline around the disabled
|
|
695
934
|
// control. Destructive is already the quiet borderless chip, so its
|
|
696
|
-
// edge
|
|
935
|
+
// edge emits no command in either state.
|
|
697
936
|
const tokens = DesignTokens{};
|
|
698
937
|
const button = Widget{
|
|
699
938
|
.id = 71,
|
|
@@ -741,10 +980,7 @@ test "disabled filled buttons match their reference edge treatment" {
|
|
|
741
980
|
var chip_commands: [8]CanvasCommand = undefined;
|
|
742
981
|
var chip_builder = Builder.init(&chip_commands);
|
|
743
982
|
try emitWidgetTree(&chip_builder, chip, tokens);
|
|
744
|
-
|
|
745
|
-
.stroke_rect => |stroke| try std.testing.expectEqual(@as(f32, 0), stroke.stroke.width),
|
|
746
|
-
else => return error.TestUnexpectedResult,
|
|
747
|
-
}
|
|
983
|
+
try std.testing.expect(chip_builder.displayList().findCommandById(widgetPartId(71, 2)) == null);
|
|
748
984
|
}
|
|
749
985
|
|
|
750
986
|
test "geist disabled buttons use the reference swap and tertiary registers" {
|
|
@@ -855,6 +1091,66 @@ test "button disabled border override does not require a disabled background" {
|
|
|
855
1091
|
try expectFillColor(disabled_border, buttonBorderFill(button, tokens));
|
|
856
1092
|
}
|
|
857
1093
|
|
|
1094
|
+
test "disabled colors wash resolved identity and secondary accents use the accent channel" {
|
|
1095
|
+
const style_mod = @import("widget_render_style.zig");
|
|
1096
|
+
const tokens = DesignTokens{};
|
|
1097
|
+
const accent = Color.rgb8(180, 24, 48);
|
|
1098
|
+
const accent_foreground = Color.rgb8(250, 226, 232);
|
|
1099
|
+
const foreground = Color.rgb8(36, 92, 148);
|
|
1100
|
+
const background = Color.rgb8(24, 56, 88);
|
|
1101
|
+
const washed_accent = Color.rgba(accent.r, accent.g, accent.b, tokens.states.disabled_alpha);
|
|
1102
|
+
const washed_accent_foreground = Color.rgba(accent_foreground.r, accent_foreground.g, accent_foreground.b, tokens.states.disabled_alpha);
|
|
1103
|
+
const washed_foreground = Color.rgba(foreground.r, foreground.g, foreground.b, tokens.states.disabled_alpha);
|
|
1104
|
+
const washed_background = Color.rgba(background.r, background.g, background.b, tokens.states.disabled_alpha);
|
|
1105
|
+
|
|
1106
|
+
const disabled = Widget{
|
|
1107
|
+
.kind = .text,
|
|
1108
|
+
.state = .{ .disabled = true },
|
|
1109
|
+
.style = .{
|
|
1110
|
+
.foreground = foreground,
|
|
1111
|
+
.accent_foreground = accent_foreground,
|
|
1112
|
+
},
|
|
1113
|
+
};
|
|
1114
|
+
try std.testing.expectEqualDeep(washed_foreground, style_mod.widgetForegroundColor(disabled, tokens, tokens.colors.text));
|
|
1115
|
+
try std.testing.expectEqualDeep(washed_accent_foreground, style_mod.widgetAccentForegroundColor(disabled, tokens, tokens.colors.accent_text));
|
|
1116
|
+
|
|
1117
|
+
const secondary = Widget{
|
|
1118
|
+
.kind = .button,
|
|
1119
|
+
.variant = .secondary,
|
|
1120
|
+
.style = .{ .accent = accent },
|
|
1121
|
+
};
|
|
1122
|
+
try std.testing.expectEqualDeep(accent, style_mod.buttonFillColor(secondary, tokens));
|
|
1123
|
+
try expectFillColor(accent, style_mod.buttonBorderFill(secondary, tokens));
|
|
1124
|
+
|
|
1125
|
+
const disabled_input = Widget{
|
|
1126
|
+
.kind = .text_field,
|
|
1127
|
+
.state = .{ .disabled = true },
|
|
1128
|
+
.style = .{ .background = background },
|
|
1129
|
+
};
|
|
1130
|
+
try expectFillColor(washed_background, style_mod.textInputFill(disabled_input, tokens, .{}));
|
|
1131
|
+
|
|
1132
|
+
const secondary_badge = Widget{
|
|
1133
|
+
.kind = .badge,
|
|
1134
|
+
.variant = .secondary,
|
|
1135
|
+
.style = .{ .accent = accent },
|
|
1136
|
+
};
|
|
1137
|
+
try std.testing.expectEqualDeep(accent, style_mod.badgeBackgroundColor(secondary_badge, tokens, .{}));
|
|
1138
|
+
try std.testing.expectEqualDeep(accent, style_mod.badgeBorderColor(secondary_badge, tokens, .{}));
|
|
1139
|
+
|
|
1140
|
+
const disabled_destructive_badge = Widget{
|
|
1141
|
+
.kind = .badge,
|
|
1142
|
+
.variant = .destructive,
|
|
1143
|
+
.state = .{ .disabled = true },
|
|
1144
|
+
.style = .{
|
|
1145
|
+
.accent = accent,
|
|
1146
|
+
.accent_foreground = accent_foreground,
|
|
1147
|
+
},
|
|
1148
|
+
};
|
|
1149
|
+
try std.testing.expectEqualDeep(washed_accent, style_mod.badgeBackgroundColor(disabled_destructive_badge, tokens, .{}));
|
|
1150
|
+
try std.testing.expectEqualDeep(washed_accent, style_mod.badgeBorderColor(disabled_destructive_badge, tokens, .{}));
|
|
1151
|
+
try std.testing.expectEqualDeep(washed_accent_foreground, style_mod.badgeTextColor(disabled_destructive_badge, tokens, .{}));
|
|
1152
|
+
}
|
|
1153
|
+
|
|
858
1154
|
/// The flush-group segment assertions, shared by the tree-walk and
|
|
859
1155
|
/// layout-walk halves of the test below so the two emission paths are
|
|
860
1156
|
/// pinned to the SAME bar: leading corners on the first segment,
|
|
@@ -984,11 +1280,8 @@ test "detached button groups render chip members with the group table and the me
|
|
|
984
1280
|
// No seam clips anywhere: a chip has no shared boundary.
|
|
985
1281
|
try std.testing.expect(list.findCommandById(widgetPartId(2, 0)) == null);
|
|
986
1282
|
try std.testing.expect(list.findCommandById(widgetPartId(3, 0)) == null);
|
|
987
|
-
// The chips are borderless:
|
|
988
|
-
|
|
989
|
-
.stroke_rect => |stroke| try std.testing.expectEqual(@as(f32, 0), stroke.stroke.width),
|
|
990
|
-
else => return error.TestUnexpectedResult,
|
|
991
|
-
}
|
|
1283
|
+
// The chips are borderless: no dead zero-width stroke command.
|
|
1284
|
+
try std.testing.expect(list.findCommandById(widgetPartId(2, 2)) == null);
|
|
992
1285
|
// Knockout ink on the selected label, the stated rest ink elsewhere.
|
|
993
1286
|
switch (list.findCommandById(widgetPartId(2, 4)).?.command) {
|
|
994
1287
|
.draw_text => |text| try std.testing.expectEqualDeep(Color.rgb8(255, 255, 255), text.color),
|
|
@@ -1821,6 +2114,176 @@ test "the quiet-surface knob silences the hover wash and nothing else" {
|
|
|
1821
2114
|
try std.testing.expect(focused_builder.displayList().findCommandById(widgetPartId(74, 2)) != null);
|
|
1822
2115
|
}
|
|
1823
2116
|
|
|
2117
|
+
test "actionable layout containers paint the row hover and pressed ladder in both emit paths" {
|
|
2118
|
+
const tokens = DesignTokens{};
|
|
2119
|
+
inline for (.{ WidgetKind.row, WidgetKind.column, WidgetKind.stack }) |kind| {
|
|
2120
|
+
const base = Widget{
|
|
2121
|
+
.id = 75,
|
|
2122
|
+
.kind = kind,
|
|
2123
|
+
.frame = geometry.RectF.init(0, 0, 160, 40),
|
|
2124
|
+
.semantics = .{ .actions = .{ .press = true } },
|
|
2125
|
+
};
|
|
2126
|
+
|
|
2127
|
+
var hovered = base;
|
|
2128
|
+
hovered.state.hovered = true;
|
|
2129
|
+
var commands: [4]CanvasCommand = undefined;
|
|
2130
|
+
var builder = Builder.init(&commands);
|
|
2131
|
+
try emitWidgetTree(&builder, hovered, tokens);
|
|
2132
|
+
switch (builder.displayList().findCommandById(widgetPartId(75, 1)).?.command) {
|
|
2133
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_subtle, fill.fill),
|
|
2134
|
+
else => return error.TestUnexpectedResult,
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
// The laid-out/live emitter resolves the same state and part slot.
|
|
2138
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
2139
|
+
const layout = try layoutWidgetTree(hovered, hovered.frame, &nodes);
|
|
2140
|
+
var layout_commands: [4]CanvasCommand = undefined;
|
|
2141
|
+
var layout_builder = Builder.init(&layout_commands);
|
|
2142
|
+
try layout.emitDisplayList(&layout_builder, tokens);
|
|
2143
|
+
switch (layout_builder.displayList().findCommandById(widgetPartId(75, 1)).?.command) {
|
|
2144
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_subtle, fill.fill),
|
|
2145
|
+
else => return error.TestUnexpectedResult,
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
var pressed = base;
|
|
2149
|
+
pressed.state.pressed = true;
|
|
2150
|
+
var pressed_commands: [4]CanvasCommand = undefined;
|
|
2151
|
+
var pressed_builder = Builder.init(&pressed_commands);
|
|
2152
|
+
try emitWidgetTree(&pressed_builder, pressed, tokens);
|
|
2153
|
+
switch (pressed_builder.displayList().findCommandById(widgetPartId(75, 1)).?.command) {
|
|
2154
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_pressed, fill.fill),
|
|
2155
|
+
else => return error.TestUnexpectedResult,
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
var quiet = hovered;
|
|
2159
|
+
quiet.style.quiet_hover = true;
|
|
2160
|
+
var quiet_commands: [4]CanvasCommand = undefined;
|
|
2161
|
+
var quiet_builder = Builder.init(&quiet_commands);
|
|
2162
|
+
try emitWidgetTree(&quiet_builder, quiet, tokens);
|
|
2163
|
+
try std.testing.expect(quiet_builder.displayList().findCommandById(widgetPartId(75, 1)) == null);
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
test "drag-only layout containers own hover and pressed washes through child content" {
|
|
2168
|
+
const tokens = DesignTokens{};
|
|
2169
|
+
const label = [_]Widget{.{
|
|
2170
|
+
.id = 79,
|
|
2171
|
+
.kind = .text,
|
|
2172
|
+
.text = "Drag me",
|
|
2173
|
+
}};
|
|
2174
|
+
const draggable = Widget{
|
|
2175
|
+
.id = 78,
|
|
2176
|
+
.kind = .row,
|
|
2177
|
+
.frame = geometry.RectF.init(0, 0, 160, 40),
|
|
2178
|
+
.semantics = .{ .actions = .{ .drag = true } },
|
|
2179
|
+
.children = &label,
|
|
2180
|
+
};
|
|
2181
|
+
var nodes: [2]WidgetLayoutNode = undefined;
|
|
2182
|
+
const layout = try layoutWidgetTree(draggable, draggable.frame, &nodes);
|
|
2183
|
+
const label_node = layout.findById(79) orelse return error.TestUnexpectedResult;
|
|
2184
|
+
const raw_hit = layout.hitTest(label_node.frame.center()) orelse return error.TestUnexpectedResult;
|
|
2185
|
+
try std.testing.expectEqual(@as(ObjectId, 79), raw_hit.id);
|
|
2186
|
+
const hover_target = layout.hoverTargetForHit(raw_hit) orelse return error.TestUnexpectedResult;
|
|
2187
|
+
try std.testing.expectEqual(@as(ObjectId, 78), hover_target.id);
|
|
2188
|
+
const press_target = canvas.widgetPressTargetForHit(layout, raw_hit) orelse return error.TestUnexpectedResult;
|
|
2189
|
+
try std.testing.expectEqual(@as(ObjectId, 78), press_target.id);
|
|
2190
|
+
|
|
2191
|
+
var hover_commands: [4]CanvasCommand = undefined;
|
|
2192
|
+
var hover_builder = Builder.init(&hover_commands);
|
|
2193
|
+
try layout.emitDisplayListWithState(&hover_builder, tokens, .{ .hovered_id = hover_target.id });
|
|
2194
|
+
switch (hover_builder.displayList().findCommandById(widgetPartId(78, 1)).?.command) {
|
|
2195
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_subtle, fill.fill),
|
|
2196
|
+
else => return error.TestUnexpectedResult,
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
var press_commands: [4]CanvasCommand = undefined;
|
|
2200
|
+
var press_builder = Builder.init(&press_commands);
|
|
2201
|
+
try layout.emitDisplayListWithState(&press_builder, tokens, .{ .pressed_id = press_target.id });
|
|
2202
|
+
switch (press_builder.displayList().findCommandById(widgetPartId(78, 1)).?.command) {
|
|
2203
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_pressed, fill.fill),
|
|
2204
|
+
else => return error.TestUnexpectedResult,
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
test "an actionable container uses authored background only at rest" {
|
|
2209
|
+
const authored = Color.rgb8(28, 52, 76);
|
|
2210
|
+
const tokens = DesignTokens{};
|
|
2211
|
+
const base = Widget{
|
|
2212
|
+
.id = 77,
|
|
2213
|
+
.kind = .row,
|
|
2214
|
+
.frame = geometry.RectF.init(0, 0, 160, 40),
|
|
2215
|
+
.style = .{ .background = authored },
|
|
2216
|
+
.semantics = .{ .actions = .{ .press = true } },
|
|
2217
|
+
};
|
|
2218
|
+
var rest_commands: [4]CanvasCommand = undefined;
|
|
2219
|
+
var rest_builder = Builder.init(&rest_commands);
|
|
2220
|
+
try emitWidgetTree(&rest_builder, base, tokens);
|
|
2221
|
+
switch (rest_builder.displayList().findCommandById(widgetPartId(77, 1)).?.command) {
|
|
2222
|
+
.fill_rounded_rect => |fill| try expectFillColor(authored, fill.fill),
|
|
2223
|
+
else => return error.TestUnexpectedResult,
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
var hovered = base;
|
|
2227
|
+
hovered.state.hovered = true;
|
|
2228
|
+
var hover_commands: [4]CanvasCommand = undefined;
|
|
2229
|
+
var hover_builder = Builder.init(&hover_commands);
|
|
2230
|
+
try emitWidgetTree(&hover_builder, hovered, tokens);
|
|
2231
|
+
switch (hover_builder.displayList().findCommandById(widgetPartId(77, 1)).?.command) {
|
|
2232
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_subtle, fill.fill),
|
|
2233
|
+
else => return error.TestUnexpectedResult,
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
test "house alert card and panel surfaces have visible hover and pressed fallbacks" {
|
|
2238
|
+
const themed_rest = Color.rgb8(28, 52, 76);
|
|
2239
|
+
const tokens = DesignTokens{ .controls = .{
|
|
2240
|
+
.alert = .{ .background = themed_rest },
|
|
2241
|
+
.card = .{ .background = themed_rest },
|
|
2242
|
+
.panel = .{ .background = themed_rest },
|
|
2243
|
+
} };
|
|
2244
|
+
const cases = [_]struct { kind: WidgetKind, fill_slot: u4 }{
|
|
2245
|
+
.{ .kind = .alert, .fill_slot = 1 },
|
|
2246
|
+
.{ .kind = .card, .fill_slot = 1 },
|
|
2247
|
+
.{ .kind = .panel, .fill_slot = 2 },
|
|
2248
|
+
};
|
|
2249
|
+
for (cases) |case| {
|
|
2250
|
+
const base = Widget{
|
|
2251
|
+
.id = 76,
|
|
2252
|
+
.kind = case.kind,
|
|
2253
|
+
.frame = geometry.RectF.init(0, 0, 160, 48),
|
|
2254
|
+
.semantics = .{ .actions = .{ .press = true } },
|
|
2255
|
+
};
|
|
2256
|
+
|
|
2257
|
+
var rest_commands: [8]CanvasCommand = undefined;
|
|
2258
|
+
var rest_builder = Builder.init(&rest_commands);
|
|
2259
|
+
try emitWidgetTree(&rest_builder, base, tokens);
|
|
2260
|
+
switch (rest_builder.displayList().findCommandById(widgetPartId(76, case.fill_slot)).?.command) {
|
|
2261
|
+
.fill_rounded_rect => |fill| try expectFillColor(themed_rest, fill.fill),
|
|
2262
|
+
else => return error.TestUnexpectedResult,
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
var hovered = base;
|
|
2266
|
+
hovered.state.hovered = true;
|
|
2267
|
+
var hovered_commands: [8]CanvasCommand = undefined;
|
|
2268
|
+
var hovered_builder = Builder.init(&hovered_commands);
|
|
2269
|
+
try emitWidgetTree(&hovered_builder, hovered, tokens);
|
|
2270
|
+
switch (hovered_builder.displayList().findCommandById(widgetPartId(76, case.fill_slot)).?.command) {
|
|
2271
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_subtle, fill.fill),
|
|
2272
|
+
else => return error.TestUnexpectedResult,
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
var pressed = base;
|
|
2276
|
+
pressed.state.pressed = true;
|
|
2277
|
+
var pressed_commands: [8]CanvasCommand = undefined;
|
|
2278
|
+
var pressed_builder = Builder.init(&pressed_commands);
|
|
2279
|
+
try emitWidgetTree(&pressed_builder, pressed, tokens);
|
|
2280
|
+
switch (pressed_builder.displayList().findCommandById(widgetPartId(76, case.fill_slot)).?.command) {
|
|
2281
|
+
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.surface_pressed, fill.fill),
|
|
2282
|
+
else => return error.TestUnexpectedResult,
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
|
|
1824
2287
|
test "icon buttons draw registry names as vector icons and keep the glyph fallback" {
|
|
1825
2288
|
const tokens = DesignTokens{};
|
|
1826
2289
|
const vector = Widget{
|
|
@@ -2201,7 +2664,7 @@ test "built-in component factory applies house composite defaults" {
|
|
|
2201
2664
|
try std.testing.expectEqual(widget_kind, component.kind);
|
|
2202
2665
|
try std.testing.expectEqual(gap, component.layout.gap);
|
|
2203
2666
|
try std.testing.expectEqual(WidgetCrossAlignment.center, component.layout.cross_alignment);
|
|
2204
|
-
try std.testing.expectEqual(WidgetRole.group, component.semantics.role);
|
|
2667
|
+
try std.testing.expectEqual(if (kind == .radio_group) WidgetRole.radiogroup else WidgetRole.group, component.semantics.role);
|
|
2205
2668
|
}
|
|
2206
2669
|
|
|
2207
2670
|
// The house TabsList: a muted rounded container hugging its
|
|
@@ -2524,6 +2987,85 @@ test "built-in alert renders house surface chrome and text" {
|
|
|
2524
2987
|
}
|
|
2525
2988
|
}
|
|
2526
2989
|
|
|
2990
|
+
test "destructive alerts tint every channel and compact defaults align chrome with content" {
|
|
2991
|
+
const tokens = DesignTokens{
|
|
2992
|
+
.controls = .{
|
|
2993
|
+
// One shared alert table may state neutral defaults; the
|
|
2994
|
+
// destructive variant still owns its hue.
|
|
2995
|
+
.alert = .{
|
|
2996
|
+
.background = Color.rgb8(12, 18, 24),
|
|
2997
|
+
.foreground = Color.rgb8(235, 240, 245),
|
|
2998
|
+
.border = Color.rgb8(54, 64, 74),
|
|
2999
|
+
},
|
|
3000
|
+
},
|
|
3001
|
+
};
|
|
3002
|
+
const destructive = Widget{
|
|
3003
|
+
.id = 42,
|
|
3004
|
+
.kind = .alert,
|
|
3005
|
+
.frame = geometry.RectF.init(0, 0, 320, 68),
|
|
3006
|
+
.text = "Session expired",
|
|
3007
|
+
.variant = .destructive,
|
|
3008
|
+
.state = .{ .disabled = true },
|
|
3009
|
+
.style = .{ .accent = Color.rgb8(196, 32, 64) },
|
|
3010
|
+
};
|
|
3011
|
+
var destructive_commands: [12]CanvasCommand = undefined;
|
|
3012
|
+
var destructive_builder = Builder.init(&destructive_commands);
|
|
3013
|
+
try emitWidgetTree(&destructive_builder, destructive, tokens);
|
|
3014
|
+
const destructive_hue = destructive.style.accent.?;
|
|
3015
|
+
const destructive_fill = colorWithAlpha(destructive_hue, tokens.states.destructive_wash_alpha * tokens.states.disabled_alpha);
|
|
3016
|
+
const destructive_border = colorWithAlpha(destructive_hue, 0.5 * tokens.states.disabled_alpha);
|
|
3017
|
+
const destructive_ink = colorWithAlpha(destructive_hue, tokens.states.disabled_alpha);
|
|
3018
|
+
switch (destructive_builder.displayList().findCommandById(widgetPartId(42, 1)).?.command) {
|
|
3019
|
+
.fill_rounded_rect => |fill| try expectFillColor(destructive_fill, fill.fill),
|
|
3020
|
+
else => return error.TestUnexpectedResult,
|
|
3021
|
+
}
|
|
3022
|
+
switch (destructive_builder.displayList().findCommandById(widgetPartId(42, 2)).?.command) {
|
|
3023
|
+
.stroke_rect => |stroke| try expectFillColor(destructive_border, stroke.stroke.fill),
|
|
3024
|
+
else => return error.TestUnexpectedResult,
|
|
3025
|
+
}
|
|
3026
|
+
switch (destructive_builder.displayList().findCommandById(widgetPartId(42, 4)).?.command) {
|
|
3027
|
+
.stroke_path => |stroke| try expectFillColor(destructive_ink, stroke.stroke.fill),
|
|
3028
|
+
else => return error.TestUnexpectedResult,
|
|
3029
|
+
}
|
|
3030
|
+
switch (destructive_builder.displayList().findCommandById(widgetPartId(42, 10)).?.command) {
|
|
3031
|
+
.draw_text => |text| try std.testing.expectEqualDeep(destructive_ink, text.color),
|
|
3032
|
+
else => return error.TestUnexpectedResult,
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
const description = [_]Widget{.{
|
|
3036
|
+
.id = 44,
|
|
3037
|
+
.kind = .text,
|
|
3038
|
+
.text = "Restart to update.",
|
|
3039
|
+
}};
|
|
3040
|
+
const compact = builtinComponentWidget(.alert, .{
|
|
3041
|
+
.id = 43,
|
|
3042
|
+
.frame = geometry.RectF.init(0, 0, 320, 80),
|
|
3043
|
+
.text = "Update available",
|
|
3044
|
+
.size = .sm,
|
|
3045
|
+
.children = &description,
|
|
3046
|
+
});
|
|
3047
|
+
// Stored kind default and token-resolved chrome share the 14px compact
|
|
3048
|
+
// inset; the 14px multiplicatively scaled icon plus 10px additive
|
|
3049
|
+
// text gap put title and child at x=38. The semantic title gap stays
|
|
3050
|
+
// 4px rather than shrinking with control chrome.
|
|
3051
|
+
try std.testing.expectEqual(@as(f32, 14), compact.layout.padding.top);
|
|
3052
|
+
try std.testing.expect(compact.layout.padding_is_kind_default);
|
|
3053
|
+
var compact_nodes: [2]WidgetLayoutNode = undefined;
|
|
3054
|
+
const compact_layout = try layoutWidgetTree(compact, compact.frame, &compact_nodes);
|
|
3055
|
+
const child = compact_layout.findById(44) orelse return error.TestUnexpectedResult;
|
|
3056
|
+
const text_size = widget_metrics.widgetBodyTextSize(compact, .{});
|
|
3057
|
+
try std.testing.expectApproxEqAbs(@as(f32, 38), child.frame.x, 0.001);
|
|
3058
|
+
try std.testing.expectApproxEqAbs(@as(f32, 14) + widget_metrics.widgetLineHeight(text_size) + 4, child.frame.y, 0.001);
|
|
3059
|
+
|
|
3060
|
+
var compact_commands: [16]CanvasCommand = undefined;
|
|
3061
|
+
var compact_builder = Builder.init(&compact_commands);
|
|
3062
|
+
try compact_layout.emitDisplayList(&compact_builder, .{});
|
|
3063
|
+
switch (compact_builder.displayList().findCommandById(widgetPartId(43, 10)).?.command) {
|
|
3064
|
+
.draw_text => |text| try std.testing.expectApproxEqAbs(child.frame.x, text.origin.x, 0.001),
|
|
3065
|
+
else => return error.TestUnexpectedResult,
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
|
|
2527
3069
|
test "built-in card renders house surface chrome and title" {
|
|
2528
3070
|
const card = builtinComponentWidget(.card, .{
|
|
2529
3071
|
.id = 44,
|
|
@@ -2758,10 +3300,13 @@ test "built-in modal surfaces render house chrome and semantics" {
|
|
|
2758
3300
|
const root = Widget{ .kind = .stack, .children = &.{ backdrop, dialog, drawer, sheet } };
|
|
2759
3301
|
var nodes: [5]WidgetLayoutNode = undefined;
|
|
2760
3302
|
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 920, 240), &nodes);
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
try std.testing.expectEqual(WidgetKind.
|
|
3303
|
+
// Modal placement is root-relative through the real layout pass:
|
|
3304
|
+
// dialog centered, drawer full-width at the bottom, sheet full-height
|
|
3305
|
+
// at the right. All three use the modal layer above the backdrop.
|
|
3306
|
+
try std.testing.expectEqual(WidgetKind.drawer, layout.hitTest(geometry.PointF.init(300, 220)).?.kind);
|
|
3307
|
+
try std.testing.expectEqual(WidgetKind.dialog, layout.hitTest(geometry.PointF.init(310, 50)).?.kind);
|
|
3308
|
+
try std.testing.expectEqual(WidgetKind.drawer, layout.hitTest(geometry.PointF.init(12, 100)).?.kind);
|
|
3309
|
+
try std.testing.expectEqual(WidgetKind.sheet, layout.hitTest(geometry.PointF.init(800, 12)).?.kind);
|
|
2765
3310
|
|
|
2766
3311
|
var semantics_buffer: [5]WidgetSemanticsNode = undefined;
|
|
2767
3312
|
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
@@ -3133,7 +3678,10 @@ test "built-in component primitive widgets render distinct house chrome" {
|
|
|
3133
3678
|
try layout.emitDisplayList(&builder, .{});
|
|
3134
3679
|
|
|
3135
3680
|
const display_list = builder.displayList();
|
|
3136
|
-
|
|
3681
|
+
// Eight live commands: avatar fill/text/stroke, badge fill/text (its
|
|
3682
|
+
// default zero-width edge emits nothing), separator, skeleton, and
|
|
3683
|
+
// spinner. This count deliberately excludes dead rasterizer work.
|
|
3684
|
+
try std.testing.expectEqual(@as(usize, 8), display_list.commandCount());
|
|
3137
3685
|
try std.testing.expect(display_list.commands[0] == .fill_rounded_rect);
|
|
3138
3686
|
switch (display_list.commands[1]) {
|
|
3139
3687
|
.draw_text => |text| try std.testing.expectEqualStrings("NS", text.text),
|
|
@@ -3144,16 +3692,16 @@ test "built-in component primitive widgets render distinct house chrome" {
|
|
|
3144
3692
|
.fill_rounded_rect => |fill| try expectFillColor(ColorTokens.light().accent, fill.fill),
|
|
3145
3693
|
else => return error.TestUnexpectedResult,
|
|
3146
3694
|
}
|
|
3147
|
-
switch (display_list.commands[
|
|
3695
|
+
switch (display_list.commands[4]) {
|
|
3148
3696
|
.draw_text => |text| try std.testing.expectEqualStrings("Beta", text.text),
|
|
3149
3697
|
else => return error.TestUnexpectedResult,
|
|
3150
3698
|
}
|
|
3151
|
-
try std.testing.expect(display_list.commands[
|
|
3152
|
-
try std.testing.expect(display_list.commands[
|
|
3699
|
+
try std.testing.expect(display_list.commands[5] == .fill_rect);
|
|
3700
|
+
try std.testing.expect(display_list.commands[6] == .fill_rounded_rect);
|
|
3153
3701
|
// The spinner (house arc register): ONE stroked arc in the page
|
|
3154
3702
|
// ink — no track — with the stroke scaling at 1/12 of the box
|
|
3155
3703
|
// (28px box -> 2.333px stroke).
|
|
3156
|
-
switch (display_list.commands[
|
|
3704
|
+
switch (display_list.commands[7]) {
|
|
3157
3705
|
.stroke_path => |arc| {
|
|
3158
3706
|
try expectFillColor(ColorTokens.light().text, arc.stroke.fill);
|
|
3159
3707
|
try std.testing.expectApproxEqAbs(@as(f32, 28.0 * 2.0 / 24.0), arc.stroke.width, 0.001);
|