@native-sdk/cli 0.7.0 → 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 +114 -103
- 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/packages/core/sdk/text.ts +25 -14
- package/packages/core/src/checker.ts +39 -0
- package/packages/core/src/emitter.ts +125 -1
- package/skill-data/native-ui/SKILL.md +11 -7
- package/src/platform/macos/appkit_host.m +76 -4
- package/src/platform/macos/cef_host.mm +24 -2
- package/src/platform/macos/root.zig +13 -0
- 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 +501 -33
- package/src/primitives/canvas/code_tests.zig +1029 -6
- package/src/primitives/canvas/events.zig +111 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/markdown_tests.zig +17 -18
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/text.zig +6 -0
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +160 -36
- package/src/primitives/canvas/ui_markup.zig +60 -9
- package/src/primitives/canvas/ui_markup_compiled.zig +41 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +12 -0
- package/src/primitives/canvas/ui_markup_contract.zig +17 -1
- package/src/primitives/canvas/ui_markup_view.zig +44 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +80 -6
- package/src/primitives/canvas/ui_schema.zig +18 -0
- package/src/primitives/canvas/ui_schema_tests.zig +10 -7
- package/src/primitives/canvas/ui_tests.zig +40 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +12 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +47 -6
- package/src/primitives/canvas/widget_render.zig +849 -78
- package/src/primitives/canvas/widget_render_controls.zig +83 -25
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_runtime.zig +2 -0
- package/src/primitives/canvas/widget_text_input.zig +167 -8
- package/src/primitives/canvas/widget_tree.zig +6 -5
- package/src/primitives/canvas/widgets.zig +78 -2
- package/src/runtime/canvas_budget_edge_tests.zig +3 -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_limits.zig +13 -6
- package/src/runtime/canvas_widget_clipboard_tests.zig +8 -5
- package/src/runtime/canvas_widget_context_menu.zig +7 -2
- package/src/runtime/canvas_widget_event_tests.zig +18 -14
- package/src/runtime/canvas_widget_events.zig +51 -20
- package/src/runtime/canvas_widget_runtime.zig +108 -4
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +59 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +100 -0
- package/src/runtime/canvas_widget_state.zig +27 -0
- package/src/runtime/canvas_widget_text_tests.zig +326 -0
- package/src/runtime/core.zig +15 -5
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +50 -19
- 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 +60 -16
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_scroll.zig +48 -18
- package/src/runtime/view_widget_text.zig +59 -16
- package/src/runtime/window_view_runtime.zig +10 -0
- package/src/tooling/templates.zig +9 -6
|
@@ -627,7 +627,7 @@ test "only a focused live terminal owns Tab and focus entry suppresses the whole
|
|
|
627
627
|
try std.testing.expectEqual(@as(canvas.ObjectId, 2), harness.runtime.views[0].canvas_widget_focused_id);
|
|
628
628
|
try std.testing.expectEqual(@as(canvas.ObjectId, 2), app_state.target_id);
|
|
629
629
|
try std.testing.expect(app_state.focus_moved);
|
|
630
|
-
try std.testing.expect(harness.runtime.views[0].
|
|
630
|
+
try std.testing.expect(harness.runtime.views[0].canvas_widget_tab_input_focus_entry_held);
|
|
631
631
|
|
|
632
632
|
// Auto-repeat while Tab is held, then its key-up: neither produces
|
|
633
633
|
// another widget event at the terminal.
|
|
@@ -646,7 +646,7 @@ test "only a focused live terminal owns Tab and focus entry suppresses the whole
|
|
|
646
646
|
.modifiers = .{ .shift = true },
|
|
647
647
|
} });
|
|
648
648
|
try std.testing.expectEqual(@as(u32, 3), app_state.keyboard_count);
|
|
649
|
-
try std.testing.expect(!harness.runtime.views[0].
|
|
649
|
+
try std.testing.expect(!harness.runtime.views[0].canvas_widget_tab_input_focus_entry_held);
|
|
650
650
|
|
|
651
651
|
// The same nonzero binding after session exit is no longer an input
|
|
652
652
|
// owner: its published grid says the session cannot accept input,
|
|
@@ -2407,12 +2407,14 @@ test "a target-less composition stays target-less when a text field takes focus
|
|
|
2407
2407
|
// The composition STARTS target-less (nothing focused): the preedit
|
|
2408
2408
|
// buffers for the surface's own consumer.
|
|
2409
2409
|
harness.runtime.views[0].canvas_widget_focused_id = 0;
|
|
2410
|
-
try harness.runtime.dispatchPlatformEvent(app, .{
|
|
2411
|
-
.
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2410
|
+
try harness.runtime.dispatchPlatformEvent(app, .{
|
|
2411
|
+
.gpu_surface_input = .{
|
|
2412
|
+
.window_id = 1,
|
|
2413
|
+
.label = "canvas",
|
|
2414
|
+
.kind = .ime_set_composition,
|
|
2415
|
+
.text = "\xe3\x81\x8b", // か
|
|
2416
|
+
},
|
|
2417
|
+
});
|
|
2416
2418
|
try std.testing.expectEqual(@as(u32, 0), app_state.committed_count);
|
|
2417
2419
|
|
|
2418
2420
|
// Focus lands on a text field mid-sequence. The empty commit
|
|
@@ -2600,12 +2602,14 @@ test "target-less IME preedit is per-surface and command chords never commit tex
|
|
|
2600
2602
|
harness.runtime.views[1].focused = true;
|
|
2601
2603
|
|
|
2602
2604
|
// Surface A composes; the preedit is provisional — nothing commits.
|
|
2603
|
-
try harness.runtime.dispatchPlatformEvent(app, .{
|
|
2604
|
-
.
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2605
|
+
try harness.runtime.dispatchPlatformEvent(app, .{
|
|
2606
|
+
.gpu_surface_input = .{
|
|
2607
|
+
.window_id = 1,
|
|
2608
|
+
.label = "canvas-a",
|
|
2609
|
+
.kind = .ime_set_composition,
|
|
2610
|
+
.text = "\xe3\x81\x8b", // か
|
|
2611
|
+
},
|
|
2612
|
+
});
|
|
2609
2613
|
try std.testing.expectEqual(@as(u32, 0), app_state.committed_count);
|
|
2610
2614
|
|
|
2611
2615
|
// THE per-surface pin: surface B's empty commit must NOT insert
|
|
@@ -330,14 +330,27 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
330
330
|
// menu path before reaching here).
|
|
331
331
|
self.views[index].canvas_widget_click_count = 0;
|
|
332
332
|
self.views[index].canvas_widget_click_timestamp_ns = 0;
|
|
333
|
+
self.views[index].canvas_widget_click_pointer_id = 0;
|
|
334
|
+
self.views[index].canvas_widget_click_target_id = 0;
|
|
333
335
|
return;
|
|
334
336
|
}
|
|
335
337
|
const previous_count = self.views[index].canvas_widget_click_count;
|
|
336
338
|
const previous_timestamp = self.views[index].canvas_widget_click_timestamp_ns;
|
|
337
339
|
const previous_point = self.views[index].canvas_widget_click_point;
|
|
340
|
+
const previous_pointer_id = self.views[index].canvas_widget_click_pointer_id;
|
|
341
|
+
const previous_target_id = self.views[index].canvas_widget_click_target_id;
|
|
338
342
|
const point = pointer_event.pointer.point;
|
|
343
|
+
const pointer_id = pointer_event.pointer.pointer_id;
|
|
344
|
+
const target_id: canvas.ObjectId = if (pointer_event.press_target) |target|
|
|
345
|
+
target.id
|
|
346
|
+
else if (pointer_event.target) |target|
|
|
347
|
+
target.id
|
|
348
|
+
else
|
|
349
|
+
0;
|
|
339
350
|
const chained = previous_count != 0 and
|
|
340
351
|
previous_timestamp != 0 and
|
|
352
|
+
pointer_id == previous_pointer_id and
|
|
353
|
+
target_id == previous_target_id and
|
|
341
354
|
input_event.timestamp_ns >= previous_timestamp and
|
|
342
355
|
input_event.timestamp_ns - previous_timestamp <= canvas_widget_multi_click_interval_ns and
|
|
343
356
|
@abs(point.x - previous_point.x) <= canvas_widget_multi_click_slop and
|
|
@@ -348,6 +361,8 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
348
361
|
self.views[index].canvas_widget_click_count = count;
|
|
349
362
|
self.views[index].canvas_widget_click_timestamp_ns = input_event.timestamp_ns;
|
|
350
363
|
self.views[index].canvas_widget_click_point = point;
|
|
364
|
+
self.views[index].canvas_widget_click_pointer_id = pointer_id;
|
|
365
|
+
self.views[index].canvas_widget_click_target_id = target_id;
|
|
351
366
|
pointer_event.pointer.click_count = count;
|
|
352
367
|
},
|
|
353
368
|
.move, .up => {
|
|
@@ -2070,6 +2085,12 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2070
2085
|
};
|
|
2071
2086
|
keyboard_event.keyboard.edit = edit;
|
|
2072
2087
|
|
|
2088
|
+
if (self.views[index].canvasWidgetTextEditNeedsLargeStorage(target.id, edit)) {
|
|
2089
|
+
for (self.views[0 .. index + 1]) |*view| {
|
|
2090
|
+
try view.ensureLargeCanvasWidgetTextStorage(self.owned_allocator);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2073
2094
|
const dirty = if (keyboard_event.history_replay)
|
|
2074
2095
|
try self.views[index].applyCanvasWidgetTextEditWithoutHistory(target.id, edit) orelse return
|
|
2075
2096
|
else
|
|
@@ -2370,17 +2391,17 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2370
2391
|
}
|
|
2371
2392
|
|
|
2372
2393
|
/// Returns true for an auto-repeat or release belonging to the
|
|
2373
|
-
/// physical Tab gesture that moved focus into a
|
|
2394
|
+
/// physical Tab gesture that moved focus into a Tab-owning editor.
|
|
2374
2395
|
/// The caller suppresses that transition; the release also
|
|
2375
2396
|
/// retires the gesture latch.
|
|
2376
|
-
pub fn
|
|
2397
|
+
pub fn consumeCanvasWidgetTabInputFocusEntry(self: *Runtime, input_event: GpuSurfaceInputEvent) bool {
|
|
2377
2398
|
if (input_event.kind != .key_down and input_event.kind != .key_up) return false;
|
|
2378
2399
|
if (!std.ascii.eqlIgnoreCase(input_event.key, "tab")) return false;
|
|
2379
2400
|
const index = runtimeFindViewIndex(self, input_event.window_id, input_event.label) orelse return false;
|
|
2380
2401
|
if (self.views[index].kind != .gpu_surface) return false;
|
|
2381
|
-
if (!self.views[index].
|
|
2402
|
+
if (!self.views[index].canvas_widget_tab_input_focus_entry_held) return false;
|
|
2382
2403
|
if (input_event.kind == .key_up) {
|
|
2383
|
-
self.views[index].
|
|
2404
|
+
self.views[index].canvas_widget_tab_input_focus_entry_held = false;
|
|
2384
2405
|
}
|
|
2385
2406
|
return true;
|
|
2386
2407
|
}
|
|
@@ -2415,18 +2436,21 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2415
2436
|
const current_id: ?canvas.ObjectId = if (self.views[index].canvas_widget_focused_id == 0) null else self.views[index].canvas_widget_focused_id;
|
|
2416
2437
|
const layout = self.views[index].widgetLayoutTree();
|
|
2417
2438
|
if (std.ascii.eqlIgnoreCase(input_event.key, "tab")) {
|
|
2418
|
-
//
|
|
2419
|
-
//
|
|
2420
|
-
//
|
|
2421
|
-
// target: the routed keyboard pass below will therefore
|
|
2422
|
-
// address this same terminal and its emulator can encode
|
|
2423
|
-
// Tab/Shift+Tab for the pty. Disabled/hidden terminals
|
|
2424
|
-
// cannot occupy the focus register because
|
|
2425
|
-
// focusTargetById rejects them, so stale focus still
|
|
2426
|
-
// falls through to the ordinary traversal repair.
|
|
2439
|
+
// Live terminals own Tab/Shift+Tab as input; editable code
|
|
2440
|
+
// owns plain Tab as indentation while Shift+Tab remains an
|
|
2441
|
+
// accessible way to leave the editor.
|
|
2427
2442
|
if (current_id) |id| {
|
|
2428
2443
|
if (layout.focusTargetById(id)) |current| {
|
|
2429
2444
|
if (canvasWidgetTerminalOwnsTabInput(layout, current)) return false;
|
|
2445
|
+
if (!input_event.modifiers.shift and
|
|
2446
|
+
!input_event.modifiers.primary and
|
|
2447
|
+
!input_event.modifiers.command and
|
|
2448
|
+
!input_event.modifiers.control and
|
|
2449
|
+
!input_event.modifiers.option and
|
|
2450
|
+
canvasWidgetCodeEditorOwnsTabInput(layout, current))
|
|
2451
|
+
{
|
|
2452
|
+
return false;
|
|
2453
|
+
}
|
|
2430
2454
|
}
|
|
2431
2455
|
}
|
|
2432
2456
|
const direction: canvas.WidgetFocusDirection = if (input_event.modifiers.shift) .backward else .forward;
|
|
@@ -2435,13 +2459,14 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2435
2459
|
else
|
|
2436
2460
|
layout.focusTarget(current_id, direction) orelse return false;
|
|
2437
2461
|
const moved = try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2438
|
-
if (moved and
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
//
|
|
2443
|
-
//
|
|
2444
|
-
|
|
2462
|
+
if (moved and
|
|
2463
|
+
(canvasWidgetTerminalOwnsTabInput(layout, target) or
|
|
2464
|
+
canvasWidgetCodeEditorOwnsTabInput(layout, target)))
|
|
2465
|
+
{
|
|
2466
|
+
// The key-down entered this input owner through focus
|
|
2467
|
+
// traversal. Hold that classification through repeats
|
|
2468
|
+
// and key-up so the gesture never becomes editor input.
|
|
2469
|
+
self.views[index].canvas_widget_tab_input_focus_entry_held = true;
|
|
2445
2470
|
}
|
|
2446
2471
|
return moved;
|
|
2447
2472
|
}
|
|
@@ -2587,6 +2612,12 @@ fn canvasWidgetTerminalOwnsTabInput(layout: canvas.WidgetLayoutTree, target: can
|
|
|
2587
2612
|
return grid.running;
|
|
2588
2613
|
}
|
|
2589
2614
|
|
|
2615
|
+
fn canvasWidgetCodeEditorOwnsTabInput(layout: canvas.WidgetLayoutTree, target: canvas.WidgetFocusTarget) bool {
|
|
2616
|
+
if (target.kind != .textarea or target.index >= layout.nodes.len) return false;
|
|
2617
|
+
const widget = layout.nodes[target.index].widget;
|
|
2618
|
+
return widget.code_editor and !widget.state.disabled;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2590
2621
|
fn canvasDirtyRegionForView(view_frame: geometry.RectF, local_dirty: geometry.RectF) ?geometry.RectF {
|
|
2591
2622
|
const normalized_view = view_frame.normalized();
|
|
2592
2623
|
const surface_bounds = geometry.RectF.init(0, 0, normalized_view.width, normalized_view.height);
|
|
@@ -161,6 +161,11 @@ pub const CanvasWidgetTextReconcileEntry = struct {
|
|
|
161
161
|
text_selection: ?canvas.TextSelection = null,
|
|
162
162
|
text_composition: ?canvas.TextRange = null,
|
|
163
163
|
value: f32 = 0,
|
|
164
|
+
value_x: f32 = 0,
|
|
165
|
+
code_content_width: f32 = 0,
|
|
166
|
+
code_content_width_generation: u64 = 0,
|
|
167
|
+
code_content_width_font_id: u64 = 0,
|
|
168
|
+
code_content_width_size_bits: u32 = 0,
|
|
164
169
|
};
|
|
165
170
|
|
|
166
171
|
pub const CanvasWidgetSourceScrollEntry = struct {
|
|
@@ -248,6 +253,54 @@ pub fn restoreCanvasWidgetLayoutScrollOffsets(
|
|
|
248
253
|
}
|
|
249
254
|
}
|
|
250
255
|
|
|
256
|
+
fn previousLayoutHasSelectedTab(previous: canvas.WidgetLayoutTree, id: canvas.ObjectId) bool {
|
|
257
|
+
for (previous.nodes) |node| {
|
|
258
|
+
if (node.widget.id == id) return node.widget.semantics.role == .tab and node.widget.state.selected;
|
|
259
|
+
}
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// A tab activation reveals only the pixels outside its standing horizontal
|
|
264
|
+
/// viewport. This runs after retained scroll restoration, against final layout
|
|
265
|
+
/// frames, so an already-visible tab preserves the exact offset and a newly
|
|
266
|
+
/// mounted native scroll driver never paints a speculative leading-edge jump.
|
|
267
|
+
fn revealNewlySelectedTabs(previous: canvas.WidgetLayoutTree, nodes: []canvas.WidgetLayoutNode) void {
|
|
268
|
+
for (nodes, 0..) |tab_node, tab_index| {
|
|
269
|
+
const tab = tab_node.widget;
|
|
270
|
+
if (tab.semantics.role != .tab or !tab.state.selected) continue;
|
|
271
|
+
if (tab.id != 0 and previousLayoutHasSelectedTab(previous, tab.id)) continue;
|
|
272
|
+
|
|
273
|
+
var ancestor = tab_node.parent_index;
|
|
274
|
+
while (ancestor) |index| {
|
|
275
|
+
if (index >= nodes.len) break;
|
|
276
|
+
const scroll_node = nodes[index];
|
|
277
|
+
if (scroll_node.widget.kind == .scroll_view and
|
|
278
|
+
canvas.widgetScrollsAxis(scroll_node.widget, .horizontal) and
|
|
279
|
+
!scroll_node.widget.layout.virtualized)
|
|
280
|
+
{
|
|
281
|
+
const viewport = scroll_node.frame.inset(scroll_node.widget.layout.padding).normalized();
|
|
282
|
+
const tab_frame = nodes[tab_index].frame.normalized();
|
|
283
|
+
if (viewport.isEmpty() or tab_frame.isEmpty()) break;
|
|
284
|
+
|
|
285
|
+
const delta = if (tab_frame.x < viewport.x)
|
|
286
|
+
tab_frame.x - viewport.x
|
|
287
|
+
else if (tab_frame.maxX() > viewport.maxX())
|
|
288
|
+
tab_frame.maxX() - viewport.maxX()
|
|
289
|
+
else
|
|
290
|
+
0;
|
|
291
|
+
if (delta == 0) break;
|
|
292
|
+
const current = scroll_node.widget.value_x;
|
|
293
|
+
const next = @max(0, current + delta);
|
|
294
|
+
if (next == current) break;
|
|
295
|
+
nodes[index].widget.value_x = next;
|
|
296
|
+
translateCanvasWidgetLayoutScrollDescendants(nodes, index, .{ .dx = -(next - current) });
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
ancestor = scroll_node.parent_index;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
251
304
|
pub const CanvasWidgetSourceTextEntry = struct {
|
|
252
305
|
id: canvas.ObjectId = 0,
|
|
253
306
|
kind: canvas.WidgetKind = .text_field,
|
|
@@ -601,6 +654,7 @@ pub fn collectCanvasWidgetTextReconcileEntries(
|
|
|
601
654
|
CanvasWidgetSourceTextFingerprint{ .len = entry.text_len, .hash = entry.text_hash }
|
|
602
655
|
else
|
|
603
656
|
canvasWidgetSourceTextFingerprint(node.widget.text);
|
|
657
|
+
const has_code_diff = node.widget.hasCodeDiff();
|
|
604
658
|
output[len] = .{
|
|
605
659
|
.id = node.widget.id,
|
|
606
660
|
.kind = node.widget.kind,
|
|
@@ -612,6 +666,11 @@ pub fn collectCanvasWidgetTextReconcileEntries(
|
|
|
612
666
|
.text_selection = node.widget.text_selection,
|
|
613
667
|
.text_composition = node.widget.text_composition,
|
|
614
668
|
.value = node.widget.value,
|
|
669
|
+
.value_x = node.widget.value_x,
|
|
670
|
+
.code_content_width = if (!has_code_diff) node.widget.code_content_width else 0,
|
|
671
|
+
.code_content_width_generation = if (!has_code_diff) node.widget.code_content_width_generation else 0,
|
|
672
|
+
.code_content_width_font_id = if (!has_code_diff) node.widget.code_content_width_font_id else 0,
|
|
673
|
+
.code_content_width_size_bits = if (!has_code_diff) node.widget.code_content_width_size_bits else 0,
|
|
615
674
|
};
|
|
616
675
|
len += 1;
|
|
617
676
|
}
|
|
@@ -819,6 +878,15 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
819
878
|
// right after, so a resized or re-texted field never keeps a
|
|
820
879
|
// stale offset).
|
|
821
880
|
if (canvasWidgetEditableTextKind(copy.widget.kind)) copy.widget.value = entry.value;
|
|
881
|
+
if (copy.widget.code_editor) {
|
|
882
|
+
copy.widget.value_x = entry.value_x;
|
|
883
|
+
if (!copy.widget.hasCodeDiff()) {
|
|
884
|
+
copy.widget.code_content_width = entry.code_content_width;
|
|
885
|
+
copy.widget.code_content_width_generation = entry.code_content_width_generation;
|
|
886
|
+
copy.widget.code_content_width_font_id = entry.code_content_width_font_id;
|
|
887
|
+
copy.widget.code_content_width_size_bits = entry.code_content_width_size_bits;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
822
890
|
if (copy.widget.text_selection == null and copy.widget.text_composition == null) {
|
|
823
891
|
copy.widget.text_selection = entry.text_selection;
|
|
824
892
|
copy.widget.text_composition = entry.text_composition;
|
|
@@ -968,6 +1036,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
|
|
|
968
1036
|
// the caller AFTER native scroll drivers are stamped — a rebuild
|
|
969
1037
|
// mid-rubber-band must not clamp an offset the OS scroller owns.
|
|
970
1038
|
restoreCanvasWidgetLayoutScrollOffsets(staged_nodes, previous_runtime_offsets, previous_source_scroll_entries);
|
|
1039
|
+
revealNewlySelectedTabs(previous, staged_nodes);
|
|
971
1040
|
|
|
972
1041
|
const index_scratch = canvas_widget_reconcile_index_scratch.get();
|
|
973
1042
|
index_scratch.controls.build(previous_control_states);
|
|
@@ -1102,7 +1171,12 @@ pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, st
|
|
|
1102
1171
|
pub fn clampCanvasWidgetLayoutTextOffsets(nodes: []canvas.WidgetLayoutNode, tokens: canvas.DesignTokens) void {
|
|
1103
1172
|
for (nodes) |*node| {
|
|
1104
1173
|
if (node.widget.kind == .textarea) {
|
|
1174
|
+
canvas.cacheTextInputContentWidthForWidget(&node.widget, tokens);
|
|
1105
1175
|
node.widget.value = canvas.clampedTextInputScrollOffsetForWidget(node.widget, tokens, node.widget.value);
|
|
1176
|
+
node.widget.value_x = if (node.widget.code_editor)
|
|
1177
|
+
canvas.clampedTextInputHorizontalScrollOffsetForWidget(node.widget, tokens, node.widget.value_x)
|
|
1178
|
+
else
|
|
1179
|
+
0;
|
|
1106
1180
|
continue;
|
|
1107
1181
|
}
|
|
1108
1182
|
if (!canvasWidgetSingleLineTextKind(node.widget.kind)) continue;
|
|
@@ -1499,8 +1573,10 @@ fn canvasWidgetTreeRowFocusTarget(layout: canvas.WidgetLayoutTree, node_index: u
|
|
|
1499
1573
|
/// the focused row is a leaf or collapsed (an expanded row collapses
|
|
1500
1574
|
/// instead — no focus move, the routed toggle intent handles it); Right
|
|
1501
1575
|
/// moves to the FIRST CHILD row when the focused row is expanded (a
|
|
1502
|
-
/// collapsed row expands instead).
|
|
1503
|
-
///
|
|
1576
|
+
/// collapsed row expands instead). Flat sibling rows may declare a
|
|
1577
|
+
/// one-based `tree_level`; otherwise parent/child relationships derive
|
|
1578
|
+
/// from widget nesting. Null = no tree move (the caller falls through to
|
|
1579
|
+
/// group/spatial focus).
|
|
1504
1580
|
pub fn canvasWidgetTreeDirectionalFocusTarget(
|
|
1505
1581
|
layout: canvas.WidgetLayoutTree,
|
|
1506
1582
|
focused: canvas.WidgetFocusTarget,
|
|
@@ -1520,7 +1596,7 @@ pub fn canvasWidgetTreeDirectionalFocusTarget(
|
|
|
1520
1596
|
.right => blk: {
|
|
1521
1597
|
const expanded = layout.nodes[focused.index].widget.state.expanded orelse false;
|
|
1522
1598
|
if (!expanded) break :blk null; // expand intent (or leaf no-op)
|
|
1523
|
-
break :blk canvasWidgetTreeFirstChildRow(layout, focused.index) orelse focused;
|
|
1599
|
+
break :blk canvasWidgetTreeFirstChildRow(layout, tree_index, focused.index) orelse focused;
|
|
1524
1600
|
},
|
|
1525
1601
|
.forward, .backward => null,
|
|
1526
1602
|
};
|
|
@@ -1578,6 +1654,20 @@ fn canvasWidgetTreeAdjacentRow(
|
|
|
1578
1654
|
}
|
|
1579
1655
|
|
|
1580
1656
|
fn canvasWidgetTreeParentRow(layout: canvas.WidgetLayoutTree, tree_index: usize, focused_index: usize) ?canvas.WidgetFocusTarget {
|
|
1657
|
+
const focused_level = layout.nodes[focused_index].widget.tree_level;
|
|
1658
|
+
if (focused_level > 1) {
|
|
1659
|
+
var index = focused_index;
|
|
1660
|
+
while (index > tree_index + 1) {
|
|
1661
|
+
index -= 1;
|
|
1662
|
+
const widget = layout.nodes[index].widget;
|
|
1663
|
+
if (widget.semantics.role != .treeitem) continue;
|
|
1664
|
+
if (widget.tree_level == focused_level - 1) {
|
|
1665
|
+
return canvasWidgetTreeRowFocusTarget(layout, index);
|
|
1666
|
+
}
|
|
1667
|
+
if (widget.tree_level != 0 and widget.tree_level < focused_level - 1) return null;
|
|
1668
|
+
}
|
|
1669
|
+
return null;
|
|
1670
|
+
}
|
|
1581
1671
|
var current = layout.nodes[focused_index].parent_index;
|
|
1582
1672
|
while (current) |index| {
|
|
1583
1673
|
if (index >= layout.nodes.len or index == tree_index) return null;
|
|
@@ -1587,7 +1677,21 @@ fn canvasWidgetTreeParentRow(layout: canvas.WidgetLayoutTree, tree_index: usize,
|
|
|
1587
1677
|
return null;
|
|
1588
1678
|
}
|
|
1589
1679
|
|
|
1590
|
-
fn canvasWidgetTreeFirstChildRow(layout: canvas.WidgetLayoutTree, focused_index: usize) ?canvas.WidgetFocusTarget {
|
|
1680
|
+
fn canvasWidgetTreeFirstChildRow(layout: canvas.WidgetLayoutTree, tree_index: usize, focused_index: usize) ?canvas.WidgetFocusTarget {
|
|
1681
|
+
const focused_level = layout.nodes[focused_index].widget.tree_level;
|
|
1682
|
+
if (focused_level > 0) {
|
|
1683
|
+
const tree_depth = layout.nodes[tree_index].depth;
|
|
1684
|
+
var index = focused_index + 1;
|
|
1685
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > tree_depth) : (index += 1) {
|
|
1686
|
+
const widget = layout.nodes[index].widget;
|
|
1687
|
+
if (widget.semantics.role != .treeitem) continue;
|
|
1688
|
+
if (@as(u32, widget.tree_level) == @as(u32, focused_level) + 1) {
|
|
1689
|
+
return canvasWidgetTreeRowFocusTarget(layout, index);
|
|
1690
|
+
}
|
|
1691
|
+
return null;
|
|
1692
|
+
}
|
|
1693
|
+
return null;
|
|
1694
|
+
}
|
|
1591
1695
|
const row_depth = layout.nodes[focused_index].depth;
|
|
1592
1696
|
var index = focused_index + 1;
|
|
1593
1697
|
while (index < layout.nodes.len and layout.nodes[index].depth > row_depth) : (index += 1) {
|
|
@@ -37,6 +37,21 @@ fn scrollFixtureLayout(nodes: []canvas.WidgetLayoutNode, offset: f32) !canvas.Wi
|
|
|
37
37
|
return canvas.layoutWidgetTree(scroll, geometry.RectF.init(0, 0, 180, 72), nodes);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
fn horizontalTabFixtureLayout(nodes: []canvas.WidgetLayoutNode, selected_id: canvas.ObjectId) !canvas.WidgetLayoutTree {
|
|
41
|
+
const tabs = [_]canvas.Widget{
|
|
42
|
+
.{ .id = 2, .kind = .stack, .frame = geometry.RectF.init(0, 0, 180, 37), .state = .{ .selected = selected_id == 2 }, .semantics = .{ .role = .tab, .label = "One" } },
|
|
43
|
+
.{ .id = 3, .kind = .stack, .frame = geometry.RectF.init(180, 0, 180, 37), .state = .{ .selected = selected_id == 3 }, .semantics = .{ .role = .tab, .label = "Two" } },
|
|
44
|
+
.{ .id = 4, .kind = .stack, .frame = geometry.RectF.init(360, 0, 180, 37), .state = .{ .selected = selected_id == 4 }, .semantics = .{ .role = .tab, .label = "Three" } },
|
|
45
|
+
};
|
|
46
|
+
const strip = canvas.Widget{
|
|
47
|
+
.id = 1,
|
|
48
|
+
.kind = .scroll_view,
|
|
49
|
+
.scroll_axes = .horizontal,
|
|
50
|
+
.children = &tabs,
|
|
51
|
+
};
|
|
52
|
+
return canvas.layoutWidgetTree(strip, geometry.RectF.init(0, 0, 360, 37), nodes);
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
test "layout install publishes native scroll drivers and suppresses engine scrollbars" {
|
|
41
56
|
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
42
57
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -645,6 +660,50 @@ test "a two-axis region's driver carries both content dimensions and follows off
|
|
|
645
660
|
try std.testing.expectEqualDeep(geometry.RectF.init(-60, -30, 140, 120), retained.findById(2).?.frame);
|
|
646
661
|
}
|
|
647
662
|
|
|
663
|
+
test "activating a tab minimally reveals it without shifting an already visible tab" {
|
|
664
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
665
|
+
defer harness.destroy(std.testing.allocator);
|
|
666
|
+
harness.null_platform.gpu_surfaces = true;
|
|
667
|
+
harness.null_platform.gpu_surface_scroll_drivers = true;
|
|
668
|
+
var app_state: PassiveApp = .{};
|
|
669
|
+
const app = app_state.app();
|
|
670
|
+
try harness.start(app);
|
|
671
|
+
|
|
672
|
+
_ = try harness.runtime.createView(.{
|
|
673
|
+
.window_id = 1,
|
|
674
|
+
.label = "canvas",
|
|
675
|
+
.kind = .gpu_surface,
|
|
676
|
+
.frame = geometry.RectF.init(10, 20, 360, 37),
|
|
677
|
+
});
|
|
678
|
+
var initial_nodes: [4]canvas.WidgetLayoutNode = undefined;
|
|
679
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", try horizontalTabFixtureLayout(&initial_nodes, 2));
|
|
680
|
+
|
|
681
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_scroll_driver = .{
|
|
682
|
+
.window_id = 1,
|
|
683
|
+
.label = "canvas",
|
|
684
|
+
.driver_id = 1,
|
|
685
|
+
.offset_x = 60,
|
|
686
|
+
.timestamp_ns = 1_000_000_000,
|
|
687
|
+
} });
|
|
688
|
+
|
|
689
|
+
// Tab Two occupies content x=180..360, already wholly inside the
|
|
690
|
+
// standing 60..420 viewport. Activating it preserves the offset exactly.
|
|
691
|
+
var visible_nodes: [4]canvas.WidgetLayoutNode = undefined;
|
|
692
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", try horizontalTabFixtureLayout(&visible_nodes, 3));
|
|
693
|
+
var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
694
|
+
try std.testing.expectEqual(@as(f32, 60), retained.findById(1).?.widget.value_x);
|
|
695
|
+
try std.testing.expectEqualDeep(geometry.RectF.init(120, 0, 180, 37), retained.findById(3).?.frame);
|
|
696
|
+
|
|
697
|
+
// Tab Three ends at x=540, 120 points past that viewport. The reveal
|
|
698
|
+
// moves by only those 120 points instead of snapping it to the leading edge.
|
|
699
|
+
var hidden_nodes: [4]canvas.WidgetLayoutNode = undefined;
|
|
700
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", try horizontalTabFixtureLayout(&hidden_nodes, 4));
|
|
701
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
702
|
+
try std.testing.expectEqual(@as(f32, 180), retained.findById(1).?.widget.value_x);
|
|
703
|
+
try std.testing.expectEqualDeep(geometry.RectF.init(180, 0, 180, 37), retained.findById(4).?.frame);
|
|
704
|
+
try std.testing.expectEqual(@as(f32, 180), harness.null_platform.scrollDrivers()[0].offset_x);
|
|
705
|
+
}
|
|
706
|
+
|
|
648
707
|
test "a horizontal-only region's driver pins its vertical range" {
|
|
649
708
|
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
650
709
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -13,6 +13,7 @@ const App = support.App;
|
|
|
13
13
|
const Runtime = support.Runtime;
|
|
14
14
|
const Event = support.Event;
|
|
15
15
|
const TestHarness = support.TestHarness;
|
|
16
|
+
const canvas_widget_runtime = @import("canvas_widget_runtime.zig");
|
|
16
17
|
|
|
17
18
|
const TestMsg = union(enum) {
|
|
18
19
|
resized: f32,
|
|
@@ -371,6 +372,105 @@ test "tree keymap walks visible rows, collapses, expands, and selects through re
|
|
|
371
372
|
try std.testing.expect(!after_enter.findById(12).?.widget.state.selected);
|
|
372
373
|
}
|
|
373
374
|
|
|
375
|
+
test "flat tree levels resolve logical parents and children" {
|
|
376
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
377
|
+
defer harness.destroy(std.testing.allocator);
|
|
378
|
+
harness.null_platform.gpu_surfaces = true;
|
|
379
|
+
var app_state: ObservingApp = .{};
|
|
380
|
+
const app = app_state.app();
|
|
381
|
+
try harness.start(app);
|
|
382
|
+
|
|
383
|
+
_ = try harness.runtime.createView(.{
|
|
384
|
+
.window_id = 1,
|
|
385
|
+
.label = "canvas",
|
|
386
|
+
.kind = .gpu_surface,
|
|
387
|
+
.frame = geometry.RectF.init(0, 0, 240, 160),
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// The rows are layout siblings (the natural output of a declarative
|
|
391
|
+
// `for`), but their one-based levels describe the logical tree:
|
|
392
|
+
// src (expanded)
|
|
393
|
+
// └─ main.zig
|
|
394
|
+
// README.md
|
|
395
|
+
const rows = [_]canvas.Widget{
|
|
396
|
+
blk: {
|
|
397
|
+
var row = treeRowPanel(21, 0, 24, true, &.{});
|
|
398
|
+
row.tree_level = 1;
|
|
399
|
+
break :blk row;
|
|
400
|
+
},
|
|
401
|
+
blk: {
|
|
402
|
+
var row = treeRowPanel(22, 30, 24, null, &.{});
|
|
403
|
+
row.tree_level = 2;
|
|
404
|
+
break :blk row;
|
|
405
|
+
},
|
|
406
|
+
blk: {
|
|
407
|
+
var row = treeRowPanel(23, 60, 24, null, &.{});
|
|
408
|
+
row.tree_level = 1;
|
|
409
|
+
break :blk row;
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
var nodes: [6]canvas.WidgetLayoutNode = undefined;
|
|
413
|
+
const layout = try canvas.layoutWidgetTree(.{ .id = 20, .kind = .tree, .children = &rows }, geometry.RectF.init(0, 0, 240, 160), &nodes);
|
|
414
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
415
|
+
const view = &harness.runtime.views[0];
|
|
416
|
+
|
|
417
|
+
// Focus the flat child row, then use the standard tree moves. Left
|
|
418
|
+
// reaches its logical parent; Right on that expanded parent reaches
|
|
419
|
+
// the first logical child even though neither is a widget ancestor.
|
|
420
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_down, .x = 10, .y = 35, .button = 0 } });
|
|
421
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_up, .x = 10, .y = 35, .button = 0 } });
|
|
422
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 22), view.canvas_widget_focused_id);
|
|
423
|
+
|
|
424
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowleft" } });
|
|
425
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 21), view.canvas_widget_focused_id);
|
|
426
|
+
try std.testing.expect(app_state.last_keyboard_focus_moved);
|
|
427
|
+
|
|
428
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowright" } });
|
|
429
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 22), view.canvas_widget_focused_id);
|
|
430
|
+
try std.testing.expect(app_state.last_keyboard_focus_moved);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
test "flat tree child lookup stays inside its tree scope" {
|
|
434
|
+
var first_row = treeRowPanel(31, 0, 24, true, &.{});
|
|
435
|
+
first_row.tree_level = 1;
|
|
436
|
+
var second_row = treeRowPanel(41, 0, 24, null, &.{});
|
|
437
|
+
second_row.tree_level = 2;
|
|
438
|
+
const first_rows = [_]canvas.Widget{first_row};
|
|
439
|
+
const second_rows = [_]canvas.Widget{second_row};
|
|
440
|
+
const trees = [_]canvas.Widget{
|
|
441
|
+
.{ .id = 30, .kind = .tree, .children = &first_rows },
|
|
442
|
+
.{ .id = 40, .kind = .tree, .children = &second_rows },
|
|
443
|
+
};
|
|
444
|
+
var nodes: [5]canvas.WidgetLayoutNode = undefined;
|
|
445
|
+
const layout = try canvas.layoutWidgetTree(
|
|
446
|
+
.{ .id = 29, .kind = .stack, .children = &trees },
|
|
447
|
+
geometry.RectF.init(0, 0, 240, 100),
|
|
448
|
+
&nodes,
|
|
449
|
+
);
|
|
450
|
+
const focused = layout.focusTargetById(31).?;
|
|
451
|
+
|
|
452
|
+
const target = canvas_widget_runtime.canvasWidgetTreeDirectionalFocusTarget(layout, focused, .right).?;
|
|
453
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 31), target.id);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
test "flat tree child lookup handles the maximum logical level" {
|
|
457
|
+
var first_row = treeRowPanel(51, 0, 24, true, &.{});
|
|
458
|
+
first_row.tree_level = std.math.maxInt(u16);
|
|
459
|
+
var second_row = treeRowPanel(52, 30, 24, null, &.{});
|
|
460
|
+
second_row.tree_level = std.math.maxInt(u16);
|
|
461
|
+
const rows = [_]canvas.Widget{ first_row, second_row };
|
|
462
|
+
var nodes: [4]canvas.WidgetLayoutNode = undefined;
|
|
463
|
+
const layout = try canvas.layoutWidgetTree(
|
|
464
|
+
.{ .id = 50, .kind = .tree, .children = &rows },
|
|
465
|
+
geometry.RectF.init(0, 0, 240, 100),
|
|
466
|
+
&nodes,
|
|
467
|
+
);
|
|
468
|
+
const focused = layout.focusTargetById(51).?;
|
|
469
|
+
|
|
470
|
+
const target = canvas_widget_runtime.canvasWidgetTreeDirectionalFocusTarget(layout, focused, .right).?;
|
|
471
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 51), target.id);
|
|
472
|
+
}
|
|
473
|
+
|
|
374
474
|
test "a virtual list declaring the tree role scopes the tree keymap over its rows" {
|
|
375
475
|
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
376
476
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -28,6 +28,27 @@ const canvasWidgetAccessibilityActionSupported = widget_bridge.canvasWidgetAcces
|
|
|
28
28
|
const platformWidgetAccessibilityActionKindFromCanvas = widget_bridge.platformWidgetAccessibilityActionKindFromCanvas;
|
|
29
29
|
const canvasWidgetBooleanSelected = canvas_widget_runtime.canvasWidgetBooleanSelected;
|
|
30
30
|
|
|
31
|
+
fn canvasWidgetLayoutNeedsLargeTextStorage(layout: canvas.WidgetLayoutTree) bool {
|
|
32
|
+
var text_len: usize = 0;
|
|
33
|
+
for (layout.nodes) |node| {
|
|
34
|
+
const widget = node.widget;
|
|
35
|
+
if (widget.code_editor) return true;
|
|
36
|
+
text_len +|= widget.text.len +| widget.icon.len +| widget.command.len +| widget.semantics.label.len;
|
|
37
|
+
for (widget.spans) |span| text_len +|= span.text.len +| span.link.len;
|
|
38
|
+
for (widget.context_menu) |item| text_len +|= item.label.len;
|
|
39
|
+
for (widget.chart.series) |series| text_len +|= series.label.len;
|
|
40
|
+
for (widget.chart.x_labels) |label| text_len +|= label.len;
|
|
41
|
+
if (text_len > canvas_limits.max_canvas_widget_inline_text_bytes_per_view) return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fn ensureCanvasWidgetLargeTextStorageThrough(runtime: anytype, index: usize) !void {
|
|
47
|
+
for (runtime.views[0 .. index + 1]) |*view| {
|
|
48
|
+
try view.ensureLargeCanvasWidgetTextStorage(runtime.owned_allocator);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
32
53
|
return struct {
|
|
33
54
|
pub fn setCanvasWidgetLayout(self: *Runtime, window_id: platform.WindowId, label: []const u8, layout: canvas.WidgetLayoutTree) anyerror!platform.ViewInfo {
|
|
@@ -85,6 +106,9 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
85
106
|
armed_tween_ids[0..armed_tween_count],
|
|
86
107
|
canvasWidgetPressedSplitId(self, index),
|
|
87
108
|
);
|
|
109
|
+
if (canvasWidgetLayoutNeedsLargeTextStorage(reconciled_layout)) {
|
|
110
|
+
try ensureCanvasWidgetLargeTextStorageThrough(self, index);
|
|
111
|
+
}
|
|
88
112
|
// Native scroll drivers: mark natively driven scroll
|
|
89
113
|
// regions before the copy so rebuild-time clamping and display
|
|
90
114
|
// emission both see the flag (engine scrollbar + engine clamp
|
|
@@ -831,6 +855,9 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
831
855
|
// field's editor never accepts a line break, whoever writes.
|
|
832
856
|
const node = self.views[index].widgetLayoutTree().findById(id) orelse return error.InvalidCommand;
|
|
833
857
|
const sanitized = canvas.sanitizedSingleLineTextInputEvent(node.widget.kind, edit) orelse return self.views[index].info();
|
|
858
|
+
if (self.views[index].canvasWidgetTextEditNeedsLargeStorage(id, sanitized)) {
|
|
859
|
+
try ensureCanvasWidgetLargeTextStorageThrough(self, index);
|
|
860
|
+
}
|
|
834
861
|
const dirty = try self.views[index].applyCanvasWidgetTextEdit(id, sanitized) orelse return self.views[index].info();
|
|
835
862
|
try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, index, dirty);
|
|
836
863
|
_ = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
|