@native-sdk/cli 0.7.1 → 0.7.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 +8 -0
- package/build.zig +49 -12
- package/native-sdk.d.ts +6 -3
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/skill-data/native-ui/SKILL.md +4 -2
- package/src/platform/macos/appkit_host.m +51 -3
- package/src/platform/types.zig +4 -0
- package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
- package/src/platform/windows/gpu_surface_renderer.h +86 -0
- package/src/platform/windows/root.zig +298 -20
- package/src/platform/windows/webview2_host.cpp +343 -33
- package/src/primitives/canvas/code.zig +50 -0
- package/src/primitives/canvas/code_tests.zig +174 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +2 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +52 -7
- package/src/primitives/canvas/ui_markup.zig +38 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +28 -0
- package/src/primitives/canvas/ui_markup_contract.zig +9 -0
- package/src/primitives/canvas/ui_markup_view.zig +28 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +10 -2
- package/src/primitives/canvas/ui_schema.zig +5 -0
- package/src/primitives/canvas/ui_schema_tests.zig +4 -3
- package/src/primitives/canvas/ui_tests.zig +14 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +11 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +45 -9
- package/src/primitives/canvas/widget_render.zig +220 -70
- package/src/primitives/canvas/widget_render_controls.zig +79 -21
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_text_input.zig +2 -0
- package/src/primitives/canvas/widgets.zig +53 -2
- package/src/runtime/canvas_frame.zig +60 -7
- package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
- package/src/runtime/canvas_frame_packet_tests.zig +83 -9
- package/src/runtime/canvas_frame_patch_tests.zig +16 -0
- package/src/runtime/canvas_images.zig +8 -2
- package/src/runtime/canvas_widget_clipboard_tests.zig +1 -1
- package/src/runtime/canvas_widget_runtime.zig +11 -8
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +38 -7
- package/src/runtime/media_surface_tests.zig +1 -1
- package/src/runtime/runtime_event_tests.zig +74 -0
- package/src/runtime/ui_app.zig +10 -8
- package/src/runtime/ui_app_tests.zig +67 -0
- package/src/runtime/view.zig +6 -0
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_text.zig +6 -4
- package/src/runtime/window_view_runtime.zig +1 -0
- package/src/tooling/templates.zig +9 -6
|
@@ -687,15 +687,13 @@ test "buttons draw an inline vector icon and label as one widget with one tint"
|
|
|
687
687
|
try std.testing.expect(icon_only_list.findCommandById(widgetPartId(63, 6)) != null);
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
-
test "disabled filled buttons
|
|
691
|
-
// A
|
|
692
|
-
//
|
|
693
|
-
//
|
|
694
|
-
//
|
|
695
|
-
//
|
|
696
|
-
//
|
|
697
|
-
// the quiet borderless chip, so its edge stays at width 0 in both
|
|
698
|
-
// states — nothing to wash.
|
|
690
|
+
test "disabled filled buttons match their reference edge treatment" {
|
|
691
|
+
// A primary button's implicit structural edge is the same accent as
|
|
692
|
+
// its opaque fill at rest. shadcn's actual edge is transparent; if
|
|
693
|
+
// the fill and fallback edge are each washed to half strength, their
|
|
694
|
+
// overlap becomes darker and invents an outline around the disabled
|
|
695
|
+
// control. Destructive is already the quiet borderless chip, so its
|
|
696
|
+
// edge stays at width 0 in both states.
|
|
699
697
|
const tokens = DesignTokens{};
|
|
700
698
|
const button = Widget{
|
|
701
699
|
.id = 71,
|
|
@@ -717,9 +715,21 @@ test "disabled filled buttons mute their border with the fill" {
|
|
|
717
715
|
var disabled_commands: [8]CanvasCommand = undefined;
|
|
718
716
|
var disabled_builder = Builder.init(&disabled_commands);
|
|
719
717
|
try emitWidgetTree(&disabled_builder, disabled, tokens);
|
|
720
|
-
const washed_border = Color.rgba(tokens.colors.accent.r, tokens.colors.accent.g, tokens.colors.accent.b, 0.5 * tokens.colors.accent.a);
|
|
721
718
|
switch (disabled_builder.displayList().findCommandById(widgetPartId(71, 2)).?.command) {
|
|
722
|
-
.stroke_rect => |stroke| try expectFillColor(
|
|
719
|
+
.stroke_rect => |stroke| try expectFillColor(Color.rgba8(0, 0, 0, 0), stroke.stroke.fill),
|
|
720
|
+
else => return error.TestUnexpectedResult,
|
|
721
|
+
}
|
|
722
|
+
// shadcn applies opacity to the composed button. Its knockout label
|
|
723
|
+
// therefore lands back near the matching page/surface color instead
|
|
724
|
+
// of being blended through the already-faded fill a second time.
|
|
725
|
+
const disabled_label = Color.rgba(
|
|
726
|
+
tokens.colors.accent_text.r * tokens.states.disabled_alpha + tokens.colors.background.r * (1 - tokens.states.disabled_alpha),
|
|
727
|
+
tokens.colors.accent_text.g * tokens.states.disabled_alpha + tokens.colors.background.g * (1 - tokens.states.disabled_alpha),
|
|
728
|
+
tokens.colors.accent_text.b * tokens.states.disabled_alpha + tokens.colors.background.b * (1 - tokens.states.disabled_alpha),
|
|
729
|
+
1,
|
|
730
|
+
);
|
|
731
|
+
switch (disabled_builder.displayList().findCommandById(widgetPartId(71, 4)).?.command) {
|
|
732
|
+
.draw_text => |text| try std.testing.expectEqualDeep(disabled_label, text.color),
|
|
723
733
|
else => return error.TestUnexpectedResult,
|
|
724
734
|
}
|
|
725
735
|
|
|
@@ -737,6 +747,114 @@ test "disabled filled buttons mute their border with the fill" {
|
|
|
737
747
|
}
|
|
738
748
|
}
|
|
739
749
|
|
|
750
|
+
test "geist disabled buttons use the reference swap and tertiary registers" {
|
|
751
|
+
const buttonFillColor = @import("widget_render_style.zig").buttonFillColor;
|
|
752
|
+
const buttonTextColorForWidget = @import("widget_render_style.zig").buttonTextColorForWidget;
|
|
753
|
+
const buttonBorderFill = @import("widget_render_style.zig").buttonBorderFill;
|
|
754
|
+
const schemes = [_]canvas.ColorScheme{ .light, .dark };
|
|
755
|
+
|
|
756
|
+
for (schemes) |scheme| {
|
|
757
|
+
const tokens = DesignTokens.theme(.{ .pack = .geist, .color_scheme = scheme });
|
|
758
|
+
const disabled_background = if (scheme == .light) Color.rgb8(242, 242, 242) else Color.rgb8(26, 26, 26);
|
|
759
|
+
const disabled_border = if (scheme == .light) Color.rgb8(235, 235, 235) else Color.rgb8(31, 31, 31);
|
|
760
|
+
const variants = [_]canvas.WidgetVariant{ .default, .secondary, .outline };
|
|
761
|
+
for (variants) |variant| {
|
|
762
|
+
const button = Widget{ .kind = .button, .variant = variant, .state = .{ .disabled = true } };
|
|
763
|
+
try std.testing.expectEqualDeep(disabled_background, buttonFillColor(button, tokens));
|
|
764
|
+
try std.testing.expectEqualDeep(Color.rgb8(143, 143, 143), buttonTextColorForWidget(button, tokens));
|
|
765
|
+
try expectFillColor(disabled_border, buttonBorderFill(button, tokens));
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
const filled_variants = [_]canvas.WidgetVariant{ .primary, .destructive };
|
|
769
|
+
for (filled_variants) |variant| {
|
|
770
|
+
const button = Widget{ .kind = .button, .variant = variant, .state = .{ .disabled = true } };
|
|
771
|
+
try std.testing.expectEqualDeep(disabled_background, buttonFillColor(button, tokens));
|
|
772
|
+
try std.testing.expectEqualDeep(Color.rgb8(143, 143, 143), buttonTextColorForWidget(button, tokens));
|
|
773
|
+
try expectFillColor(Color.rgba8(0, 0, 0, 0), buttonBorderFill(button, tokens));
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const tertiary = Widget{ .kind = .button, .variant = .ghost, .state = .{ .disabled = true } };
|
|
777
|
+
const tertiary_background = Color.rgba(
|
|
778
|
+
disabled_background.r * 0.5 + tokens.colors.background.r * 0.5,
|
|
779
|
+
disabled_background.g * 0.5 + tokens.colors.background.g * 0.5,
|
|
780
|
+
disabled_background.b * 0.5 + tokens.colors.background.b * 0.5,
|
|
781
|
+
1,
|
|
782
|
+
);
|
|
783
|
+
const tertiary_foreground = Color.rgba(
|
|
784
|
+
tokens.colors.text.r * 0.5 + tokens.colors.background.r * 0.5,
|
|
785
|
+
tokens.colors.text.g * 0.5 + tokens.colors.background.g * 0.5,
|
|
786
|
+
tokens.colors.text.b * 0.5 + tokens.colors.background.b * 0.5,
|
|
787
|
+
1,
|
|
788
|
+
);
|
|
789
|
+
try std.testing.expectEqualDeep(tertiary_background, buttonFillColor(tertiary, tokens));
|
|
790
|
+
try std.testing.expectEqualDeep(tertiary_foreground, buttonTextColorForWidget(tertiary, tokens));
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
test "disabled primary fallback honors the state alpha" {
|
|
795
|
+
const buttonTextColorForWidget = @import("widget_render_style.zig").buttonTextColorForWidget;
|
|
796
|
+
const background = Color.rgb8(20, 40, 60);
|
|
797
|
+
const accent_text = Color.rgb8(220, 180, 140);
|
|
798
|
+
const disabled_alpha: f32 = 0.25;
|
|
799
|
+
const tokens = DesignTokens.themeWithOverrides(.{}, .{
|
|
800
|
+
.colors = .{ .background = background, .accent_text = accent_text },
|
|
801
|
+
.states = .{ .disabled_alpha = disabled_alpha },
|
|
802
|
+
});
|
|
803
|
+
const button = Widget{ .kind = .button, .variant = .primary, .state = .{ .disabled = true } };
|
|
804
|
+
const expected = Color.rgba(
|
|
805
|
+
accent_text.r * disabled_alpha + background.r * (1 - disabled_alpha),
|
|
806
|
+
accent_text.g * disabled_alpha + background.g * (1 - disabled_alpha),
|
|
807
|
+
accent_text.b * disabled_alpha + background.b * (1 - disabled_alpha),
|
|
808
|
+
1,
|
|
809
|
+
);
|
|
810
|
+
try std.testing.expectEqualDeep(expected, buttonTextColorForWidget(button, tokens));
|
|
811
|
+
|
|
812
|
+
var transparent_state = tokens;
|
|
813
|
+
transparent_state.states.disabled_alpha = 0;
|
|
814
|
+
try std.testing.expectEqualDeep(background, buttonTextColorForWidget(button, transparent_state));
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
test "disabled filled buttons preserve explicit token borders" {
|
|
818
|
+
const buttonFillColor = @import("widget_render_style.zig").buttonFillColor;
|
|
819
|
+
const buttonBorderFill = @import("widget_render_style.zig").buttonBorderFill;
|
|
820
|
+
const disabled_background = Color.rgba8(80, 100, 120, 128);
|
|
821
|
+
const border = Color.rgb8(24, 96, 160);
|
|
822
|
+
const tokens = DesignTokens.themeWithOverrides(.{}, .{
|
|
823
|
+
.controls = .{
|
|
824
|
+
.button_primary = .{ .disabled_background = disabled_background, .border = border },
|
|
825
|
+
.button_destructive = .{ .disabled_background = disabled_background, .border = border },
|
|
826
|
+
},
|
|
827
|
+
});
|
|
828
|
+
const expected_border = Color.rgba(border.r, border.g, border.b, border.a * tokens.states.disabled_alpha);
|
|
829
|
+
const variants = [_]canvas.WidgetVariant{ .primary, .destructive };
|
|
830
|
+
for (variants) |variant| {
|
|
831
|
+
const button = Widget{ .kind = .button, .variant = variant, .state = .{ .disabled = true } };
|
|
832
|
+
try std.testing.expectEqualDeep(disabled_background, buttonFillColor(button, tokens));
|
|
833
|
+
try expectFillColor(expected_border, buttonBorderFill(button, tokens));
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
const implicit_tokens = DesignTokens.themeWithOverrides(.{}, .{
|
|
837
|
+
.controls = .{ .button_primary = .{ .disabled_background = disabled_background } },
|
|
838
|
+
});
|
|
839
|
+
const implicit = Widget{ .kind = .button, .variant = .primary, .state = .{ .disabled = true } };
|
|
840
|
+
try expectFillColor(Color.rgba8(0, 0, 0, 0), buttonBorderFill(implicit, implicit_tokens));
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
test "button disabled border override does not require a disabled background" {
|
|
844
|
+
const buttonBorderFill = @import("widget_render_style.zig").buttonBorderFill;
|
|
845
|
+
const disabled_border = Color.rgb8(24, 96, 160);
|
|
846
|
+
const tokens = DesignTokens.themeWithOverrides(.{}, .{
|
|
847
|
+
.controls = .{ .button_disabled_border = disabled_border },
|
|
848
|
+
});
|
|
849
|
+
const button = Widget{
|
|
850
|
+
.kind = .button,
|
|
851
|
+
.variant = .outline,
|
|
852
|
+
.state = .{ .disabled = true },
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
try expectFillColor(disabled_border, buttonBorderFill(button, tokens));
|
|
856
|
+
}
|
|
857
|
+
|
|
740
858
|
/// The flush-group segment assertions, shared by the tree-walk and
|
|
741
859
|
/// layout-walk halves of the test below so the two emission paths are
|
|
742
860
|
/// pinned to the SAME bar: leading corners on the first segment,
|
|
@@ -948,6 +1066,365 @@ test "underline tab strips separate triggers by the tabs metric gap" {
|
|
|
948
1066
|
try std.testing.expectApproxEqAbs(@as(f32, 0), pill_layout.nodes[2].frame.x - pill_layout.nodes[1].frame.maxX(), 0.001);
|
|
949
1067
|
}
|
|
950
1068
|
|
|
1069
|
+
test "geist primary tabs use the measured row while house tabs remain unchanged" {
|
|
1070
|
+
const triggers = [_]Widget{
|
|
1071
|
+
.{ .id = 2, .kind = .segmented_control, .text = "Apple", .state = .{ .selected = true, .disabled = true } },
|
|
1072
|
+
.{ .id = 3, .kind = .segmented_control, .text = "Orange" },
|
|
1073
|
+
.{ .id = 4, .kind = .segmented_control, .text = "Files", .icon = "folder" },
|
|
1074
|
+
};
|
|
1075
|
+
const strip = builtinComponentWidget(.tabs, .{
|
|
1076
|
+
.id = 1,
|
|
1077
|
+
.frame = geometry.RectF.init(0, 0, 240, 50),
|
|
1078
|
+
.children = &triggers,
|
|
1079
|
+
});
|
|
1080
|
+
try std.testing.expect(strip.layout.padding_is_kind_default);
|
|
1081
|
+
|
|
1082
|
+
const geist = DesignTokens.theme(.{ .pack = .geist });
|
|
1083
|
+
var geist_nodes: [4]WidgetLayoutNode = undefined;
|
|
1084
|
+
const geist_layout = try layoutWidgetTreeWithTokens(strip, strip.frame, geist, &geist_nodes);
|
|
1085
|
+
try std.testing.expectEqual(geometry.RectF.init(0, 0, geist_layout.nodes[1].frame.width, 50), geist_layout.nodes[1].frame);
|
|
1086
|
+
try std.testing.expectApproxEqAbs(@as(f32, 24), geist_layout.nodes[2].frame.x - geist_layout.nodes[1].frame.maxX(), 0.001);
|
|
1087
|
+
|
|
1088
|
+
var commands: [24]CanvasCommand = undefined;
|
|
1089
|
+
var builder = Builder.init(&commands);
|
|
1090
|
+
try geist_layout.emitDisplayList(&builder, geist);
|
|
1091
|
+
const list = builder.displayList();
|
|
1092
|
+
switch (list.findCommandById(widgetPartId(1, 2)).?.command) {
|
|
1093
|
+
.fill_rect => |rail| try std.testing.expectEqualDeep(geometry.RectF.init(0, 49, 240, 1), rail.rect),
|
|
1094
|
+
else => return error.TestUnexpectedResult,
|
|
1095
|
+
}
|
|
1096
|
+
switch (list.findCommandById(widgetPartId(2, 2)).?.command) {
|
|
1097
|
+
.fill_rect => |indicator| try std.testing.expectEqualDeep(geometry.RectF.init(0, 48, geist_layout.nodes[1].frame.width, 2), indicator.rect),
|
|
1098
|
+
else => return error.TestUnexpectedResult,
|
|
1099
|
+
}
|
|
1100
|
+
// Disabled does not dim the selected primary tab in the reference.
|
|
1101
|
+
switch (list.findCommandById(widgetPartId(2, 3)).?.command) {
|
|
1102
|
+
.draw_text => |label| {
|
|
1103
|
+
try std.testing.expectEqual(@as(f32, 14), label.size);
|
|
1104
|
+
try std.testing.expectEqualDeep(Color.rgb8(23, 23, 23), label.color);
|
|
1105
|
+
},
|
|
1106
|
+
else => return error.TestUnexpectedResult,
|
|
1107
|
+
}
|
|
1108
|
+
try std.testing.expect(list.findCommandById(widgetPartId(4, 5)) != null or list.findCommandById(widgetPartId(4, 6)) != null);
|
|
1109
|
+
|
|
1110
|
+
// A numerically identical 3px author inset is not the builder
|
|
1111
|
+
// default. Geist preserves it instead of translating it to the
|
|
1112
|
+
// underline register's zero inset.
|
|
1113
|
+
const explicitly_padded_strip = builtinComponentWidget(.tabs, .{
|
|
1114
|
+
.id = 11,
|
|
1115
|
+
.frame = geometry.RectF.init(0, 0, 240, 50),
|
|
1116
|
+
.layout = .{ .padding = geometry.InsetsF.all(3) },
|
|
1117
|
+
.children = &triggers,
|
|
1118
|
+
});
|
|
1119
|
+
try std.testing.expect(!explicitly_padded_strip.layout.padding_is_kind_default);
|
|
1120
|
+
var explicitly_padded_nodes: [4]WidgetLayoutNode = undefined;
|
|
1121
|
+
const explicitly_padded_layout = try layoutWidgetTreeWithTokens(explicitly_padded_strip, explicitly_padded_strip.frame, geist, &explicitly_padded_nodes);
|
|
1122
|
+
try std.testing.expectEqual(@as(f32, 3), explicitly_padded_layout.nodes[1].frame.x);
|
|
1123
|
+
try std.testing.expectEqual(@as(f32, 3), explicitly_padded_layout.nodes[1].frame.y);
|
|
1124
|
+
try std.testing.expectEqual(@as(f32, 44), explicitly_padded_layout.nodes[1].frame.height);
|
|
1125
|
+
|
|
1126
|
+
// The identical authored tree under the default register retains
|
|
1127
|
+
// its canonical 3px pill hug, 32px trigger, 13px label, and gap 0.
|
|
1128
|
+
const house = DesignTokens{};
|
|
1129
|
+
var house_nodes: [4]WidgetLayoutNode = undefined;
|
|
1130
|
+
const house_layout = try layoutWidgetTreeWithTokens(strip, strip.frame, house, &house_nodes);
|
|
1131
|
+
try std.testing.expectEqual(@as(f32, 3), house_layout.nodes[1].frame.x);
|
|
1132
|
+
try std.testing.expectEqual(@as(f32, 32), house_layout.nodes[1].frame.height);
|
|
1133
|
+
try std.testing.expectApproxEqAbs(@as(f32, 0), house_layout.nodes[2].frame.x - house_layout.nodes[1].frame.maxX(), 0.001);
|
|
1134
|
+
var house_commands: [24]CanvasCommand = undefined;
|
|
1135
|
+
var house_builder = Builder.init(&house_commands);
|
|
1136
|
+
try house_layout.emitDisplayList(&house_builder, house);
|
|
1137
|
+
switch (house_builder.displayList().findCommandById(widgetPartId(2, 3)).?.command) {
|
|
1138
|
+
.draw_text => |label| try std.testing.expectEqual(@as(f32, 13), label.size),
|
|
1139
|
+
else => return error.TestUnexpectedResult,
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// A theme-agnostic stack may carry the pill register's old hug
|
|
1143
|
+
// width. Geist translates that primary TabsList to the containing
|
|
1144
|
+
// width so the closing rail continues after the last trigger; the
|
|
1145
|
+
// identical house tree keeps its authored pill width.
|
|
1146
|
+
var nested_strip = strip;
|
|
1147
|
+
nested_strip.frame = geometry.RectF.init(0, 0, 148, 50);
|
|
1148
|
+
const nested_children = [_]Widget{nested_strip};
|
|
1149
|
+
const host = Widget{
|
|
1150
|
+
.kind = .stack,
|
|
1151
|
+
.frame = geometry.RectF.init(0, 0, 352, 80),
|
|
1152
|
+
.children = &nested_children,
|
|
1153
|
+
};
|
|
1154
|
+
var nested_geist_nodes: [5]WidgetLayoutNode = undefined;
|
|
1155
|
+
const nested_geist = try layoutWidgetTreeWithTokens(host, host.frame, geist, &nested_geist_nodes);
|
|
1156
|
+
try std.testing.expectEqual(@as(f32, 352), nested_geist.nodes[1].frame.width);
|
|
1157
|
+
var nested_geist_commands: [24]CanvasCommand = undefined;
|
|
1158
|
+
var nested_geist_builder = Builder.init(&nested_geist_commands);
|
|
1159
|
+
try nested_geist.emitDisplayList(&nested_geist_builder, geist);
|
|
1160
|
+
switch (nested_geist_builder.displayList().findCommandById(widgetPartId(1, 2)).?.command) {
|
|
1161
|
+
.fill_rect => |rail| try std.testing.expectEqualDeep(geometry.RectF.init(0, 49, 352, 1), rail.rect),
|
|
1162
|
+
else => return error.TestUnexpectedResult,
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
var nested_house_nodes: [5]WidgetLayoutNode = undefined;
|
|
1166
|
+
const nested_house = try layoutWidgetTreeWithTokens(host, host.frame, house, &nested_house_nodes);
|
|
1167
|
+
try std.testing.expectEqual(@as(f32, 148), nested_house.nodes[1].frame.width);
|
|
1168
|
+
var nested_house_commands: [24]CanvasCommand = undefined;
|
|
1169
|
+
var nested_house_builder = Builder.init(&nested_house_commands);
|
|
1170
|
+
try nested_house.emitDisplayList(&nested_house_builder, house);
|
|
1171
|
+
switch (nested_house_builder.displayList().findCommandById(widgetPartId(1, 1)).?.command) {
|
|
1172
|
+
.fill_rounded_rect => |pill| try std.testing.expectEqual(@as(f32, 148), pill.rect.width),
|
|
1173
|
+
else => return error.TestUnexpectedResult,
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// Underline paint does not imply Geist's width:100% policy. A
|
|
1177
|
+
// custom underline theme must opt into that layout metric, otherwise
|
|
1178
|
+
// the same authored strip keeps its 148px hug.
|
|
1179
|
+
var custom_underline = DesignTokens{};
|
|
1180
|
+
custom_underline.controls.tabs_indicator = .underline;
|
|
1181
|
+
var nested_custom_nodes: [5]WidgetLayoutNode = undefined;
|
|
1182
|
+
const nested_custom = try layoutWidgetTreeWithTokens(host, host.frame, custom_underline, &nested_custom_nodes);
|
|
1183
|
+
try std.testing.expectEqual(@as(f32, 148), nested_custom.nodes[1].frame.width);
|
|
1184
|
+
|
|
1185
|
+
// Full-width is a minimum, not a cap. A deliberately wider Geist
|
|
1186
|
+
// strip inside a horizontal viewport retains its authored overflow,
|
|
1187
|
+
// including when the strip clips its own trigger content: the rail and
|
|
1188
|
+
// the scroll semantics must cover the full scrollable width.
|
|
1189
|
+
var wide_strip = nested_strip;
|
|
1190
|
+
wide_strip.frame.width = 480;
|
|
1191
|
+
wide_strip.layout.clip_content = true;
|
|
1192
|
+
const wide_scroll_children = [_]Widget{wide_strip};
|
|
1193
|
+
const wide_scroll = Widget{
|
|
1194
|
+
.id = 7,
|
|
1195
|
+
.kind = .scroll_view,
|
|
1196
|
+
.frame = geometry.RectF.init(0, 0, 240, 50),
|
|
1197
|
+
.scroll_axes = .horizontal,
|
|
1198
|
+
.layout = .{ .clip_content = true },
|
|
1199
|
+
.children = &wide_scroll_children,
|
|
1200
|
+
};
|
|
1201
|
+
var wide_scroll_nodes: [5]WidgetLayoutNode = undefined;
|
|
1202
|
+
const wide_scroll_layout = try layoutWidgetTreeWithTokens(wide_scroll, wide_scroll.frame, geist, &wide_scroll_nodes);
|
|
1203
|
+
try std.testing.expectEqual(@as(f32, 480), wide_scroll_layout.findById(1).?.frame.width);
|
|
1204
|
+
var wide_scroll_commands: [32]CanvasCommand = undefined;
|
|
1205
|
+
var wide_scroll_builder = Builder.init(&wide_scroll_commands);
|
|
1206
|
+
try wide_scroll_layout.emitDisplayList(&wide_scroll_builder, geist);
|
|
1207
|
+
switch (wide_scroll_builder.displayList().findCommandById(widgetPartId(1, 2)).?.command) {
|
|
1208
|
+
.fill_rect => |rail| try std.testing.expectEqual(@as(f32, 480), rail.rect.width),
|
|
1209
|
+
else => return error.TestUnexpectedResult,
|
|
1210
|
+
}
|
|
1211
|
+
var wide_scroll_semantics_buffer: [5]WidgetSemanticsNode = undefined;
|
|
1212
|
+
const wide_scroll_semantics = try wide_scroll_layout.collectSemantics(&wide_scroll_semantics_buffer);
|
|
1213
|
+
try std.testing.expect(wide_scroll_semantics[0].scroll.present);
|
|
1214
|
+
try std.testing.expectEqual(@as(f32, 240), wide_scroll_semantics[0].scroll.viewport_extent);
|
|
1215
|
+
try std.testing.expectEqual(@as(f32, 480), wide_scroll_semantics[0].scroll.content_extent);
|
|
1216
|
+
|
|
1217
|
+
// Flow layout keeps the same contract. The row + growing spacer is
|
|
1218
|
+
// the common theme-agnostic shape used to make the house strip hug;
|
|
1219
|
+
// Geist gives the TabsList first claim on the row's flexible width,
|
|
1220
|
+
// while the identical house tree leaves that width to the spacer.
|
|
1221
|
+
const row_children = [_]Widget{
|
|
1222
|
+
nested_strip,
|
|
1223
|
+
.{ .id = 5, .kind = .stack, .layout = .{ .grow = 1 } },
|
|
1224
|
+
};
|
|
1225
|
+
const row_host = Widget{
|
|
1226
|
+
.kind = .row,
|
|
1227
|
+
.frame = geometry.RectF.init(0, 0, 352, 50),
|
|
1228
|
+
.children = &row_children,
|
|
1229
|
+
};
|
|
1230
|
+
var row_geist_nodes: [6]WidgetLayoutNode = undefined;
|
|
1231
|
+
const row_geist = try layoutWidgetTreeWithTokens(row_host, row_host.frame, geist, &row_geist_nodes);
|
|
1232
|
+
try std.testing.expectEqual(@as(f32, 352), row_geist.nodes[1].frame.width);
|
|
1233
|
+
try std.testing.expectEqual(@as(f32, 0), row_geist.nodes[5].frame.width);
|
|
1234
|
+
|
|
1235
|
+
var row_house_nodes: [6]WidgetLayoutNode = undefined;
|
|
1236
|
+
const row_house = try layoutWidgetTreeWithTokens(row_host, row_host.frame, house, &row_house_nodes);
|
|
1237
|
+
try std.testing.expectEqual(@as(f32, 148), row_house.nodes[1].frame.width);
|
|
1238
|
+
try std.testing.expectEqual(@as(f32, 204), row_house.nodes[5].frame.width);
|
|
1239
|
+
|
|
1240
|
+
var row_custom_nodes: [6]WidgetLayoutNode = undefined;
|
|
1241
|
+
const row_custom = try layoutWidgetTreeWithTokens(row_host, row_host.frame, custom_underline, &row_custom_nodes);
|
|
1242
|
+
try std.testing.expectEqual(@as(f32, 148), row_custom.nodes[1].frame.width);
|
|
1243
|
+
try std.testing.expectEqual(@as(f32, 204), row_custom.nodes[5].frame.width);
|
|
1244
|
+
|
|
1245
|
+
// Anchored primary tabs consume no flow allocation, including the
|
|
1246
|
+
// second pass that totals clamped fill widths. The bounded flow tab
|
|
1247
|
+
// takes its 100px maximum and leaves the rest to the growing sibling.
|
|
1248
|
+
var bounded_strip = nested_strip;
|
|
1249
|
+
bounded_strip.layout.max_size.width = 100;
|
|
1250
|
+
const anchored_strip = Widget{
|
|
1251
|
+
.id = 6,
|
|
1252
|
+
.kind = .tabs,
|
|
1253
|
+
.frame = geometry.RectF.init(0, 0, 40, 50),
|
|
1254
|
+
.layout = .{ .anchor = .{} },
|
|
1255
|
+
};
|
|
1256
|
+
const anchored_row_children = [_]Widget{
|
|
1257
|
+
bounded_strip,
|
|
1258
|
+
.{ .id = 5, .kind = .stack, .layout = .{ .grow = 1 } },
|
|
1259
|
+
anchored_strip,
|
|
1260
|
+
};
|
|
1261
|
+
var anchored_row = row_host;
|
|
1262
|
+
anchored_row.children = &anchored_row_children;
|
|
1263
|
+
var anchored_row_nodes: [7]WidgetLayoutNode = undefined;
|
|
1264
|
+
const anchored_row_layout = try layoutWidgetTreeWithTokens(anchored_row, anchored_row.frame, geist, &anchored_row_nodes);
|
|
1265
|
+
try std.testing.expectEqual(@as(f32, 100), anchored_row_layout.findById(1).?.frame.width);
|
|
1266
|
+
try std.testing.expectEqual(@as(f32, 252), anchored_row_layout.findById(5).?.frame.width);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
test "geist primary tabs translate fixed trigger frames onto the content-hugging underline register" {
|
|
1270
|
+
const tokens = DesignTokens.theme(.{ .pack = .geist });
|
|
1271
|
+
const triggers = [_]Widget{.{
|
|
1272
|
+
.id = 2,
|
|
1273
|
+
.kind = .segmented_control,
|
|
1274
|
+
// A theme-agnostic tree can retain the house trigger's fixed
|
|
1275
|
+
// height and a wider hit target. Geist must still join the active
|
|
1276
|
+
// marker to its 50px rail and keep that marker on the content.
|
|
1277
|
+
.frame = geometry.RectF.init(0, 0, 120, 32),
|
|
1278
|
+
.text = "Files",
|
|
1279
|
+
.icon = "folder",
|
|
1280
|
+
.state = .{ .selected = true },
|
|
1281
|
+
}};
|
|
1282
|
+
const strip = builtinComponentWidget(.tabs, .{
|
|
1283
|
+
.id = 1,
|
|
1284
|
+
.frame = geometry.RectF.init(0, 0, 240, 50),
|
|
1285
|
+
.children = &triggers,
|
|
1286
|
+
});
|
|
1287
|
+
|
|
1288
|
+
var nodes: [3]WidgetLayoutNode = undefined;
|
|
1289
|
+
const layout = try layoutWidgetTreeWithTokens(strip, strip.frame, tokens, &nodes);
|
|
1290
|
+
const trigger = layout.findById(2).?.widget;
|
|
1291
|
+
try std.testing.expectEqual(@as(f32, 50), trigger.frame.height);
|
|
1292
|
+
try std.testing.expectEqual(@as(f32, 120), trigger.frame.width);
|
|
1293
|
+
|
|
1294
|
+
var commands: [16]CanvasCommand = undefined;
|
|
1295
|
+
var builder = Builder.init(&commands);
|
|
1296
|
+
try layout.emitDisplayList(&builder, tokens);
|
|
1297
|
+
switch (builder.displayList().findCommandById(widgetPartId(2, 2)).?.command) {
|
|
1298
|
+
.fill_rect => |indicator| {
|
|
1299
|
+
try std.testing.expectEqual(@as(f32, 48), indicator.rect.y);
|
|
1300
|
+
try std.testing.expectEqual(@as(f32, 2), indicator.rect.height);
|
|
1301
|
+
try std.testing.expect(indicator.rect.width < trigger.frame.width);
|
|
1302
|
+
|
|
1303
|
+
var hug_trigger = trigger;
|
|
1304
|
+
hug_trigger.frame = geometry.RectF.init(0, 0, 0, 0);
|
|
1305
|
+
const hug_width = intrinsicWidgetSize(hug_trigger, tokens).width;
|
|
1306
|
+
try std.testing.expectApproxEqAbs(hug_width, indicator.rect.width, 1);
|
|
1307
|
+
try std.testing.expectApproxEqAbs(trigger.frame.center().x, indicator.rect.center().x, 0.5);
|
|
1308
|
+
},
|
|
1309
|
+
else => return error.TestUnexpectedResult,
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
test "geist primary tabs fill the remaining width of an indented vertical flow" {
|
|
1314
|
+
const geist = DesignTokens.theme(.{ .pack = .geist });
|
|
1315
|
+
const triggers = [_]Widget{.{
|
|
1316
|
+
.id = 3,
|
|
1317
|
+
.kind = .segmented_control,
|
|
1318
|
+
.text = "Files",
|
|
1319
|
+
.state = .{ .selected = true },
|
|
1320
|
+
}};
|
|
1321
|
+
const strip = builtinComponentWidget(.tabs, .{
|
|
1322
|
+
.id = 2,
|
|
1323
|
+
.frame = geometry.RectF.init(20, 0, 148, 50),
|
|
1324
|
+
.children = &triggers,
|
|
1325
|
+
});
|
|
1326
|
+
const children = [_]Widget{strip};
|
|
1327
|
+
const column = Widget{
|
|
1328
|
+
.id = 1,
|
|
1329
|
+
.kind = .column,
|
|
1330
|
+
.frame = geometry.RectF.init(0, 0, 352, 80),
|
|
1331
|
+
.children = &children,
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
1335
|
+
const layout = try layoutWidgetTreeWithTokens(column, column.frame, geist, &nodes);
|
|
1336
|
+
try std.testing.expectEqual(geometry.RectF.init(20, 0, 332, 50), layout.findById(2).?.frame);
|
|
1337
|
+
|
|
1338
|
+
// Full width remains a floor, not a cap: an authored overflow keeps
|
|
1339
|
+
// its extent just as it does in stack and horizontal-scroll parents.
|
|
1340
|
+
var wide_strip = strip;
|
|
1341
|
+
wide_strip.frame.width = 480;
|
|
1342
|
+
const wide_children = [_]Widget{wide_strip};
|
|
1343
|
+
var wide_column = column;
|
|
1344
|
+
wide_column.children = &wide_children;
|
|
1345
|
+
var wide_nodes: [4]WidgetLayoutNode = undefined;
|
|
1346
|
+
const wide_layout = try layoutWidgetTreeWithTokens(wide_column, wide_column.frame, geist, &wide_nodes);
|
|
1347
|
+
try std.testing.expectEqual(geometry.RectF.init(20, 0, 480, 50), wide_layout.findById(2).?.frame);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
test "geist primary tabs preserve authored overflow in rows" {
|
|
1351
|
+
const geist = DesignTokens.theme(.{ .pack = .geist });
|
|
1352
|
+
const triggers = [_]Widget{.{
|
|
1353
|
+
.id = 3,
|
|
1354
|
+
.kind = .segmented_control,
|
|
1355
|
+
.text = "Files",
|
|
1356
|
+
.state = .{ .selected = true },
|
|
1357
|
+
}};
|
|
1358
|
+
const strip = builtinComponentWidget(.tabs, .{
|
|
1359
|
+
.id = 2,
|
|
1360
|
+
.frame = geometry.RectF.init(0, 0, 480, 50),
|
|
1361
|
+
.children = &triggers,
|
|
1362
|
+
});
|
|
1363
|
+
const children = [_]Widget{
|
|
1364
|
+
strip,
|
|
1365
|
+
.{ .id = 4, .kind = .stack, .layout = .{ .grow = 1 } },
|
|
1366
|
+
};
|
|
1367
|
+
const row = Widget{
|
|
1368
|
+
.id = 1,
|
|
1369
|
+
.kind = .row,
|
|
1370
|
+
.frame = geometry.RectF.init(0, 0, 352, 50),
|
|
1371
|
+
.children = &children,
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
var nodes: [5]WidgetLayoutNode = undefined;
|
|
1375
|
+
const layout = try layoutWidgetTreeWithTokens(row, row.frame, geist, &nodes);
|
|
1376
|
+
try std.testing.expectEqual(@as(f32, 480), layout.findById(2).?.frame.width);
|
|
1377
|
+
try std.testing.expectEqual(@as(f32, 0), layout.findById(4).?.frame.width);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
test "geist primary tabs fill regular and virtual grid cells" {
|
|
1381
|
+
const geist = DesignTokens.theme(.{ .pack = .geist });
|
|
1382
|
+
const house = DesignTokens{};
|
|
1383
|
+
const triggers = [_]Widget{.{
|
|
1384
|
+
.id = 3,
|
|
1385
|
+
.kind = .segmented_control,
|
|
1386
|
+
.text = "Files",
|
|
1387
|
+
.state = .{ .selected = true },
|
|
1388
|
+
}};
|
|
1389
|
+
const strip = builtinComponentWidget(.tabs, .{
|
|
1390
|
+
.id = 2,
|
|
1391
|
+
.frame = geometry.RectF.init(0, 0, 148, 50),
|
|
1392
|
+
.children = &triggers,
|
|
1393
|
+
});
|
|
1394
|
+
const children = [_]Widget{strip};
|
|
1395
|
+
const grid = Widget{
|
|
1396
|
+
.id = 1,
|
|
1397
|
+
.kind = .grid,
|
|
1398
|
+
.frame = geometry.RectF.init(0, 0, 352, 50),
|
|
1399
|
+
.layout = .{ .columns = 1 },
|
|
1400
|
+
.children = &children,
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
var geist_nodes: [4]WidgetLayoutNode = undefined;
|
|
1404
|
+
const geist_layout = try layoutWidgetTreeWithTokens(grid, grid.frame, geist, &geist_nodes);
|
|
1405
|
+
try std.testing.expectEqual(@as(f32, 352), geist_layout.findById(2).?.frame.width);
|
|
1406
|
+
|
|
1407
|
+
var house_nodes: [4]WidgetLayoutNode = undefined;
|
|
1408
|
+
const house_layout = try layoutWidgetTreeWithTokens(grid, grid.frame, house, &house_nodes);
|
|
1409
|
+
try std.testing.expectEqual(@as(f32, 148), house_layout.findById(2).?.frame.width);
|
|
1410
|
+
|
|
1411
|
+
var virtual_grid = grid;
|
|
1412
|
+
virtual_grid.layout.virtualized = true;
|
|
1413
|
+
virtual_grid.layout.virtual_item_extent = 50;
|
|
1414
|
+
var virtual_nodes: [4]WidgetLayoutNode = undefined;
|
|
1415
|
+
const virtual_layout = try layoutWidgetTreeWithTokens(virtual_grid, virtual_grid.frame, geist, &virtual_nodes);
|
|
1416
|
+
try std.testing.expectEqual(@as(f32, 352), virtual_layout.findById(2).?.frame.width);
|
|
1417
|
+
|
|
1418
|
+
var wide_strip = strip;
|
|
1419
|
+
wide_strip.frame.width = 480;
|
|
1420
|
+
const wide_children = [_]Widget{wide_strip};
|
|
1421
|
+
var wide_grid = grid;
|
|
1422
|
+
wide_grid.children = &wide_children;
|
|
1423
|
+
var wide_nodes: [4]WidgetLayoutNode = undefined;
|
|
1424
|
+
const wide_layout = try layoutWidgetTreeWithTokens(wide_grid, wide_grid.frame, geist, &wide_nodes);
|
|
1425
|
+
try std.testing.expectEqual(@as(f32, 480), wide_layout.findById(2).?.frame.width);
|
|
1426
|
+
}
|
|
1427
|
+
|
|
951
1428
|
test "the bubble reaction pill straddles the bottom edge on the page plane" {
|
|
952
1429
|
const surfaces = @import("widget_render_surfaces.zig");
|
|
953
1430
|
const tokens = DesignTokens{};
|
|
@@ -1172,6 +1649,22 @@ test "list and menu items draw a leading vector icon with the label shifted righ
|
|
|
1172
1649
|
const registered = canvas.icons.find("folder").?;
|
|
1173
1650
|
try std.testing.expectEqual(registered.elements.ptr, icon_stroke.elements.ptr);
|
|
1174
1651
|
|
|
1652
|
+
// `tree_level` is logical hierarchy metadata, not renderer-owned
|
|
1653
|
+
// spacing. A flat tree can author indentation with ordinary layout
|
|
1654
|
+
// (including a composed list row), so the same built-in row keeps its
|
|
1655
|
+
// label position when only its semantic level changes.
|
|
1656
|
+
var tree_child = plain;
|
|
1657
|
+
tree_child.semantics.role = .treeitem;
|
|
1658
|
+
tree_child.tree_level = 2;
|
|
1659
|
+
var tree_commands: [8]CanvasCommand = undefined;
|
|
1660
|
+
var tree_builder = Builder.init(&tree_commands);
|
|
1661
|
+
try emitWidgetTree(&tree_builder, tree_child, tokens);
|
|
1662
|
+
const tree_label = switch (tree_builder.displayList().findCommandById(widgetPartId(70, 3)).?.command) {
|
|
1663
|
+
.draw_text => |text| text,
|
|
1664
|
+
else => return error.TestUnexpectedResult,
|
|
1665
|
+
};
|
|
1666
|
+
try std.testing.expectEqualDeep(plain_label.origin, tree_label.origin);
|
|
1667
|
+
|
|
1175
1668
|
// menu_item keeps the same leading-icon slot contract even though
|
|
1176
1669
|
// it draws with its own emitter (menu rows add the trailing
|
|
1177
1670
|
// checkmark slot and drop the focus ring).
|
|
@@ -1186,8 +1679,10 @@ test "list and menu items draw a leading vector icon with the label shifted righ
|
|
|
1186
1679
|
// Intrinsic row width grows by the shared icon metrics; height holds.
|
|
1187
1680
|
const plain_size = canvas.intrinsicWidgetSize(plain, tokens);
|
|
1188
1681
|
const iconed_size = canvas.intrinsicWidgetSize(iconed, tokens);
|
|
1682
|
+
const tree_size = canvas.intrinsicWidgetSize(tree_child, tokens);
|
|
1189
1683
|
try std.testing.expect(iconed_size.width > plain_size.width);
|
|
1190
1684
|
try std.testing.expectEqual(plain_size.height, iconed_size.height);
|
|
1685
|
+
try std.testing.expectEqualDeep(plain_size, tree_size);
|
|
1191
1686
|
}
|
|
1192
1687
|
|
|
1193
1688
|
test "menu rows wash the active row, never outline, and checkmark the committed row" {
|
|
@@ -1748,7 +2243,12 @@ test "built-in component factory applies house composite defaults" {
|
|
|
1748
2243
|
.layout = .{ .gap = 4 },
|
|
1749
2244
|
});
|
|
1750
2245
|
try std.testing.expectEqual(@as(f32, 3), custom_tabs.layout.padding.top);
|
|
2246
|
+
try std.testing.expect(custom_tabs.layout.padding_is_kind_default);
|
|
1751
2247
|
try std.testing.expectEqual(@as(f32, 4), custom_tabs.layout.gap);
|
|
2248
|
+
const explicitly_padded_tabs = builtinComponentWidget(.tabs, .{
|
|
2249
|
+
.layout = .{ .padding = geometry.InsetsF.all(3) },
|
|
2250
|
+
});
|
|
2251
|
+
try std.testing.expect(!explicitly_padded_tabs.layout.padding_is_kind_default);
|
|
1752
2252
|
const padded_card = builtinComponentWidget(.card, .{
|
|
1753
2253
|
.layout = .{ .padding = geometry.InsetsF.all(8) },
|
|
1754
2254
|
});
|
|
@@ -3295,8 +3795,8 @@ test "label-exact controls at intrinsic width never elide under geometry pixel s
|
|
|
3295
3795
|
// edge, at both snap scales, across labels whose fractional widths
|
|
3296
3796
|
// land on both sides of the rounding boundary.
|
|
3297
3797
|
const kinds = [_]canvas.WidgetKind{
|
|
3298
|
-
.toggle_button, .button, .toggle,
|
|
3299
|
-
.menu_item, .checkbox, .radio,
|
|
3798
|
+
.toggle_button, .button, .toggle, .segmented_control,
|
|
3799
|
+
.menu_item, .checkbox, .radio, .switch_control,
|
|
3300
3800
|
.tooltip, .badge, .list_item,
|
|
3301
3801
|
};
|
|
3302
3802
|
const labels = [_][]const u8{ "PID", "CPU", "Memory", "Name", "Filter processes", "Quarterly report" };
|
|
@@ -260,6 +260,8 @@ fn terminalBindingClean(previous: widget_model.TerminalBinding, next: widget_mod
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
fn widgetChange(previous: WidgetLayoutNode, next: WidgetLayoutNode, previous_index: usize, next_index: usize, tokens: DesignTokens) WidgetInvalidation {
|
|
263
|
+
const previous_diff_lines = previous.widget.codeDiffLines();
|
|
264
|
+
const next_diff_lines = next.widget.codeDiffLines();
|
|
263
265
|
const layout_dirty =
|
|
264
266
|
previous.widget.kind != next.widget.kind or
|
|
265
267
|
previous.depth != next.depth or
|
|
@@ -271,7 +273,9 @@ fn widgetChange(previous: WidgetLayoutNode, next: WidgetLayoutNode, previous_ind
|
|
|
271
273
|
!textSpansEqual(previous.widget.spans, next.widget.spans) or
|
|
272
274
|
previous.widget.code_language != next.widget.code_language or
|
|
273
275
|
previous.widget.static_text_group_id != next.widget.static_text_group_id or
|
|
274
|
-
|
|
276
|
+
!codeDiffLinesEqual(previous_diff_lines, next_diff_lines) or
|
|
277
|
+
(previous_diff_lines == null and next_diff_lines == null and
|
|
278
|
+
previous.widget.static_text_group_offset != next.widget.static_text_group_offset) or
|
|
275
279
|
!chartDataEqual(previous.widget.chart, next.widget.chart) or
|
|
276
280
|
!std.mem.eql(u8, previous.widget.placeholder, next.widget.placeholder) or
|
|
277
281
|
!std.mem.eql(u8, previous.widget.icon, next.widget.icon) or
|
|
@@ -446,6 +450,11 @@ fn optionalPointsEqual(a: ?geometry.PointF, b: ?geometry.PointF) bool {
|
|
|
446
450
|
return b == null;
|
|
447
451
|
}
|
|
448
452
|
|
|
453
|
+
fn codeDiffLinesEqual(a: ?widget_model.CodeDiffLines, b: ?widget_model.CodeDiffLines) bool {
|
|
454
|
+
if (a == null or b == null) return a == null and b == null;
|
|
455
|
+
return a.?.added == b.?.added and a.?.removed == b.?.removed;
|
|
456
|
+
}
|
|
457
|
+
|
|
449
458
|
/// The paint bounds of every `.input_group` ancestor's focus ring for a
|
|
450
459
|
/// focus-visible widget id (null when the id resolves outside any group).
|
|
451
460
|
fn inputGroupFocusWithinBounds(layout: anytype, maybe_id: ?ObjectId, tokens: DesignTokens) ?geometry.RectF {
|
|
@@ -771,6 +780,7 @@ fn widgetStatesEqual(a: WidgetState, b: WidgetState) bool {
|
|
|
771
780
|
|
|
772
781
|
fn widgetLayoutStylesEqual(a: WidgetLayoutStyle, b: WidgetLayoutStyle) bool {
|
|
773
782
|
return insetsEqual(a.padding, b.padding) and
|
|
783
|
+
a.padding_is_kind_default == b.padding_is_kind_default and
|
|
774
784
|
a.gap == b.gap and
|
|
775
785
|
a.grow == b.grow and
|
|
776
786
|
a.main_alignment == b.main_alignment and
|