@native-sdk/cli 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +50 -3
- package/build.zig +134 -360
- package/native-sdk.d.ts +4 -0
- package/package.json +9 -9
- package/packages/core/compile-surface/core.ts +90 -1
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.d.ts +65 -2
- package/packages/core/sdk/core.ts +189 -33
- package/packages/core/sdk/events.d.ts +14 -0
- package/packages/core/sdk/events.ts +18 -0
- package/packages/core/src/checker.ts +61 -1
- package/packages/core/src/devhost.ts +3 -3
- package/packages/core/src/diagnostics.ts +4 -4
- package/skill-data/core/SKILL.md +4 -2
- package/skill-data/core/references/project-anatomy.md +2 -1
- package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
- package/skill-data/native-ui/SKILL.md +8 -8
- package/skill-data/ts-core/SKILL.md +16 -13
- package/src/app_runner/app_assets.zig +138 -0
- package/src/app_runner/root.zig +2 -0
- package/src/app_runner/ts_core_main.zig +27 -3
- package/src/embed/host.zig +6 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/linux/root.zig +1 -0
- package/src/platform/macos/appkit_host.h +10 -0
- package/src/platform/macos/appkit_host.m +515 -93
- package/src/platform/macos/capture_info_plist.c +25 -0
- package/src/platform/macos/cef_host.mm +22 -0
- package/src/platform/macos/root.zig +68 -0
- package/src/platform/null_platform.zig +58 -0
- package/src/platform/root.zig +7 -0
- package/src/platform/types.zig +100 -0
- package/src/platform/windows/root.zig +56 -0
- package/src/platform/windows/webview2_host.cpp +171 -0
- package/src/primitives/app_manifest/types.zig +2 -0
- package/src/primitives/canvas/code_tests.zig +9 -9
- package/src/primitives/canvas/events.zig +12 -11
- package/src/primitives/canvas/frame.zig +44 -9
- package/src/primitives/canvas/icons/mic.svg +1 -0
- package/src/primitives/canvas/icons.zig +2 -0
- package/src/primitives/canvas/root.zig +8 -0
- package/src/primitives/canvas/text_span_tests.zig +39 -0
- package/src/primitives/canvas/ui.zig +23 -4
- package/src/primitives/canvas/ui_markup.zig +15 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
- package/src/primitives/canvas/ui_markup_tests.zig +5 -0
- package/src/primitives/canvas/ui_markup_view.zig +9 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
- package/src/primitives/canvas/ui_schema.zig +19 -10
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +18 -4
- package/src/primitives/canvas/widget_invalidation.zig +9 -2
- package/src/primitives/canvas/widget_render.zig +321 -115
- package/src/primitives/canvas/widget_runtime_tests.zig +173 -0
- package/src/primitives/canvas/widget_text_input.zig +10 -10
- package/src/primitives/canvas/widget_tree.zig +1 -1
- package/src/primitives/canvas/widgets.zig +41 -5
- package/src/root.zig +10 -0
- package/src/runtime/automation_widget_dispatch.zig +1 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/canvas_frame.zig +13 -2
- package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
- package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
- package/src/runtime/canvas_widget_event_tests.zig +1 -0
- package/src/runtime/canvas_widget_events.zig +69 -24
- package/src/runtime/canvas_widget_runtime.zig +101 -6
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
- package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
- package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
- package/src/runtime/canvas_widget_state.zig +10 -1
- package/src/runtime/canvas_widget_text_tests.zig +112 -3
- package/src/runtime/effects.zig +313 -2
- package/src/runtime/effects_audio_capture_tests.zig +251 -0
- package/src/runtime/root.zig +3 -0
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_core_host.zig +401 -32
- package/src/runtime/ts_core_host_tests.zig +407 -0
- package/src/runtime/ts_ui_app.zig +39 -1
- package/src/runtime/ui_app.zig +18 -3
- package/src/runtime/ui_app_tests.zig +48 -0
- package/src/runtime/view.zig +2 -0
- package/src/runtime/view_widget_scroll.zig +56 -5
- package/src/runtime/view_widget_text.zig +24 -5
- package/src/runtime/view_widget_tree.zig +1 -1
- package/src/tooling/manifest.zig +1034 -0
- package/src/tooling/package.zig +841 -10
- package/src/tooling/raw_manifest.zig +35 -0
- package/src/tooling/templates.zig +55 -0
- package/tools/corewire/emit_facade.zig +36 -0
|
@@ -164,11 +164,33 @@ pub fn emitWidgetLayout(builder: *Builder, layout: anytype, tokens: DesignTokens
|
|
|
164
164
|
pub fn emitWidgetLayoutWithState(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
|
|
165
165
|
scrim_viewport = widgetLayoutRootBounds(layout);
|
|
166
166
|
try emitWidgetLayoutChildren(builder, layout, null, tokens, state);
|
|
167
|
+
try emitWidgetLayoutClipEscapingMotions(builder, layout, tokens, state);
|
|
167
168
|
try emitWidgetLayoutAnchored(builder, layout, tokens, state);
|
|
168
169
|
try emitWidgetLayoutChartHoverDetails(builder, layout, tokens, state);
|
|
169
170
|
try emitWidgetLayoutDragPreview(builder, layout, tokens, state);
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
/// Pointer-up replaces the window-level drag preview with a FLIP landing.
|
|
174
|
+
/// Paint that one moving subtree in the same unclipped coordinate space until
|
|
175
|
+
/// its offset reaches zero, so crossing into another scroll lane does not crop
|
|
176
|
+
/// the card at the destination lane's bounds. Other layout motions stay in the
|
|
177
|
+
/// ordinary tree walk and retain their scroll clipping.
|
|
178
|
+
fn emitWidgetLayoutClipEscapingMotions(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
|
|
179
|
+
for (layout.nodes, 0..) |node, index| {
|
|
180
|
+
if (widget_tree.widgetIsAnchored(node.widget)) continue;
|
|
181
|
+
if (!state.layoutMotionEscapesAncestorClips(node.widget.id)) continue;
|
|
182
|
+
if (widget_tree.isWidgetHiddenInAncestors(layout, index)) continue;
|
|
183
|
+
if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) continue;
|
|
184
|
+
|
|
185
|
+
const ancestor_transform = widgetLayoutNodeAncestorEmissionTransform(layout, index) orelse return error.InvalidTransform;
|
|
186
|
+
const wrap_ancestor_transform = !affinesEqual(ancestor_transform, Affine.identity());
|
|
187
|
+
const inverse_ancestor_transform = if (wrap_ancestor_transform) ancestor_transform.inverse() orelse return error.InvalidTransform else Affine.identity();
|
|
188
|
+
if (wrap_ancestor_transform) try builder.transform(ancestor_transform);
|
|
189
|
+
try emitWidgetLayoutNode(builder, layout, index, tokens, state, .none);
|
|
190
|
+
if (wrap_ancestor_transform) try builder.transform(inverse_ancestor_transform);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
172
194
|
/// Paint the active drag source in a late, window-level pass so the card under
|
|
173
195
|
/// the pointer escapes its column's clip. Normal emission suppresses this
|
|
174
196
|
/// subtree, leaving its one current layout slot blank.
|
|
@@ -184,6 +206,9 @@ fn emitWidgetLayoutDragPreview(builder: *Builder, layout: anytype, tokens: Desig
|
|
|
184
206
|
|
|
185
207
|
var preview_state = WidgetRenderState{
|
|
186
208
|
.rendering_drag_preview = true,
|
|
209
|
+
.drag_preview_id = source_id,
|
|
210
|
+
.drag_preview_origin = state.drag_preview_origin,
|
|
211
|
+
.drag_preview_offset = state.drag_preview_offset,
|
|
187
212
|
};
|
|
188
213
|
// Keep disclosure content in the preview in the same visible phase as
|
|
189
214
|
// the standing tree, while dropping focus/hover/press chrome from the
|
|
@@ -193,18 +218,31 @@ fn emitWidgetLayoutDragPreview(builder: *Builder, layout: anytype, tokens: Desig
|
|
|
193
218
|
const ancestor_transform = widgetLayoutNodeAncestorEmissionTransform(layout, source_index) orelse return error.InvalidTransform;
|
|
194
219
|
const wrap_ancestor_transform = !affinesEqual(ancestor_transform, Affine.identity());
|
|
195
220
|
const inverse_ancestor_transform = if (wrap_ancestor_transform) ancestor_transform.inverse() orelse return error.InvalidTransform else Affine.identity();
|
|
196
|
-
const
|
|
197
|
-
const current_origin = ancestor_transform.transformPoint(geometry.PointF.init(current_frame.x, current_frame.y));
|
|
198
|
-
const source_layout_origin = state.drag_preview_origin orelse geometry.PointF.init(current_frame.x, current_frame.y);
|
|
199
|
-
const source_origin = ancestor_transform.transformPoint(source_layout_origin);
|
|
200
|
-
const translate_x = source_origin.x + state.drag_preview_offset.dx - current_origin.x;
|
|
201
|
-
const translate_y = source_origin.y + state.drag_preview_offset.dy - current_origin.y;
|
|
202
|
-
const translation = Affine.translate(translate_x, translate_y);
|
|
221
|
+
const translation = widgetLayoutDragPreviewTranslation(layout, source_index, state, ancestor_transform);
|
|
203
222
|
try builder.transform(translation);
|
|
204
223
|
if (wrap_ancestor_transform) try builder.transform(ancestor_transform);
|
|
205
224
|
try emitWidgetLayoutNode(builder, layout, source_index, tokens, preview_state, .none);
|
|
206
225
|
if (wrap_ancestor_transform) try builder.transform(inverse_ancestor_transform);
|
|
207
|
-
try builder.transform(Affine.translate(-
|
|
226
|
+
try builder.transform(Affine.translate(-translation.tx, -translation.ty));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/// The window-space translation around a floating drag preview. The same
|
|
230
|
+
/// value drives both the builder stack and span visibility below, so a rich
|
|
231
|
+
/// text child is culled at its lifted pose rather than its standing slot.
|
|
232
|
+
fn widgetLayoutDragPreviewTranslation(
|
|
233
|
+
layout: anytype,
|
|
234
|
+
source_index: usize,
|
|
235
|
+
state: WidgetRenderState,
|
|
236
|
+
ancestor_transform: Affine,
|
|
237
|
+
) Affine {
|
|
238
|
+
const current_frame = layout.nodes[source_index].frame.normalized();
|
|
239
|
+
const current_origin = ancestor_transform.transformPoint(geometry.PointF.init(current_frame.x, current_frame.y));
|
|
240
|
+
const source_layout_origin = state.drag_preview_origin orelse geometry.PointF.init(current_frame.x, current_frame.y);
|
|
241
|
+
const source_origin = ancestor_transform.transformPoint(source_layout_origin);
|
|
242
|
+
return Affine.translate(
|
|
243
|
+
source_origin.x + state.drag_preview_offset.dx - current_origin.x,
|
|
244
|
+
source_origin.y + state.drag_preview_offset.dy - current_origin.y,
|
|
245
|
+
);
|
|
208
246
|
}
|
|
209
247
|
|
|
210
248
|
/// The union of the layout's root-node frames: the whole laid-out
|
|
@@ -243,6 +281,46 @@ fn widgetLayoutNodeEmissionTransform(layout: anytype, node_index: usize) ?Affine
|
|
|
243
281
|
return transform;
|
|
244
282
|
}
|
|
245
283
|
|
|
284
|
+
/// The transform active while `node_index` paints in this frame. Unlike the
|
|
285
|
+
/// standing emission transform above, this includes presentation-only layout
|
|
286
|
+
/// motion and the window-level translation around a floating drag preview.
|
|
287
|
+
fn widgetLayoutNodePresentationTransform(
|
|
288
|
+
layout: anytype,
|
|
289
|
+
node_index: usize,
|
|
290
|
+
state: WidgetRenderState,
|
|
291
|
+
outer_transform: Affine,
|
|
292
|
+
) ?Affine {
|
|
293
|
+
// Static/ordinary frames are overwhelmingly common. Keep their culling
|
|
294
|
+
// path byte-for-byte with the standing transform walk; only late passes
|
|
295
|
+
// and active layout motion pay for presentation-state lookups.
|
|
296
|
+
if (!state.rendering_drag_preview and state.layout_motions.len == 0) {
|
|
297
|
+
return widgetLayoutNodeEmissionTransform(layout, node_index);
|
|
298
|
+
}
|
|
299
|
+
if (node_index >= layout.nodes.len) return null;
|
|
300
|
+
var indices: [widget_layout.max_widget_depth]usize = undefined;
|
|
301
|
+
var len: usize = 0;
|
|
302
|
+
var current: ?usize = node_index;
|
|
303
|
+
while (current) |index| {
|
|
304
|
+
if (index >= layout.nodes.len or len >= indices.len) return null;
|
|
305
|
+
indices[len] = index;
|
|
306
|
+
len += 1;
|
|
307
|
+
if (widget_tree.widgetIsAnchored(layout.nodes[index].widget)) break;
|
|
308
|
+
current = layout.nodes[index].parent_index;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
var transform = outer_transform;
|
|
312
|
+
while (len > 0) {
|
|
313
|
+
len -= 1;
|
|
314
|
+
const widget = layout.nodes[indices[len]].widget;
|
|
315
|
+
const motion = state.layoutMotionOffset(widget.id);
|
|
316
|
+
if (motion.dx != 0 or motion.dy != 0) {
|
|
317
|
+
transform = transform.multiply(Affine.translate(motion.dx, motion.dy));
|
|
318
|
+
}
|
|
319
|
+
transform = transform.multiply(widgetTransform(widget));
|
|
320
|
+
}
|
|
321
|
+
return transform;
|
|
322
|
+
}
|
|
323
|
+
|
|
246
324
|
/// The transform stack a node inherits at its ordinary paint position. A
|
|
247
325
|
/// drag preview is hoisted to the window-level late pass to escape clipping,
|
|
248
326
|
/// so it must explicitly restore this stack before painting the source.
|
|
@@ -257,24 +335,45 @@ fn widgetLayoutNodeAncestorEmissionTransform(layout: anytype, node_index: usize)
|
|
|
257
335
|
|
|
258
336
|
/// The rectangular part of one layout node that can reach the surface,
|
|
259
337
|
/// returned in the node's untransformed layout coordinate space. Window
|
|
260
|
-
/// and ancestor clip bounds are intersected in device space, then
|
|
261
|
-
/// back through the exact transform stack
|
|
262
|
-
///
|
|
263
|
-
///
|
|
264
|
-
fn widgetLayoutNodeVisibleBounds(
|
|
338
|
+
/// and active ancestor clip bounds are intersected in device space, then
|
|
339
|
+
/// mapped back through the exact PRESENTATION transform stack. Floating
|
|
340
|
+
/// drag previews and clip-escaping landing motions stop at their lifted
|
|
341
|
+
/// subtree root, so the culling policy matches the late unclipped paint pass.
|
|
342
|
+
fn widgetLayoutNodeVisibleBounds(
|
|
343
|
+
layout: anytype,
|
|
344
|
+
node_index: usize,
|
|
345
|
+
bounds: geometry.RectF,
|
|
346
|
+
state: WidgetRenderState,
|
|
347
|
+
) ?geometry.RectF {
|
|
265
348
|
if (node_index >= layout.nodes.len) return null;
|
|
266
349
|
var device_visible = (widgetLayoutRootBounds(layout) orelse return null).normalized();
|
|
350
|
+
const has_layout_motion = state.layout_motions.len > 0;
|
|
351
|
+
const outer_transform = if (state.rendering_drag_preview) blk: {
|
|
352
|
+
const preview_id = state.drag_preview_id orelse return null;
|
|
353
|
+
const preview_index = widget_tree.widgetIndexById(layout, preview_id) orelse return null;
|
|
354
|
+
const ancestor_transform = widgetLayoutNodeAncestorEmissionTransform(layout, preview_index) orelse return null;
|
|
355
|
+
break :blk widgetLayoutDragPreviewTranslation(layout, preview_index, state, ancestor_transform);
|
|
356
|
+
} else Affine.identity();
|
|
267
357
|
|
|
268
358
|
var current = node_index;
|
|
269
359
|
while (true) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
360
|
+
const current_widget = layout.nodes[current].widget;
|
|
361
|
+
const is_drag_preview_root = state.rendering_drag_preview and
|
|
362
|
+
state.drag_preview_id != null and
|
|
363
|
+
state.drag_preview_id.? == current_widget.id;
|
|
364
|
+
// Every late window-level pass escapes clips ABOVE its lifted root,
|
|
365
|
+
// but nested clips inside that subtree still constrain descendants.
|
|
366
|
+
if (widget_tree.widgetIsAnchored(current_widget) or
|
|
367
|
+
is_drag_preview_root or
|
|
368
|
+
has_layout_motion and state.layoutMotionEscapesAncestorClips(current_widget.id))
|
|
369
|
+
{
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
273
372
|
const parent_index = layout.nodes[current].parent_index orelse break;
|
|
274
373
|
if (parent_index >= layout.nodes.len) return null;
|
|
275
374
|
const parent = layout.nodes[parent_index];
|
|
276
375
|
if (widgetClipsContent(parent.widget)) {
|
|
277
|
-
const parent_transform =
|
|
376
|
+
const parent_transform = widgetLayoutNodePresentationTransform(layout, parent_index, state, outer_transform) orelse return null;
|
|
278
377
|
const device_clip = parent_transform.transformRect(parent.frame.normalized());
|
|
279
378
|
device_visible = geometry.RectF.intersection(device_visible, device_clip);
|
|
280
379
|
if (device_visible.isEmpty()) return null;
|
|
@@ -282,7 +381,7 @@ fn widgetLayoutNodeVisibleBounds(layout: anytype, node_index: usize, bounds: geo
|
|
|
282
381
|
current = parent_index;
|
|
283
382
|
}
|
|
284
383
|
|
|
285
|
-
const transform =
|
|
384
|
+
const transform = widgetLayoutNodePresentationTransform(layout, node_index, state, outer_transform) orelse return null;
|
|
286
385
|
const inverse = transform.inverse() orelse return null;
|
|
287
386
|
const local_visible = inverse.transformRect(device_visible);
|
|
288
387
|
const clipped = geometry.RectF.intersection(bounds.normalized(), local_visible.normalized());
|
|
@@ -375,6 +474,16 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
375
474
|
try emitVisibleCodeTextSpansWidget(builder, paint_widget, tokens, clipped, .{});
|
|
376
475
|
}
|
|
377
476
|
}
|
|
477
|
+
} else if (paint_widget.spans.len > 0) {
|
|
478
|
+
if (tree_visible_bounds) |visible_bounds| {
|
|
479
|
+
const clipped = geometry.RectF.intersection(
|
|
480
|
+
paint_widget.frame.normalized(),
|
|
481
|
+
visible_bounds.normalized(),
|
|
482
|
+
);
|
|
483
|
+
if (!clipped.isEmpty()) {
|
|
484
|
+
try emitVisibleTextSpansWidget(builder, paint_widget, tokens, clipped);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
378
487
|
} else {
|
|
379
488
|
try emitTextWidget(builder, paint_widget, tokens);
|
|
380
489
|
}
|
|
@@ -389,7 +498,7 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
389
498
|
.icon_button => try widget_render_controls.emitIconButtonWidget(builder, paint_widget, tokens),
|
|
390
499
|
.select => try widget_render_controls.emitSelectWidget(builder, paint_widget, tokens),
|
|
391
500
|
.input, .text_field => try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
392
|
-
.textarea => if (paint_widget.code_editor)
|
|
501
|
+
.textarea => if (paint_widget.runtime_flags.code_editor)
|
|
393
502
|
try emitCodeEditorWidget(builder, paint_widget, tokens)
|
|
394
503
|
else
|
|
395
504
|
try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
@@ -586,7 +695,9 @@ fn emitWidgetLayoutChildren(
|
|
|
586
695
|
const child_index = nextWidgetLayoutPaintChild(layout, parent_index, tokens, previous) orelse return;
|
|
587
696
|
// Anchored floating children paint in the late z-pass
|
|
588
697
|
// (`emitWidgetLayoutAnchored`), never in tree position.
|
|
589
|
-
if (!widget_tree.widgetIsAnchored(layout.nodes[child_index].widget)
|
|
698
|
+
if (!widget_tree.widgetIsAnchored(layout.nodes[child_index].widget) and
|
|
699
|
+
!state.layoutMotionEscapesAncestorClips(layout.nodes[child_index].widget.id))
|
|
700
|
+
{
|
|
590
701
|
const segment = if (group_index) |index|
|
|
591
702
|
layoutButtonGroupSegment(layout, index, child_index)
|
|
592
703
|
else
|
|
@@ -690,7 +801,7 @@ fn emitWidgetLayoutNodeContent(
|
|
|
690
801
|
try emitWidgetLayoutChildren(builder, layout, node_index, tokens, state);
|
|
691
802
|
try builder.popClip();
|
|
692
803
|
// Native scroll drivers own the (OS overlay) scrollbar.
|
|
693
|
-
if (!paint_widget.native_scroll) {
|
|
804
|
+
if (!paint_widget.runtime_flags.native_scroll) {
|
|
694
805
|
try widget_render_scroll.emitScrollViewScrollbars(
|
|
695
806
|
builder,
|
|
696
807
|
paint_widget.frame,
|
|
@@ -756,9 +867,13 @@ fn emitWidgetLayoutNodeContent(
|
|
|
756
867
|
.menu_surface, .dropdown_menu => try widget_render_surfaces.emitMenuSurfaceWidgetChrome(builder, paint_widget, tokens),
|
|
757
868
|
.text => {
|
|
758
869
|
if (isSyntaxCodeParagraph(paint_widget)) {
|
|
759
|
-
if (widgetLayoutNodeVisibleBounds(layout, node_index, paint_widget.frame)) |visible_bounds| {
|
|
870
|
+
if (widgetLayoutNodeVisibleBounds(layout, node_index, paint_widget.frame, state)) |visible_bounds| {
|
|
760
871
|
try emitVisibleCodeTextSpansWidget(builder, paint_widget, tokens, visible_bounds, .{});
|
|
761
872
|
}
|
|
873
|
+
} else if (paint_widget.spans.len > 0) {
|
|
874
|
+
if (widgetLayoutNodeVisibleBounds(layout, node_index, paint_widget.frame, state)) |visible_bounds| {
|
|
875
|
+
try emitVisibleTextSpansWidget(builder, paint_widget, tokens, visible_bounds);
|
|
876
|
+
}
|
|
762
877
|
} else {
|
|
763
878
|
try emitTextWidget(builder, paint_widget, tokens);
|
|
764
879
|
}
|
|
@@ -773,7 +888,7 @@ fn emitWidgetLayoutNodeContent(
|
|
|
773
888
|
.icon_button => try widget_render_controls.emitIconButtonWidget(builder, paint_widget, tokens),
|
|
774
889
|
.select => try widget_render_controls.emitSelectWidget(builder, paint_widget, tokens),
|
|
775
890
|
.input, .text_field => try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
776
|
-
.textarea => if (paint_widget.code_editor)
|
|
891
|
+
.textarea => if (paint_widget.runtime_flags.code_editor)
|
|
777
892
|
try emitCodeEditorWidget(builder, paint_widget, tokens)
|
|
778
893
|
else
|
|
779
894
|
try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
@@ -847,7 +962,7 @@ fn emitWidgetLayoutScrollableChildren(
|
|
|
847
962
|
// Native scroll drivers own the (OS overlay) scrollbar. These are
|
|
848
963
|
// the virtualized containers — vertical machinery, so only the
|
|
849
964
|
// vertical bar can exist.
|
|
850
|
-
if (!widget.native_scroll) {
|
|
965
|
+
if (!widget.runtime_flags.native_scroll) {
|
|
851
966
|
try widget_render_scroll.emitScrollViewScrollbars(
|
|
852
967
|
builder,
|
|
853
968
|
widget.frame,
|
|
@@ -1090,7 +1205,7 @@ fn emitScrollViewWidget(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
1090
1205
|
try emitWidgetChildren(builder, widget.children, tokens, depth);
|
|
1091
1206
|
try builder.popClip();
|
|
1092
1207
|
// Native scroll drivers own the (OS overlay) scrollbar.
|
|
1093
|
-
if (!widget.native_scroll) {
|
|
1208
|
+
if (!widget.runtime_flags.native_scroll) {
|
|
1094
1209
|
try widget_render_scroll.emitScrollViewScrollbars(
|
|
1095
1210
|
builder,
|
|
1096
1211
|
widget.frame,
|
|
@@ -1365,112 +1480,194 @@ fn emitStaticTextSelectionBounded(
|
|
|
1365
1480
|
}
|
|
1366
1481
|
}
|
|
1367
1482
|
|
|
1368
|
-
///
|
|
1369
|
-
///
|
|
1370
|
-
/// decorations get stable hashed command ids derived from the widget id
|
|
1371
|
-
/// and their ordinal, so retained diffing works across frames.
|
|
1483
|
+
/// Full-frame compatibility path for span-bearing composite leaves such
|
|
1484
|
+
/// as table cells. Ordinary `.text` nodes pass their real viewport below.
|
|
1372
1485
|
fn emitTextSpansWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
1486
|
+
return emitVisibleTextSpansWidget(builder, widget, tokens, widget.frame);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
/// Draw the visible pages of an ordinary span paragraph: one single-line
|
|
1490
|
+
/// text command per laid-out run plus backgrounds and thin decoration
|
|
1491
|
+
/// rects. Layout keeps the full paragraph height, while painting pages the
|
|
1492
|
+
/// bounded run store through the current viewport. Without this split, a
|
|
1493
|
+
/// transcript longer than `max_text_span_lines_per_paragraph` reserved its
|
|
1494
|
+
/// real height but painted only its first page, leaving a blank tail after
|
|
1495
|
+
/// the scroll moved beyond line 128.
|
|
1496
|
+
fn emitVisibleTextSpansWidget(
|
|
1497
|
+
builder: *Builder,
|
|
1498
|
+
widget: Widget,
|
|
1499
|
+
tokens: DesignTokens,
|
|
1500
|
+
visible_bounds: geometry.RectF,
|
|
1501
|
+
) Error!void {
|
|
1373
1502
|
const content = widget_metrics.widgetTextSpanContentFrame(widget, tokens);
|
|
1374
1503
|
const layout_options = widget_metrics.widgetTextSpanLayoutOptions(
|
|
1375
1504
|
widget,
|
|
1376
1505
|
tokens,
|
|
1377
1506
|
textWrapMaxWidth(tokens, content.width),
|
|
1378
1507
|
);
|
|
1508
|
+
const line_height = text_spans_model.textSpanLineHeight(widget.spans, layout_options);
|
|
1509
|
+
if (line_height <= 0 or !std.math.isFinite(line_height)) return;
|
|
1510
|
+
|
|
1511
|
+
const first_visible_line: usize = if (std.math.isFinite(visible_bounds.y - content.y) and
|
|
1512
|
+
visible_bounds.y > content.y)
|
|
1513
|
+
@intFromFloat(@floor((visible_bounds.y - content.y) / line_height))
|
|
1514
|
+
else
|
|
1515
|
+
0;
|
|
1516
|
+
const last_visible_line: usize = if (std.math.isFinite(visible_bounds.maxY() - content.y) and
|
|
1517
|
+
visible_bounds.maxY() > content.y)
|
|
1518
|
+
@intFromFloat(@floor((visible_bounds.maxY() - content.y) / line_height))
|
|
1519
|
+
else
|
|
1520
|
+
first_visible_line;
|
|
1521
|
+
const lines_per_page = text_spans_model.max_text_span_lines_per_paragraph;
|
|
1522
|
+
const first_page_line = (first_visible_line / lines_per_page) * lines_per_page;
|
|
1523
|
+
|
|
1379
1524
|
var runs: [text_spans_model.max_text_span_runs_per_paragraph]text_spans_model.TextSpanRun = undefined;
|
|
1380
|
-
const layout = text_spans_model.layoutTextSpans(
|
|
1381
|
-
widget.spans,
|
|
1382
|
-
layout_options,
|
|
1383
|
-
&runs,
|
|
1384
|
-
);
|
|
1385
1525
|
|
|
1386
|
-
|
|
1387
|
-
//
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1526
|
+
// Backgrounds from every visible page stay behind the paragraph's
|
|
1527
|
+
// selection layer and glyphs, preserving the original paint order.
|
|
1528
|
+
var page_first_line = first_page_line;
|
|
1529
|
+
while (true) {
|
|
1530
|
+
const layout = text_spans_model.layoutTextSpansFromLine(
|
|
1531
|
+
widget.spans,
|
|
1532
|
+
layout_options,
|
|
1533
|
+
page_first_line,
|
|
1534
|
+
&runs,
|
|
1535
|
+
);
|
|
1536
|
+
const page_index = page_first_line / lines_per_page;
|
|
1537
|
+
const ordinal_base = page_index *| text_spans_model.max_text_span_runs_per_paragraph;
|
|
1538
|
+
for (layout.runs, 0..) |run, ordinal| {
|
|
1539
|
+
if (run.text.len == 0) continue;
|
|
1540
|
+
const background = widget.spans[run.span_index].background orelse continue;
|
|
1541
|
+
const bounds = text_spans_model.textSpanRunBounds(layout, run);
|
|
1542
|
+
const frame = geometry.RectF.init(
|
|
1399
1543
|
content.x + bounds.x,
|
|
1400
1544
|
content.y + bounds.y,
|
|
1401
1545
|
bounds.width,
|
|
1402
1546
|
bounds.height,
|
|
1403
|
-
)
|
|
1404
|
-
|
|
1405
|
-
|
|
1547
|
+
);
|
|
1548
|
+
if (!frame.intersects(visible_bounds)) continue;
|
|
1549
|
+
try builder.fillRect(.{
|
|
1550
|
+
// Page zero keeps the historical ids byte-for-byte; later
|
|
1551
|
+
// pages occupy disjoint ordinal bands.
|
|
1552
|
+
.id = textSpanBackgroundCommandId(widget.id, ordinal_base +| ordinal),
|
|
1553
|
+
.rect = pixelSnapGeometryRect(tokens, frame),
|
|
1554
|
+
.fill = colorFill(text_spans_model.textSpanColorValue(tokens.colors, background)),
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
const next_first_line = page_first_line +| lines_per_page;
|
|
1558
|
+
if (next_first_line <= page_first_line or
|
|
1559
|
+
next_first_line > last_visible_line or
|
|
1560
|
+
next_first_line >= layout.line_count)
|
|
1561
|
+
{
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
page_first_line = next_first_line;
|
|
1406
1565
|
}
|
|
1407
1566
|
|
|
1408
1567
|
try emitStaticTextSelection(builder, widget, tokens);
|
|
1409
1568
|
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
.
|
|
1440
|
-
.
|
|
1441
|
-
.
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
},
|
|
1445
|
-
});
|
|
1569
|
+
page_first_line = first_page_line;
|
|
1570
|
+
while (true) {
|
|
1571
|
+
const layout = text_spans_model.layoutTextSpansFromLine(
|
|
1572
|
+
widget.spans,
|
|
1573
|
+
layout_options,
|
|
1574
|
+
page_first_line,
|
|
1575
|
+
&runs,
|
|
1576
|
+
);
|
|
1577
|
+
const page_index = page_first_line / lines_per_page;
|
|
1578
|
+
const ordinal_base = page_index *| text_spans_model.max_text_span_runs_per_paragraph;
|
|
1579
|
+
const decoration_base = page_index *| (text_spans_model.max_text_span_runs_per_paragraph * 2);
|
|
1580
|
+
var decoration_ordinal: usize = 0;
|
|
1581
|
+
for (layout.runs, 0..) |run, ordinal| {
|
|
1582
|
+
if (run.text.len == 0) continue;
|
|
1583
|
+
const span = widget.spans[run.span_index];
|
|
1584
|
+
const is_link = span.link.len > 0;
|
|
1585
|
+
const underline_ordinal: ?usize = if (span.underline or is_link) blk: {
|
|
1586
|
+
const value = decoration_base +| decoration_ordinal;
|
|
1587
|
+
decoration_ordinal += 1;
|
|
1588
|
+
break :blk value;
|
|
1589
|
+
} else null;
|
|
1590
|
+
const strikethrough_ordinal: ?usize = if (span.strikethrough) blk: {
|
|
1591
|
+
const value = decoration_base +| decoration_ordinal;
|
|
1592
|
+
decoration_ordinal += 1;
|
|
1593
|
+
break :blk value;
|
|
1594
|
+
} else null;
|
|
1595
|
+
const bounds = text_spans_model.textSpanRunBounds(layout, run);
|
|
1596
|
+
const run_frame = geometry.RectF.init(
|
|
1597
|
+
content.x + bounds.x,
|
|
1598
|
+
content.y + bounds.y,
|
|
1599
|
+
bounds.width,
|
|
1600
|
+
bounds.height,
|
|
1601
|
+
);
|
|
1602
|
+
if (!run_frame.intersects(visible_bounds)) continue;
|
|
1446
1603
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
.
|
|
1604
|
+
const color = if (span.color) |ref|
|
|
1605
|
+
text_spans_model.textSpanColorValue(tokens.colors, ref)
|
|
1606
|
+
else if (is_link)
|
|
1607
|
+
widgetForegroundColor(widget, tokens, tokens.colors.accent)
|
|
1608
|
+
else
|
|
1609
|
+
widgetForegroundColor(widget, tokens, tokens.colors.text);
|
|
1610
|
+
const origin = pixelSnapTextPoint(tokens, geometry.PointF.init(content.x + run.x, content.y + run.baseline));
|
|
1611
|
+
try builder.drawText(.{
|
|
1612
|
+
.id = textSpanRunCommandId(widget.id, ordinal_base +| ordinal),
|
|
1613
|
+
.font_id = run.font_id,
|
|
1614
|
+
.size = run.size,
|
|
1615
|
+
.origin = origin,
|
|
1616
|
+
.color = color,
|
|
1617
|
+
.text = run.text,
|
|
1618
|
+
// Wrapping already happened at the span level (each run is one
|
|
1619
|
+
// line segment), so the options carry no wrap work — they carry
|
|
1620
|
+
// the measurement seam. Renderers that walk per-cluster
|
|
1621
|
+
// advances (the reference renderer behind every automation
|
|
1622
|
+
// screenshot) then advance with the same provider layout
|
|
1623
|
+
// positioned the runs with; without it a provider-kerned prose
|
|
1624
|
+
// run repainted at estimator advances overran the next span's
|
|
1625
|
+
// x and visually swallowed the inter-span space
|
|
1626
|
+
// ("remaining`experimental_`" -> "remainingexperimental_").
|
|
1627
|
+
.text_layout = .{
|
|
1628
|
+
.max_width = 0,
|
|
1629
|
+
.line_height = layout.line_height,
|
|
1630
|
+
.wrap = .none,
|
|
1631
|
+
.alignment = .start,
|
|
1632
|
+
.measure = tokens.text_measure,
|
|
1633
|
+
},
|
|
1458
1634
|
});
|
|
1459
|
-
|
|
1635
|
+
|
|
1636
|
+
const thickness = @max(1, tokens.stroke.hairline);
|
|
1637
|
+
if (underline_ordinal) |decoration_id_ordinal| {
|
|
1638
|
+
try builder.fillRect(.{
|
|
1639
|
+
.id = textSpanDecorationCommandId(widget.id, decoration_id_ordinal),
|
|
1640
|
+
.rect = pixelSnapGeometryRect(tokens, geometry.RectF.init(
|
|
1641
|
+
content.x + run.x,
|
|
1642
|
+
content.y + run.baseline + @max(1, run.size * 0.1),
|
|
1643
|
+
run.width,
|
|
1644
|
+
thickness,
|
|
1645
|
+
)),
|
|
1646
|
+
.fill = colorFill(color),
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
if (strikethrough_ordinal) |decoration_id_ordinal| {
|
|
1650
|
+
try builder.fillRect(.{
|
|
1651
|
+
.id = textSpanDecorationCommandId(widget.id, decoration_id_ordinal),
|
|
1652
|
+
.rect = pixelSnapGeometryRect(tokens, geometry.RectF.init(
|
|
1653
|
+
content.x + run.x,
|
|
1654
|
+
content.y + run.baseline - run.size * 0.3,
|
|
1655
|
+
run.width,
|
|
1656
|
+
thickness,
|
|
1657
|
+
)),
|
|
1658
|
+
.fill = colorFill(color),
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1460
1661
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
thickness,
|
|
1469
|
-
)),
|
|
1470
|
-
.fill = colorFill(color),
|
|
1471
|
-
});
|
|
1472
|
-
decoration_ordinal += 1;
|
|
1662
|
+
|
|
1663
|
+
const next_first_line = page_first_line +| lines_per_page;
|
|
1664
|
+
if (next_first_line <= page_first_line or
|
|
1665
|
+
next_first_line > last_visible_line or
|
|
1666
|
+
next_first_line >= layout.line_count)
|
|
1667
|
+
{
|
|
1668
|
+
break;
|
|
1473
1669
|
}
|
|
1670
|
+
page_first_line = next_first_line;
|
|
1474
1671
|
}
|
|
1475
1672
|
}
|
|
1476
1673
|
|
|
@@ -1579,10 +1776,10 @@ fn emitVisibleCodeTextSpansWidget(
|
|
|
1579
1776
|
visible_bounds: geometry.RectF,
|
|
1580
1777
|
paint: CodeTextPaint,
|
|
1581
1778
|
) Error!void {
|
|
1582
|
-
if (widget.code_editor and widget.text_no_wrap) {
|
|
1779
|
+
if (widget.runtime_flags.code_editor and widget.text_no_wrap) {
|
|
1583
1780
|
return emitVisibleEditableCodeLines(builder, widget, tokens, visible_bounds, paint);
|
|
1584
1781
|
}
|
|
1585
|
-
if (widget.code_editor) {
|
|
1782
|
+
if (widget.runtime_flags.code_editor) {
|
|
1586
1783
|
return emitVisibleWrappedEditableCodeLines(builder, widget, tokens, visible_bounds, paint);
|
|
1587
1784
|
}
|
|
1588
1785
|
const spans = widget.spans;
|
|
@@ -2202,7 +2399,7 @@ fn emitCodeLineDecorations(
|
|
|
2202
2399
|
while (line_start <= widget.text.len) : (logical_line += 1) {
|
|
2203
2400
|
// A terminal newline closes the preceding painted line; the span
|
|
2204
2401
|
// breaker intentionally does not reserve another empty visual line.
|
|
2205
|
-
if (line_start == widget.text.len and widget.text.len > 0 and !widget.code_editor) break;
|
|
2402
|
+
if (line_start == widget.text.len and widget.text.len > 0 and !widget.runtime_flags.code_editor) break;
|
|
2206
2403
|
const newline = std.mem.indexOfScalarPos(u8, widget.text, line_start, '\n');
|
|
2207
2404
|
const line_end = newline orelse widget.text.len;
|
|
2208
2405
|
const line = widget.text[line_start..line_end];
|
|
@@ -4090,8 +4287,17 @@ fn widgetWithFrame(widget: Widget, frame: geometry.RectF) Widget {
|
|
|
4090
4287
|
fn widgetWithRenderState(widget: Widget, state: WidgetRenderState) Widget {
|
|
4091
4288
|
var copy = widget;
|
|
4092
4289
|
if (state.focused_id != null or state.focus_visible_id != null) {
|
|
4093
|
-
|
|
4094
|
-
|
|
4290
|
+
// A menu's active row is logical focus, regardless of whether
|
|
4291
|
+
// the menu was opened with the pointer or keyboard. Menu items
|
|
4292
|
+
// render that state as a quiet full-row wash and never as a
|
|
4293
|
+
// focus-ring outline. Every other widget keeps the modality-
|
|
4294
|
+
// aware focus-visible projection used for keyboard-only rings.
|
|
4295
|
+
const painted_focus_id = if (copy.kind == .menu_item)
|
|
4296
|
+
state.focused_id
|
|
4297
|
+
else
|
|
4298
|
+
state.focus_visible_id;
|
|
4299
|
+
copy.state.focused = if (painted_focus_id) |focused_id|
|
|
4300
|
+
copy.id != 0 and copy.id == focused_id
|
|
4095
4301
|
else
|
|
4096
4302
|
false;
|
|
4097
4303
|
}
|