@native-sdk/cli 0.7.1 → 0.8.0
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 +273 -65
- package/build/ts_run.mjs +6 -8
- package/build.zig +341 -361
- package/native-sdk.d.ts +6 -3
- package/package.json +13 -11
- package/packages/core/compile-surface/core.ts +559 -0
- package/packages/core/package-lock.json +375 -12
- package/packages/core/package.json +9 -6
- package/packages/core/scripts/compiler_typecheck.mjs +58 -0
- package/packages/core/scripts/gen_case_tables.mjs +130 -0
- package/packages/core/scripts/gen_declarations.mjs +97 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +108 -0
- package/packages/core/scripts/stage_external_core.mjs +148 -0
- package/packages/core/sdk/core.d.ts +363 -0
- package/packages/core/sdk/events.d.ts +65 -0
- package/packages/core/sdk/text.d.ts +51 -0
- package/packages/core/src/checker.ts +3 -3
- package/packages/core/src/cli.ts +40 -38
- package/packages/core/src/contract.ts +749 -0
- package/packages/core/src/devhost.ts +4 -3
- package/packages/core/src/diagnostics.ts +5 -7
- package/packages/core/src/{transpile.ts → frontend.ts} +38 -50
- package/packages/core/src/infer.ts +1 -1
- package/packages/core/src/typed_ast.ts +16 -15
- package/packages/core/src/wyhash.ts +79 -0
- package/skill-data/native-ui/SKILL.md +4 -2
- package/skill-data/ts-core/SKILL.md +29 -29
- 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/ts_core_host.zig +38 -38
- package/src/runtime/ts_ui_app.zig +12 -12
- 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/manifest.zig +32 -0
- package/src/tooling/raw_manifest.zig +4 -0
- package/src/tooling/templates.zig +34 -26
- package/src/tooling/ts_core.zig +55 -34
- package/src/tooling/verbs.zig +1 -1
- package/tools/corewire/core_abi.zig +169 -0
- package/tools/corewire/emit.zig +2418 -0
- package/tools/corewire/emit_facade.zig +3984 -0
- package/tools/corewire/emit_profile.zig +501 -0
- package/tools/corewire/main.zig +561 -0
- package/tools/corewire/shim_rt.zig +632 -0
- package/tools/corewire/sidecar.zig +2507 -0
- package/packages/core/rt/rt.zig +0 -1986
- package/packages/core/src/emitter.ts +0 -11898
|
@@ -34,6 +34,12 @@ const booleanControlSelected = widget_access.booleanControlSelected;
|
|
|
34
34
|
const widgetButtonTextSize = widget_metrics.widgetButtonTextSize;
|
|
35
35
|
const widgetBodyTextSize = widget_metrics.widgetBodyTextSize;
|
|
36
36
|
const widgetLabelTextSize = widget_metrics.widgetLabelTextSize;
|
|
37
|
+
const widgetTabTriggerTextSize = widget_metrics.widgetTabTriggerTextSize;
|
|
38
|
+
const widgetTabTriggerHeight = widget_metrics.widgetTabTriggerHeight;
|
|
39
|
+
const widgetTabTriggerInset = widget_metrics.widgetTabTriggerInset;
|
|
40
|
+
const widgetTabTriggerIconExtent = widget_metrics.widgetTabTriggerIconExtent;
|
|
41
|
+
const widgetTabTriggerIconGap = widget_metrics.widgetTabTriggerIconGap;
|
|
42
|
+
const underlineTabsListInset = widget_metrics.underlineTabsListInset;
|
|
37
43
|
const widgetTypographySize = widget_metrics.widgetTypographySize;
|
|
38
44
|
const widgetLineHeight = widget_metrics.widgetLineHeight;
|
|
39
45
|
const widgetDefaultRowHeight = widget_metrics.widgetDefaultRowHeight;
|
|
@@ -71,7 +77,8 @@ pub fn layoutWidgetDepth(
|
|
|
71
77
|
};
|
|
72
78
|
len.* += 1;
|
|
73
79
|
|
|
74
|
-
const
|
|
80
|
+
const layout_padding = if (widget.kind == .tabs) tabsLayoutPadding(widget, tokens) else widget.layout.padding;
|
|
81
|
+
const content = windowControlsClearedContent(frame.inset(layout_padding), widget, tokens);
|
|
75
82
|
switch (widget.kind) {
|
|
76
83
|
.row, .breadcrumb, .pagination, .radio_group, .toggle_group => try layoutAxisChildren(widget.children, content, .horizontal, index, depth, output, len, widget.layout, tokens),
|
|
77
84
|
// Button groups flow like rows but at their register's effective
|
|
@@ -81,7 +88,7 @@ pub fn layoutWidgetDepth(
|
|
|
81
88
|
// Tab strips flow the same way: the underline register supplies
|
|
82
89
|
// its own inter-trigger gap when the author left the strip's gap
|
|
83
90
|
// at 0 (the house pill container keeps its flush triggers).
|
|
84
|
-
.tabs => try
|
|
91
|
+
.tabs => try layoutTabsChildren(widget, content, index, depth, output, len, tokens),
|
|
85
92
|
.column => try layoutAxisChildren(widget.children, content, .vertical, index, depth, output, len, widget.layout, tokens),
|
|
86
93
|
// The grouped input flows vertically inside its own field chrome:
|
|
87
94
|
// the text entry (grow-stretched by `Ui.inputGroup`) above the
|
|
@@ -123,7 +130,7 @@ pub fn layoutWidgetDepth(
|
|
|
123
130
|
const child_content = accordionContentFrame(widget, content, tokens, depth);
|
|
124
131
|
for (widget.children) |child| {
|
|
125
132
|
if (child.layout.anchor != null) continue;
|
|
126
|
-
_ = try layoutWidgetDepth(child, stackChildFrame(child_content, child), index, depth + 1, output, len, tokens);
|
|
133
|
+
_ = try layoutWidgetDepth(child, stackChildFrame(child_content, child, tokens), index, depth + 1, output, len, tokens);
|
|
127
134
|
}
|
|
128
135
|
},
|
|
129
136
|
.alert => {
|
|
@@ -133,13 +140,13 @@ pub fn layoutWidgetDepth(
|
|
|
133
140
|
const child_content = alertContentFrame(widget, content, tokens);
|
|
134
141
|
for (widget.children) |child| {
|
|
135
142
|
if (child.layout.anchor != null) continue;
|
|
136
|
-
_ = try layoutWidgetDepth(child, stackChildFrame(child_content, child), index, depth + 1, output, len, tokens);
|
|
143
|
+
_ = try layoutWidgetDepth(child, stackChildFrame(child_content, child, tokens), index, depth + 1, output, len, tokens);
|
|
137
144
|
}
|
|
138
145
|
},
|
|
139
146
|
.stack, .bubble, .card, .dialog, .drawer, .sheet, .resizable, .panel, .popover => {
|
|
140
147
|
for (widget.children) |child| {
|
|
141
148
|
if (child.layout.anchor != null) continue;
|
|
142
|
-
_ = try layoutWidgetDepth(child, stackChildFrame(content, child), index, depth + 1, output, len, tokens);
|
|
149
|
+
_ = try layoutWidgetDepth(child, stackChildFrame(content, child, tokens), index, depth + 1, output, len, tokens);
|
|
143
150
|
}
|
|
144
151
|
},
|
|
145
152
|
// Span paragraphs and span-carrying table cells share the link
|
|
@@ -414,9 +421,85 @@ pub fn tabsGap(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
414
421
|
fn tabsLayoutStyle(widget: Widget, tokens: DesignTokens) WidgetLayoutStyle {
|
|
415
422
|
var style = widget.layout;
|
|
416
423
|
style.gap = tabsGap(widget, tokens);
|
|
424
|
+
style.padding = tabsLayoutPadding(widget, tokens);
|
|
425
|
+
// Primary underline triggers fill the strip's row just like their
|
|
426
|
+
// web reference. This also honors an author-constrained strip height
|
|
427
|
+
// without letting the intrinsic trigger spill past its rail.
|
|
428
|
+
if (tokens.controls.tabs_indicator == .underline) style.cross_alignment = .stretch;
|
|
417
429
|
return style;
|
|
418
430
|
}
|
|
419
431
|
|
|
432
|
+
/// Underline triggers are the strip's full-height hit targets. The
|
|
433
|
+
/// ordinary stretch alignment only fills children without an explicit
|
|
434
|
+
/// cross extent; theme-agnostic trees can still carry the house trigger's
|
|
435
|
+
/// fixed 32px height, so this path translates those fixed frames onto the
|
|
436
|
+
/// underline register's row as well.
|
|
437
|
+
fn layoutTabsChildren(
|
|
438
|
+
widget: Widget,
|
|
439
|
+
content: geometry.RectF,
|
|
440
|
+
parent_index: usize,
|
|
441
|
+
depth: usize,
|
|
442
|
+
output: []WidgetLayoutNode,
|
|
443
|
+
len: *usize,
|
|
444
|
+
tokens: DesignTokens,
|
|
445
|
+
) Error!void {
|
|
446
|
+
const style = tabsLayoutStyle(widget, tokens);
|
|
447
|
+
if (tokens.controls.tabs_indicator == .underline) {
|
|
448
|
+
if (underlineTabsFillWidth(tokens)) {
|
|
449
|
+
return layoutAxisChildrenMode(widget.children, content, .horizontal, parent_index, depth, output, len, style, tokens, true, true);
|
|
450
|
+
}
|
|
451
|
+
return layoutAxisChildrenMode(widget.children, content, .horizontal, parent_index, depth, output, len, style, tokens, false, true);
|
|
452
|
+
}
|
|
453
|
+
return layoutAxisChildrenMode(widget.children, content, .horizontal, parent_index, depth, output, len, style, tokens, false, false);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/// Full-width underline tabs are an explicit pack layout policy, not a
|
|
457
|
+
/// consequence of choosing underline paint. This keeps custom underline
|
|
458
|
+
/// themes content-hugging unless they opt into the ruled-row geometry.
|
|
459
|
+
fn underlineTabsFillWidth(tokens: DesignTokens) bool {
|
|
460
|
+
return tokens.controls.tabs_indicator == .underline and
|
|
461
|
+
tokens.metrics.tabs_list_full_width;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/// Geist's primary TabsList is a width:100% ruled row. The authored
|
|
465
|
+
/// widget tree is theme-agnostic, though, and often carries the house
|
|
466
|
+
/// pill's intrinsic/fixed width, so every parent layout mode uses this
|
|
467
|
+
/// predicate to translate that same node without changing house layout.
|
|
468
|
+
fn primaryUnderlineTabsFillWidth(widget: Widget, tokens: DesignTokens) bool {
|
|
469
|
+
return widget.kind == .tabs and
|
|
470
|
+
(widget.variant == .default or widget.variant == .primary) and
|
|
471
|
+
underlineTabsFillWidth(tokens);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/// A non-growing primary underline TabsList gets first claim on a row's
|
|
475
|
+
/// flexible width. This is the flow-layout equivalent of
|
|
476
|
+
/// `stackChildFrame`'s full-width translation. Author-provided grow still
|
|
477
|
+
/// follows the normal flex allocation contract.
|
|
478
|
+
fn axisChildImplicitlyFillsWidth(widget: Widget) bool {
|
|
479
|
+
return nonNegative(widget.layout.grow) == 0 and
|
|
480
|
+
widget.kind == .tabs and
|
|
481
|
+
(widget.variant == .default or widget.variant == .primary);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/// Width:100% is a floor for primary underline tabs, not a cap. Preserve
|
|
485
|
+
/// an authored overflow while still growing a house-sized strip to its
|
|
486
|
+
/// share of the row. Explicit max bounds remain the author escape hatch.
|
|
487
|
+
fn axisChildImplicitFillExtent(widget: Widget, axis: LayoutAxis, fill_width_share: f32, tokens: DesignTokens) f32 {
|
|
488
|
+
return clampMainExtent(widget, axis, @max(preferredMainExtent(widget, axis, tokens), fill_width_share));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/// The builder stamps the house TabsList's canonical hug before it knows
|
|
492
|
+
/// which runtime theme pack will paint the tree. When the resolved
|
|
493
|
+
/// register is underline, translate only that recorded kind default to
|
|
494
|
+
/// the underline register's own inset (0 for Geist). Numerically equal
|
|
495
|
+
/// author padding remains author-owned. The pill arm returns the stored
|
|
496
|
+
/// padding byte-for-byte, preserving the default theme's layout.
|
|
497
|
+
fn tabsLayoutPadding(widget: Widget, tokens: DesignTokens) geometry.InsetsF {
|
|
498
|
+
if (tokens.controls.tabs_indicator != .underline) return widget.layout.padding;
|
|
499
|
+
if (!widget.layout.padding_is_kind_default) return widget.layout.padding;
|
|
500
|
+
return geometry.InsetsF.all(underlineTabsListInset(tokens));
|
|
501
|
+
}
|
|
502
|
+
|
|
420
503
|
fn layoutAxisChildren(
|
|
421
504
|
children: []const Widget,
|
|
422
505
|
content: geometry.RectF,
|
|
@@ -427,6 +510,28 @@ fn layoutAxisChildren(
|
|
|
427
510
|
len: *usize,
|
|
428
511
|
style: WidgetLayoutStyle,
|
|
429
512
|
tokens: DesignTokens,
|
|
513
|
+
) Error!void {
|
|
514
|
+
if (axis == .horizontal and underlineTabsFillWidth(tokens)) {
|
|
515
|
+
return layoutAxisChildrenMode(children, content, axis, parent_index, depth, output, len, style, tokens, true, false);
|
|
516
|
+
}
|
|
517
|
+
return layoutAxisChildrenMode(children, content, axis, parent_index, depth, output, len, style, tokens, false, false);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/// `fill_primary_tabs` is comptime so the overwhelmingly common house
|
|
521
|
+
/// path compiles to the original flex loop with no per-child theme
|
|
522
|
+
/// branches. Underline rows opt into the extra full-width allocation.
|
|
523
|
+
fn layoutAxisChildrenMode(
|
|
524
|
+
children: []const Widget,
|
|
525
|
+
content: geometry.RectF,
|
|
526
|
+
axis: LayoutAxis,
|
|
527
|
+
parent_index: usize,
|
|
528
|
+
depth: usize,
|
|
529
|
+
output: []WidgetLayoutNode,
|
|
530
|
+
len: *usize,
|
|
531
|
+
style: WidgetLayoutStyle,
|
|
532
|
+
tokens: DesignTokens,
|
|
533
|
+
comptime fill_primary_tabs: bool,
|
|
534
|
+
comptime stretch_tab_triggers: bool,
|
|
430
535
|
) Error!void {
|
|
431
536
|
// Anchored floating children take no flow slot: they are skipped in
|
|
432
537
|
// every pass here (measurement, gap counting, placement) and laid out
|
|
@@ -449,8 +554,14 @@ fn layoutAxisChildren(
|
|
|
449
554
|
const total_gap = clamped_gap * @as(f32, @floatFromInt(flow_count - 1));
|
|
450
555
|
var fixed_extent: f32 = 0;
|
|
451
556
|
var grow_total: f32 = 0;
|
|
557
|
+
var fill_width_count: usize = 0;
|
|
452
558
|
for (children) |child| {
|
|
453
559
|
if (child.layout.anchor != null) continue;
|
|
560
|
+
const implicitly_fills = if (comptime fill_primary_tabs) axisChildImplicitlyFillsWidth(child) else false;
|
|
561
|
+
if (implicitly_fills) {
|
|
562
|
+
fill_width_count += 1;
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
454
565
|
const grow = nonNegative(child.layout.grow);
|
|
455
566
|
if (grow > 0) {
|
|
456
567
|
grow_total += grow;
|
|
@@ -463,8 +574,23 @@ fn layoutAxisChildren(
|
|
|
463
574
|
}
|
|
464
575
|
}
|
|
465
576
|
|
|
466
|
-
const
|
|
467
|
-
const
|
|
577
|
+
const flexible_extent = @max(0, available_extent - fixed_extent - total_gap);
|
|
578
|
+
const fill_width_share = if (fill_width_count > 0)
|
|
579
|
+
flexible_extent / @as(f32, @floatFromInt(fill_width_count))
|
|
580
|
+
else
|
|
581
|
+
0;
|
|
582
|
+
var fill_width_extent: f32 = 0;
|
|
583
|
+
if (comptime fill_primary_tabs) {
|
|
584
|
+
if (fill_width_count > 0) {
|
|
585
|
+
for (children) |child| {
|
|
586
|
+
if (child.layout.anchor != null) continue;
|
|
587
|
+
if (!axisChildImplicitlyFillsWidth(child)) continue;
|
|
588
|
+
fill_width_extent += axisChildImplicitFillExtent(child, axis, fill_width_share, tokens);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const grow_extent = @max(0, flexible_extent - fill_width_extent);
|
|
593
|
+
const assigned_extent = assignedAxisChildrenExtent(children, axis, fixed_extent + fill_width_extent, grow_total, grow_extent);
|
|
468
594
|
const used_extent = assigned_extent + total_gap;
|
|
469
595
|
if (axisLayoutOverflow(available_extent, used_extent)) |overflow| {
|
|
470
596
|
logAxisChildrenOverflow(output, parent_index, axis, available_extent, used_extent, overflow);
|
|
@@ -482,11 +608,20 @@ fn layoutAxisChildren(
|
|
|
482
608
|
for (children) |child| {
|
|
483
609
|
if (child.layout.anchor != null) continue;
|
|
484
610
|
const grow = nonNegative(child.layout.grow);
|
|
485
|
-
const
|
|
486
|
-
|
|
611
|
+
const implicitly_fills = if (comptime fill_primary_tabs) axisChildImplicitlyFillsWidth(child) else false;
|
|
612
|
+
const main_extent = if (implicitly_fills)
|
|
613
|
+
axisChildImplicitFillExtent(child, axis, fill_width_share, tokens)
|
|
614
|
+
else if (grow > 0 and grow_total > 0)
|
|
615
|
+
clampMainExtent(child, axis, grow_extent * grow / grow_total)
|
|
487
616
|
else
|
|
488
617
|
mainExtentWithBubbleCap(child, axis, available_extent, preferredMainExtentInCross(child, axis, cross_extent, style.cross_alignment, tokens));
|
|
489
|
-
const cross =
|
|
618
|
+
const cross = if (comptime stretch_tab_triggers)
|
|
619
|
+
if (child.kind == .segmented_control)
|
|
620
|
+
stretchedCrossExtent(child, axis, cross_extent)
|
|
621
|
+
else
|
|
622
|
+
preferredCrossExtent(child, axis, cross_extent, style.cross_alignment, tokens)
|
|
623
|
+
else
|
|
624
|
+
preferredCrossExtent(child, axis, cross_extent, style.cross_alignment, tokens);
|
|
490
625
|
const cross_origin = alignedCrossAxisOrigin(content, axis, cross_extent, cross, child, style.cross_alignment);
|
|
491
626
|
const child_frame = switch (axis) {
|
|
492
627
|
.horizontal => geometry.RectF.init(cursor, cross_origin, main_extent, cross),
|
|
@@ -788,14 +923,27 @@ fn wrappedVerticalExtentForWidth(widget: Widget, width: f32, tokens: DesignToken
|
|
|
788
923
|
/// so wrapped heights inside rows (blockquotes, list items) are computed
|
|
789
924
|
/// against real widths.
|
|
790
925
|
fn rowChildWidth(row: Widget, available_width: f32, index: usize, tokens: DesignTokens) f32 {
|
|
926
|
+
if (underlineTabsFillWidth(tokens)) {
|
|
927
|
+
return rowChildWidthMode(row, available_width, index, tokens, true);
|
|
928
|
+
}
|
|
929
|
+
return rowChildWidthMode(row, available_width, index, tokens, false);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
fn rowChildWidthMode(row: Widget, available_width: f32, index: usize, tokens: DesignTokens, comptime fill_primary_tabs: bool) f32 {
|
|
791
933
|
const children = row.children;
|
|
792
934
|
if (children.len == 0) return available_width;
|
|
793
935
|
var flow_count: usize = 0;
|
|
794
936
|
var fixed_extent: f32 = 0;
|
|
795
937
|
var grow_total: f32 = 0;
|
|
938
|
+
var fill_width_count: usize = 0;
|
|
796
939
|
for (children) |child| {
|
|
797
940
|
if (child.layout.anchor != null) continue;
|
|
798
941
|
flow_count += 1;
|
|
942
|
+
const implicitly_fills = if (comptime fill_primary_tabs) axisChildImplicitlyFillsWidth(child) else false;
|
|
943
|
+
if (implicitly_fills) {
|
|
944
|
+
fill_width_count += 1;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
799
947
|
const grow = nonNegative(child.layout.grow);
|
|
800
948
|
if (grow > 0) {
|
|
801
949
|
grow_total += grow;
|
|
@@ -813,10 +961,27 @@ fn rowChildWidth(row: Widget, available_width: f32, index: usize, tokens: Design
|
|
|
813
961
|
else => nonNegative(row.layout.gap),
|
|
814
962
|
};
|
|
815
963
|
const total_gap = row_gap * @as(f32, @floatFromInt(flow_count - 1));
|
|
816
|
-
const
|
|
964
|
+
const flexible_extent = @max(0, available_width - fixed_extent - total_gap);
|
|
965
|
+
const fill_width_share = if (fill_width_count > 0)
|
|
966
|
+
flexible_extent / @as(f32, @floatFromInt(fill_width_count))
|
|
967
|
+
else
|
|
968
|
+
0;
|
|
969
|
+
var fill_width_extent: f32 = 0;
|
|
970
|
+
if (comptime fill_primary_tabs) {
|
|
971
|
+
if (fill_width_count > 0) {
|
|
972
|
+
for (children) |candidate| {
|
|
973
|
+
if (candidate.layout.anchor != null) continue;
|
|
974
|
+
if (!axisChildImplicitlyFillsWidth(candidate)) continue;
|
|
975
|
+
fill_width_extent += axisChildImplicitFillExtent(candidate, .horizontal, fill_width_share, tokens);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
const grow_extent = @max(0, flexible_extent - fill_width_extent);
|
|
817
980
|
const child = children[index];
|
|
981
|
+
const implicitly_fills = if (comptime fill_primary_tabs) axisChildImplicitlyFillsWidth(child) else false;
|
|
982
|
+
if (implicitly_fills) return axisChildImplicitFillExtent(child, .horizontal, fill_width_share, tokens);
|
|
818
983
|
const grow = nonNegative(child.layout.grow);
|
|
819
|
-
if (grow > 0 and grow_total > 0) return clampMainExtent(child, .horizontal,
|
|
984
|
+
if (grow > 0 and grow_total > 0) return clampMainExtent(child, .horizontal, grow_extent * grow / grow_total);
|
|
820
985
|
// The same bubble thread cap `layoutAxisChildren` applies, replayed
|
|
821
986
|
// here so wrapped heights measure at the width the bubble will
|
|
822
987
|
// actually receive.
|
|
@@ -959,7 +1124,7 @@ fn layoutGridChildren(
|
|
|
959
1124
|
const row = child_index / columns;
|
|
960
1125
|
const x = content.x + @as(f32, @floatFromInt(column)) * (cell_width + clamped_gap);
|
|
961
1126
|
const y = content.y + @as(f32, @floatFromInt(row)) * (fallback_cell_height + clamped_gap);
|
|
962
|
-
const width =
|
|
1127
|
+
const width = gridChildWidth(child, cell_width, tokens);
|
|
963
1128
|
const height = clampIntrinsicAxis(if (child.frame.height > 0) child.frame.height else fallback_cell_height, child.layout.min_size.height, child.layout.max_size.height);
|
|
964
1129
|
const child_frame = geometry.RectF.init(
|
|
965
1130
|
x + child.frame.x,
|
|
@@ -1021,7 +1186,7 @@ fn layoutVirtualGridChildren(
|
|
|
1021
1186
|
child.semantics.list_item_count = saturatingU32(children.len);
|
|
1022
1187
|
const x = content.x + @as(f32, @floatFromInt(column)) * (cell_width + clamped_gap);
|
|
1023
1188
|
const y = content.y + @as(f32, @floatFromInt(row)) * stride - range.layout_offset + child.frame.y;
|
|
1024
|
-
const width =
|
|
1189
|
+
const width = gridChildWidth(child, cell_width, tokens);
|
|
1025
1190
|
const height = clampIntrinsicAxis(if (child.frame.height > 0) child.frame.height else range.item_extent, child.layout.min_size.height, child.layout.max_size.height);
|
|
1026
1191
|
const child_frame = geometry.RectF.init(
|
|
1027
1192
|
x + child.frame.x,
|
|
@@ -1034,6 +1199,17 @@ fn layoutVirtualGridChildren(
|
|
|
1034
1199
|
}
|
|
1035
1200
|
}
|
|
1036
1201
|
|
|
1202
|
+
/// A grid cell is the containing width for Geist's primary ruled row.
|
|
1203
|
+
/// Translate the theme-agnostic house width to the remaining cell width,
|
|
1204
|
+
/// while keeping deliberate overflow and explicit max bounds intact.
|
|
1205
|
+
fn gridChildWidth(child: Widget, cell_width: f32, tokens: DesignTokens) f32 {
|
|
1206
|
+
var width = if (child.frame.width > 0) child.frame.width else cell_width;
|
|
1207
|
+
if (primaryUnderlineTabsFillWidth(child, tokens)) {
|
|
1208
|
+
width = @max(width, @max(0, cell_width - child.frame.x));
|
|
1209
|
+
}
|
|
1210
|
+
return clampIntrinsicAxis(width, child.layout.min_size.width, child.layout.max_size.width);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1037
1213
|
fn preferredGridRowExtent(children: []const Widget, columns: usize, tokens: DesignTokens) f32 {
|
|
1038
1214
|
if (children.len == 0 or columns == 0) return 0;
|
|
1039
1215
|
var max_height: f32 = 0;
|
|
@@ -1069,7 +1245,7 @@ fn layoutScrollChildren(
|
|
|
1069
1245
|
const scrolled_content = content.translate(geometry.OffsetF.init(-scroll_offset.dx, -scroll_offset.dy));
|
|
1070
1246
|
for (children) |child| {
|
|
1071
1247
|
if (child.layout.anchor != null) continue;
|
|
1072
|
-
var child_frame = stackChildFrame(scrolled_content, child);
|
|
1248
|
+
var child_frame = stackChildFrame(scrolled_content, child, tokens);
|
|
1073
1249
|
// A `both` region must retain the same intrinsic width as a
|
|
1074
1250
|
// horizontal-only shelf; otherwise its horizontal axis has no
|
|
1075
1251
|
// content range even when its child paints a long no-wrap line.
|
|
@@ -1483,15 +1659,37 @@ pub fn widgetKindStacksChildren(kind: widget_model.WidgetKind) bool {
|
|
|
1483
1659
|
};
|
|
1484
1660
|
}
|
|
1485
1661
|
|
|
1486
|
-
fn stackChildFrame(content: geometry.RectF, child: Widget) geometry.RectF {
|
|
1662
|
+
fn stackChildFrame(content: geometry.RectF, child: Widget, tokens: DesignTokens) geometry.RectF {
|
|
1487
1663
|
const width = if (child.frame.width > 0) child.frame.width else content.width;
|
|
1488
1664
|
const height = if (child.frame.height > 0) child.frame.height else content.height;
|
|
1489
|
-
|
|
1665
|
+
var frame = geometry.RectF.init(
|
|
1490
1666
|
content.x + child.frame.x,
|
|
1491
1667
|
content.y + child.frame.y,
|
|
1492
1668
|
clampIntrinsicAxis(width, child.layout.min_size.width, child.layout.max_size.width),
|
|
1493
1669
|
clampIntrinsicAxis(height, child.layout.min_size.height, child.layout.max_size.height),
|
|
1494
1670
|
);
|
|
1671
|
+
// A primary underline TabsList is a full-width rule with
|
|
1672
|
+
// content-hugging triggers, equivalent to the reference's
|
|
1673
|
+
// `width: 100%`. Fixed frames in theme-agnostic trees often describe
|
|
1674
|
+
// the house pill's hug width (the GPU catalog's 148px Small/Large
|
|
1675
|
+
// specimen is one); carrying that width into the underline register
|
|
1676
|
+
// clips the closing rail immediately after the last trigger. Stretch
|
|
1677
|
+
// only the underline register to the remaining containing width.
|
|
1678
|
+
// House pills return byte-for-byte above, and an explicit max width
|
|
1679
|
+
// remains the author escape hatch for a deliberately bounded strip.
|
|
1680
|
+
if (primaryUnderlineTabsFillWidth(child, tokens)) {
|
|
1681
|
+
frame.width = clampIntrinsicAxis(
|
|
1682
|
+
// Full-width is a floor, not a replacement for authored
|
|
1683
|
+
// overflow. A tab strip wider than a horizontal scroll
|
|
1684
|
+
// viewport must keep that width so its rail and clipped
|
|
1685
|
+
// trigger content remain reachable; only the narrow house
|
|
1686
|
+
// hug grows to the containing width.
|
|
1687
|
+
@max(frame.width, @max(0, content.maxX() - frame.x)),
|
|
1688
|
+
child.layout.min_size.width,
|
|
1689
|
+
child.layout.max_size.width,
|
|
1690
|
+
);
|
|
1691
|
+
}
|
|
1692
|
+
return frame;
|
|
1495
1693
|
}
|
|
1496
1694
|
|
|
1497
1695
|
/// Whether the accordion's EXTENT includes its content: only while
|
|
@@ -1730,10 +1928,12 @@ fn intrinsicAxisChildrenSize(widget: Widget, tokens: DesignTokens, axis: LayoutA
|
|
|
1730
1928
|
else => nonNegative(widget.layout.gap),
|
|
1731
1929
|
};
|
|
1732
1930
|
const gap = child_gap * @as(f32, @floatFromInt(flow_count - 1));
|
|
1733
|
-
|
|
1931
|
+
const content_size = switch (axis) {
|
|
1734
1932
|
.horizontal => geometry.SizeF.init(main_sum + gap, cross_max),
|
|
1735
1933
|
.vertical => geometry.SizeF.init(cross_max, main_sum + gap),
|
|
1736
|
-
}
|
|
1934
|
+
};
|
|
1935
|
+
if (widget.kind == .tabs) return paddedIntrinsicSizeWithPadding(widget, content_size, tabsLayoutPadding(widget, tokens));
|
|
1936
|
+
return paddedIntrinsicSize(widget, content_size);
|
|
1737
1937
|
}
|
|
1738
1938
|
|
|
1739
1939
|
fn intrinsicOverlayChildrenSize(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
@@ -1799,6 +1999,10 @@ fn intrinsicOwnMinSize(widget: Widget) geometry.SizeF {
|
|
|
1799
1999
|
|
|
1800
2000
|
fn paddedIntrinsicSize(widget: Widget, content: geometry.SizeF) geometry.SizeF {
|
|
1801
2001
|
const padding = widget.layout.padding;
|
|
2002
|
+
return paddedIntrinsicSizeWithPadding(widget, content, padding);
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
fn paddedIntrinsicSizeWithPadding(widget: Widget, content: geometry.SizeF, padding: geometry.InsetsF) geometry.SizeF {
|
|
1802
2006
|
return geometry.SizeF.init(
|
|
1803
2007
|
@max(content.width + padding.left + padding.right, widget.layout.min_size.width),
|
|
1804
2008
|
@max(content.height + padding.top + padding.bottom, widget.layout.min_size.height),
|
|
@@ -2041,12 +2245,22 @@ fn intrinsicSpinnerWidgetSize(widget: Widget, tokens: DesignTokens) geometry.Siz
|
|
|
2041
2245
|
}
|
|
2042
2246
|
|
|
2043
2247
|
fn intrinsicSegmentedControlSize(widget: Widget, tokens: DesignTokens) geometry.SizeF {
|
|
2044
|
-
const text_width = measuredTextWidth(tokens, widget.text,
|
|
2248
|
+
const text_width = measuredTextWidth(tokens, widget.text, widgetTabTriggerTextSize(widget, tokens));
|
|
2249
|
+
if (tokens.controls.tabs_indicator == .underline) {
|
|
2250
|
+
const icon_width = if (widget.icon.len > 0)
|
|
2251
|
+
widgetTabTriggerIconExtent(widget, tokens) + (if (widget.text.len > 0) widgetTabTriggerIconGap(tokens) else 0)
|
|
2252
|
+
else
|
|
2253
|
+
0;
|
|
2254
|
+
return geometry.SizeF.init(
|
|
2255
|
+
pixelSnapCeil(tokens, icon_width + text_width + widgetTabTriggerInset(widget, tokens) * 2),
|
|
2256
|
+
widgetTabTriggerHeight(widget, tokens),
|
|
2257
|
+
);
|
|
2258
|
+
}
|
|
2045
2259
|
// Ceil to the snap grid (`pixelSnapCeil`): a segment / tabs trigger
|
|
2046
2260
|
// sized exactly to its measured label must survive render-time edge
|
|
2047
2261
|
// snapping without eliding.
|
|
2048
2262
|
const width = pixelSnapCeil(tokens, @max(widgetSizedDensityValue(widget, tokens, 44), text_width + widgetControlInset(widget, tokens, tokens.spacing.md) * 2));
|
|
2049
|
-
return geometry.SizeF.init(width,
|
|
2263
|
+
return geometry.SizeF.init(width, widgetTabTriggerHeight(widget, tokens));
|
|
2050
2264
|
}
|
|
2051
2265
|
|
|
2052
2266
|
fn intrinsicRowTextWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF {
|
|
@@ -2169,6 +2383,19 @@ fn preferredCrossExtent(widget: Widget, axis: LayoutAxis, available: f32, alignm
|
|
|
2169
2383
|
.horizontal => widget.layout.max_size.height,
|
|
2170
2384
|
.vertical => widget.layout.max_size.width,
|
|
2171
2385
|
};
|
|
2386
|
+
// The cross axis of a vertical flow is width. Geist primary tabs
|
|
2387
|
+
// therefore fill a column just as they fill stack and row parents,
|
|
2388
|
+
// even when the theme-agnostic node still carries the house pill's
|
|
2389
|
+
// fixed width. An explicit max width remains the bounding escape.
|
|
2390
|
+
if (axis == .vertical and primaryUnderlineTabsFillWidth(widget, tokens)) {
|
|
2391
|
+
// `alignedCrossAxisOrigin` applies the authored x offset after
|
|
2392
|
+
// choosing this width. Fill only the space remaining after that
|
|
2393
|
+
// offset so the closing rail still lands on the parent's trailing
|
|
2394
|
+
// edge, matching `stackChildFrame`. A deliberately wider strip
|
|
2395
|
+
// remains wider so horizontal scrolling keeps its full extent.
|
|
2396
|
+
const remaining = @max(0, available - widget.frame.x);
|
|
2397
|
+
return @max(min_value, boundedByMax(@max(value, remaining), max_value));
|
|
2398
|
+
}
|
|
2172
2399
|
if (value > 0) return @max(min_value, boundedByMax(value, max_value));
|
|
2173
2400
|
// The cross axis of a vertical container is the child's WIDTH, so
|
|
2174
2401
|
// the bubble thread contract applies here: a bubble directly in a
|
|
@@ -2199,6 +2426,18 @@ fn preferredCrossExtent(widget: Widget, axis: LayoutAxis, available: f32, alignm
|
|
|
2199
2426
|
return @max(min_value, boundedByMax(@min(available, intrinsic), max_value));
|
|
2200
2427
|
}
|
|
2201
2428
|
|
|
2429
|
+
fn stretchedCrossExtent(widget: Widget, axis: LayoutAxis, available: f32) f32 {
|
|
2430
|
+
const min_value = switch (axis) {
|
|
2431
|
+
.horizontal => widget.layout.min_size.height,
|
|
2432
|
+
.vertical => widget.layout.min_size.width,
|
|
2433
|
+
};
|
|
2434
|
+
const max_value = switch (axis) {
|
|
2435
|
+
.horizontal => widget.layout.max_size.height,
|
|
2436
|
+
.vertical => widget.layout.max_size.width,
|
|
2437
|
+
};
|
|
2438
|
+
return @max(min_value, boundedByMax(available, max_value));
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2202
2441
|
fn minMainExtent(widget: Widget, axis: LayoutAxis) f32 {
|
|
2203
2442
|
return switch (axis) {
|
|
2204
2443
|
.horizontal => nonNegative(widget.layout.min_size.width),
|
|
@@ -114,17 +114,22 @@ pub fn widgetTextSpanLayoutOptions(widget: Widget, tokens: DesignTokens, max_wid
|
|
|
114
114
|
|
|
115
115
|
const min_code_line_number_digits: usize = 3;
|
|
116
116
|
|
|
117
|
-
/// Width reserved before a
|
|
118
|
-
///
|
|
119
|
-
///
|
|
120
|
-
///
|
|
117
|
+
/// Width reserved before a decorated code paragraph: numbered blocks keep
|
|
118
|
+
/// at least three muted monospace columns, while a diff without numbers
|
|
119
|
+
/// keeps one +/- column. Marker bytes never live in `Widget.text`; paint
|
|
120
|
+
/// selects them from a compile-time table.
|
|
121
121
|
pub fn widgetCodeLineNumberGutterWidth(widget: Widget, tokens: DesignTokens) f32 {
|
|
122
|
-
|
|
122
|
+
const has_diff = widget.hasCodeDiff();
|
|
123
|
+
const line_number_digits = widget.codeLineNumberDigits();
|
|
124
|
+
if (line_number_digits == 0 and !has_diff) return 0;
|
|
123
125
|
const zeros: [20]u8 = @splat('0');
|
|
124
|
-
const digits =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
const digits = if (line_number_digits == 0)
|
|
127
|
+
1
|
|
128
|
+
else
|
|
129
|
+
@min(
|
|
130
|
+
@max(@as(usize, line_number_digits), min_code_line_number_digits),
|
|
131
|
+
zeros.len,
|
|
132
|
+
);
|
|
128
133
|
return text_model.measureTextWidthForFont(
|
|
129
134
|
tokens.text_measure,
|
|
130
135
|
tokens.typography.mono_font_id,
|
|
@@ -234,6 +239,37 @@ pub fn widgetControlInset(widget: Widget, tokens: DesignTokens, base: f32) f32 {
|
|
|
234
239
|
return densityValue(tokens, widgetSizedTokenValue(widget, tokens, base));
|
|
235
240
|
}
|
|
236
241
|
|
|
242
|
+
/// Tab-trigger metrics split at the register boundary. House pill tabs
|
|
243
|
+
/// keep using the shared label/control ladder exactly as before; the
|
|
244
|
+
/// underline register owns the taller, label-hugging geometry measured
|
|
245
|
+
/// from the Geist primary Tabs component.
|
|
246
|
+
pub fn widgetTabTriggerTextSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
247
|
+
if (tokens.controls.tabs_indicator == .pill) return widgetLabelTextSize(widget, tokens);
|
|
248
|
+
return widgetTypographySize(widget, @max(8, tokens.typography.label_size + tokens.metrics.tabs_label_size_step));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
pub fn widgetTabTriggerHeight(widget: Widget, tokens: DesignTokens) f32 {
|
|
252
|
+
if (tokens.controls.tabs_indicator == .pill) return widgetControlHeight(widget, tokens);
|
|
253
|
+
return widgetSizedDensityValue(widget, tokens, @max(0, tokens.metrics.tabs_trigger_height));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
pub fn widgetTabTriggerInset(widget: Widget, tokens: DesignTokens) f32 {
|
|
257
|
+
if (tokens.controls.tabs_indicator == .pill) return widgetControlInset(widget, tokens, tokens.spacing.md);
|
|
258
|
+
return widgetControlInset(widget, tokens, @max(0, tokens.metrics.tabs_trigger_inset));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
pub fn widgetTabTriggerIconExtent(widget: Widget, tokens: DesignTokens) f32 {
|
|
262
|
+
return widgetTabTriggerTextSize(widget, tokens) + tokens.metrics.icon_text_step;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
pub fn widgetTabTriggerIconGap(tokens: DesignTokens) f32 {
|
|
266
|
+
return densityValue(tokens, tokens.metrics.button_icon_gap);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
pub fn underlineTabsListInset(tokens: DesignTokens) f32 {
|
|
270
|
+
return densityValue(tokens, @max(0, tokens.metrics.tabs_list_inset));
|
|
271
|
+
}
|
|
272
|
+
|
|
237
273
|
pub fn widgetSizedDensityValue(widget: Widget, tokens: DesignTokens, value: f32) f32 {
|
|
238
274
|
return densityValue(tokens, value) * widgetSizeScale(widget);
|
|
239
275
|
}
|