@native-sdk/cli 0.5.3 → 0.6.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 +91 -2
- package/build.zig +756 -5
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +19 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +416 -9
- package/packages/core/sdk/core.ts +706 -5
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +3187 -264
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +42 -4
- package/skill-data/ts-core/SKILL.md +13 -3
- package/src/app_runner/root.zig +112 -10
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/tests.zig +119 -1
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +639 -16
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +351 -7
- package/src/platform/macos/appkit_host.h +152 -8
- package/src/platform/macos/appkit_host.m +1816 -100
- package/src/platform/macos/cef_host.mm +372 -11
- package/src/platform/macos/root.zig +379 -11
- package/src/platform/null_platform.zig +696 -9
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +42 -0
- package/src/platform/types.zig +524 -18
- package/src/platform/windows/root.zig +432 -9
- package/src/platform/windows/webview2_host.cpp +482 -45
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +535 -12
- package/src/primitives/canvas/ui_markup.zig +253 -36
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
- package/src/primitives/canvas/ui_markup_contract.zig +89 -6
- package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +178 -9
- package/src/primitives/canvas/ui_markup_view.zig +220 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
- package/src/primitives/canvas/ui_schema.zig +110 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -10
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +23 -0
- package/src/runtime/api.zig +76 -5
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +8 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +240 -24
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +131 -13
- package/src/runtime/effects.zig +8136 -180
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +167 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +42 -4
- package/src/runtime/gpu_surface_events.zig +473 -13
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +36 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +432 -62
- package/src/runtime/session_record.zig +43 -2
- package/src/runtime/session_replay.zig +556 -20
- package/src/runtime/session_tests.zig +2087 -1
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +8 -0
- package/src/runtime/ts_core_host.zig +1320 -45
- package/src/runtime/ts_core_host_tests.zig +1100 -1
- package/src/runtime/ts_ui_app.zig +23 -5
- package/src/runtime/ui_app.zig +2444 -69
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +736 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +77 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +62 -1
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +244 -8
|
@@ -23,6 +23,12 @@ fn canvasWidgetModelDrivenVirtual(widget: canvas.Widget) bool {
|
|
|
23
23
|
return widget.layout.virtualized and !canvas.widgetVirtualRuntimeScrolled(widget);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
fn unionOptionalRects(a: ?geometry.RectF, b: ?geometry.RectF) ?geometry.RectF {
|
|
27
|
+
const first = a orelse return b;
|
|
28
|
+
const second = b orelse return first;
|
|
29
|
+
return unionRects(first, second);
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
27
33
|
return struct {
|
|
28
34
|
pub fn canvasWidgetKineticScrollActive(self: *const RuntimeView) bool {
|
|
@@ -33,31 +39,59 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
33
39
|
const viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
34
40
|
if (viewport.isEmpty()) continue;
|
|
35
41
|
const physics = canvas.widgetScrollPhysics(node.widget, self.widget_tokens.scroll);
|
|
36
|
-
|
|
42
|
+
const state = self.canvasWidgetScrollState(index, node, viewport);
|
|
43
|
+
if (canvas.widgetScrollsAxis(node.widget, .vertical) and state.axis(.vertical).needsKineticStep(physics)) return true;
|
|
44
|
+
if (canvas.widgetScrollsAxis(node.widget, .horizontal) and state.axis(.horizontal).needsKineticStep(physics)) return true;
|
|
37
45
|
}
|
|
38
46
|
return false;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
/// Route a wheel/trackpad scroll: EACH AXIS resolves
|
|
50
|
+
/// independently to the nearest ancestor scrollable on that
|
|
51
|
+
/// axis. A horizontal timeline holding a vertical list splits a
|
|
52
|
+
/// diagonal gesture — `dy` scrolls the list, `dx` reaches the
|
|
53
|
+
/// timeline — and a vertical-only tree behaves byte-identically
|
|
54
|
+
/// to the one-axis routing this generalizes (every scrollable
|
|
55
|
+
/// there grants the vertical axis and nothing grants the
|
|
56
|
+
/// horizontal one). Both axes route even at delta 0: a wheel
|
|
57
|
+
/// event has always overwritten the landing region's velocity,
|
|
58
|
+
/// so a purely horizontal gesture stills a vertical flick the
|
|
59
|
+
/// same way a zero-delta vertical wheel did.
|
|
60
|
+
pub fn applyCanvasWidgetScrollRoute(self: *RuntimeView, route: []const canvas.WidgetEventRouteEntry, delta: geometry.OffsetF, source: CanvasWidgetScrollSource) anyerror!?geometry.RectF {
|
|
61
|
+
const vertical = try applyCanvasWidgetScrollAxisRoute(self, route, .vertical, delta.dy, source);
|
|
62
|
+
const horizontal = try applyCanvasWidgetScrollAxisRoute(self, route, .horizontal, delta.dx, source);
|
|
63
|
+
return unionOptionalRects(vertical, horizontal);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fn applyCanvasWidgetScrollAxisRoute(self: *RuntimeView, route: []const canvas.WidgetEventRouteEntry, comptime axis: canvas.ScrollAxis, delta: f32, source: CanvasWidgetScrollSource) anyerror!?geometry.RectF {
|
|
42
67
|
var depth_limit: ?usize = null;
|
|
43
|
-
while (self.
|
|
68
|
+
while (self.deepestCanvasWidgetScrollIndexForAxis(route, axis, depth_limit)) |scroll_index| {
|
|
44
69
|
if (canvasWidgetModelDrivenVirtual(self.widget_layout_nodes[scroll_index].widget)) return null;
|
|
45
|
-
const has_scroll_parent = self.
|
|
46
|
-
if (has_scroll_parent and !self.
|
|
70
|
+
const has_scroll_parent = self.deepestCanvasWidgetScrollIndexForAxis(route, axis, self.widget_layout_nodes[scroll_index].depth) != null;
|
|
71
|
+
if (has_scroll_parent and !self.canvasWidgetScrollCanConsumeAxis(scroll_index, axis, delta)) {
|
|
47
72
|
depth_limit = self.widget_layout_nodes[scroll_index].depth;
|
|
48
73
|
continue;
|
|
49
74
|
}
|
|
50
|
-
if (try self.
|
|
75
|
+
if (try self.applyCanvasWidgetScrollAxis(scroll_index, axis, delta, source, !has_scroll_parent)) |dirty| return dirty;
|
|
51
76
|
depth_limit = self.widget_layout_nodes[scroll_index].depth;
|
|
52
77
|
}
|
|
53
78
|
return null;
|
|
54
79
|
}
|
|
55
80
|
|
|
56
81
|
pub fn deepestCanvasWidgetScrollIndex(self: *const RuntimeView, route: []const canvas.WidgetEventRouteEntry, depth_limit: ?usize) ?usize {
|
|
82
|
+
return self.deepestCanvasWidgetScrollIndexForAxis(route, .vertical, depth_limit);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// The deepest routed widget that scrolls on `axis`. The axis
|
|
86
|
+
/// filter is what makes per-axis routing independent: a
|
|
87
|
+
/// vertical-only list is invisible to the horizontal walk, so
|
|
88
|
+
/// `dx` passes through it to the horizontal ancestor.
|
|
89
|
+
pub fn deepestCanvasWidgetScrollIndexForAxis(self: *const RuntimeView, route: []const canvas.WidgetEventRouteEntry, comptime axis: canvas.ScrollAxis, depth_limit: ?usize) ?usize {
|
|
57
90
|
var result: ?usize = null;
|
|
58
91
|
var result_depth: usize = 0;
|
|
59
92
|
for (route) |entry| {
|
|
60
93
|
if (!canvasWidgetScrollableKind(entry.kind) or entry.node_index >= self.widget_layout_node_count) continue;
|
|
94
|
+
if (!canvas.widgetScrollsAxis(self.widget_layout_nodes[entry.node_index].widget, axis)) continue;
|
|
61
95
|
const depth = self.widget_layout_nodes[entry.node_index].depth;
|
|
62
96
|
if (depth_limit) |limit| {
|
|
63
97
|
if (depth >= limit) continue;
|
|
@@ -100,50 +134,74 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
100
134
|
return null;
|
|
101
135
|
}
|
|
102
136
|
|
|
137
|
+
/// The region's two-axis scroll state. An axis the region does
|
|
138
|
+
/// not grant is QUIET: offset and velocity 0 and the content
|
|
139
|
+
/// extent pinned to the viewport, so `on_scroll` consumers and
|
|
140
|
+
/// the routing/consume checks read `maxOffset() == 0` — never a
|
|
141
|
+
/// falsely scrollable inactive axis (a vertical list whose rows
|
|
142
|
+
/// happen to overhang sideways stays horizontally inert).
|
|
103
143
|
pub fn canvasWidgetScrollState(self: *const RuntimeView, scroll_index: usize, scroll_node: canvas.WidgetLayoutNode, viewport: geometry.RectF) canvas.ScrollState {
|
|
104
144
|
const retained = self.widget_scroll_states[scroll_index];
|
|
145
|
+
const vertical = canvas.widgetScrollsAxis(scroll_node.widget, .vertical);
|
|
146
|
+
const horizontal = canvas.widgetScrollsAxis(scroll_node.widget, .horizontal);
|
|
105
147
|
return .{
|
|
106
|
-
.
|
|
107
|
-
.
|
|
108
|
-
.
|
|
109
|
-
.
|
|
148
|
+
.offset_y = if (vertical) scroll_node.widget.value else 0,
|
|
149
|
+
.offset_x = if (horizontal) scroll_node.widget.value_x else 0,
|
|
150
|
+
.velocity_y = if (vertical) retained.velocity_y else 0,
|
|
151
|
+
.velocity_x = if (horizontal) retained.velocity_x else 0,
|
|
152
|
+
.viewport_extent_y = viewport.height,
|
|
153
|
+
.viewport_extent_x = viewport.width,
|
|
154
|
+
.content_extent_y = if (vertical) self.canvasWidgetScrollContentExtent(scroll_index, viewport) else viewport.height,
|
|
155
|
+
.content_extent_x = if (horizontal) self.canvasWidgetScrollContentExtentX(scroll_index, viewport) else viewport.width,
|
|
110
156
|
};
|
|
111
157
|
}
|
|
112
158
|
|
|
113
|
-
pub fn
|
|
114
|
-
if (scroll_index >= self.widget_layout_node_count or
|
|
159
|
+
pub fn canvasWidgetScrollCanConsumeAxis(self: *const RuntimeView, scroll_index: usize, comptime axis: canvas.ScrollAxis, delta: f32) bool {
|
|
160
|
+
if (scroll_index >= self.widget_layout_node_count or delta == 0) return false;
|
|
115
161
|
const scroll_node = self.widget_layout_nodes[scroll_index];
|
|
116
162
|
if (!canvasWidgetScrollableKind(scroll_node.widget.kind)) return false;
|
|
117
163
|
if (canvasWidgetModelDrivenVirtual(scroll_node.widget)) return false;
|
|
164
|
+
if (!canvas.widgetScrollsAxis(scroll_node.widget, axis)) return false;
|
|
118
165
|
|
|
119
166
|
if (scroll_node.widget.kind == .textarea) {
|
|
120
167
|
const max_offset = canvas.textInputMaxScrollOffsetForWidget(scroll_node.widget, self.widget_tokens);
|
|
121
168
|
if (max_offset <= 0) return false;
|
|
122
169
|
const current_offset = std.math.clamp(scroll_node.widget.value, 0, max_offset);
|
|
123
|
-
return if (
|
|
170
|
+
return if (delta > 0) current_offset < max_offset else current_offset > 0;
|
|
124
171
|
}
|
|
125
172
|
|
|
126
173
|
const viewport = scroll_node.frame.inset(scroll_node.widget.layout.padding).normalized();
|
|
127
174
|
if (viewport.isEmpty()) return false;
|
|
128
175
|
|
|
129
|
-
const current = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport);
|
|
176
|
+
const current = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport).axis(axis);
|
|
130
177
|
const max_offset = current.maxOffset();
|
|
131
|
-
if (current.offset < 0) return
|
|
132
|
-
if (current.offset > max_offset) return
|
|
133
|
-
return if (
|
|
178
|
+
if (current.offset < 0) return delta > 0;
|
|
179
|
+
if (current.offset > max_offset) return delta < 0;
|
|
180
|
+
return if (delta > 0) current.offset < max_offset else current.offset > 0;
|
|
134
181
|
}
|
|
135
182
|
|
|
136
|
-
pub fn applyCanvasWidgetScroll(self: *RuntimeView, scroll_index: usize,
|
|
183
|
+
pub fn applyCanvasWidgetScroll(self: *RuntimeView, scroll_index: usize, delta: geometry.OffsetF, source: CanvasWidgetScrollSource, allow_rubberband: bool) anyerror!?geometry.RectF {
|
|
184
|
+
const vertical = try self.applyCanvasWidgetScrollAxis(scroll_index, .vertical, delta.dy, source, allow_rubberband);
|
|
185
|
+
const horizontal = try self.applyCanvasWidgetScrollAxis(scroll_index, .horizontal, delta.dx, source, allow_rubberband);
|
|
186
|
+
return unionOptionalRects(vertical, horizontal);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
pub fn applyCanvasWidgetScrollAxis(self: *RuntimeView, scroll_index: usize, comptime axis: canvas.ScrollAxis, delta: f32, source: CanvasWidgetScrollSource, allow_rubberband: bool) anyerror!?geometry.RectF {
|
|
137
190
|
if (scroll_index >= self.widget_layout_node_count) return null;
|
|
138
191
|
const scroll_node = self.widget_layout_nodes[scroll_index];
|
|
139
192
|
if (!canvasWidgetScrollableKind(scroll_node.widget.kind)) return null;
|
|
140
|
-
if (scroll_node.widget.kind == .textarea)
|
|
193
|
+
if (scroll_node.widget.kind == .textarea) {
|
|
194
|
+
if (axis != .vertical) return null;
|
|
195
|
+
return self.applyCanvasWidgetTextareaScroll(scroll_index, delta, source);
|
|
196
|
+
}
|
|
141
197
|
if (canvasWidgetModelDrivenVirtual(scroll_node.widget)) return null;
|
|
198
|
+
if (!canvas.widgetScrollsAxis(scroll_node.widget, axis)) return null;
|
|
142
199
|
|
|
143
200
|
const viewport = scroll_node.frame.inset(scroll_node.widget.layout.padding).normalized();
|
|
144
201
|
if (viewport.isEmpty()) return null;
|
|
145
202
|
|
|
146
|
-
const
|
|
203
|
+
const state = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport);
|
|
204
|
+
const current = state.axis(axis);
|
|
147
205
|
// Per-region edge behavior: the region's overscroll override
|
|
148
206
|
// resolved onto the scroll-physics token (off by default —
|
|
149
207
|
// `applyWheel` clamps unless the effective mode is
|
|
@@ -156,22 +214,30 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
156
214
|
const rubberband = allow_rubberband and !scroll_node.widget.native_scroll;
|
|
157
215
|
const next = switch (source) {
|
|
158
216
|
.wheel => if (rubberband)
|
|
159
|
-
current.applyWheel(
|
|
217
|
+
current.applyWheel(delta, physics)
|
|
160
218
|
else
|
|
161
|
-
current.applyWheelClamped(
|
|
219
|
+
current.applyWheelClamped(delta, physics),
|
|
162
220
|
.discrete => discrete: {
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
break :discrete
|
|
221
|
+
var axis_state = current;
|
|
222
|
+
axis_state.offset += delta;
|
|
223
|
+
axis_state.velocity = 0;
|
|
224
|
+
break :discrete axis_state.clamped();
|
|
167
225
|
},
|
|
168
226
|
};
|
|
169
|
-
self.widget_scroll_states[scroll_index] = next;
|
|
227
|
+
self.widget_scroll_states[scroll_index] = state.withAxis(axis, next);
|
|
170
228
|
if (next.offset == current.offset) return null;
|
|
171
229
|
|
|
172
230
|
const offset_delta = next.offset - current.offset;
|
|
173
|
-
|
|
174
|
-
|
|
231
|
+
switch (axis) {
|
|
232
|
+
.vertical => {
|
|
233
|
+
self.widget_layout_nodes[scroll_index].widget.value = next.offset;
|
|
234
|
+
self.translateCanvasWidgetScrollDescendants(scroll_index, .{ .dy = -offset_delta });
|
|
235
|
+
},
|
|
236
|
+
.horizontal => {
|
|
237
|
+
self.widget_layout_nodes[scroll_index].widget.value_x = next.offset;
|
|
238
|
+
self.translateCanvasWidgetScrollDescendants(scroll_index, .{ .dx = -offset_delta });
|
|
239
|
+
},
|
|
240
|
+
}
|
|
175
241
|
self.noteCanvasWidgetScrollEvent(scroll_node.widget.id);
|
|
176
242
|
|
|
177
243
|
try self.refreshCanvasWidgetSemantics();
|
|
@@ -185,7 +251,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
185
251
|
if (widget.kind != .textarea) return null;
|
|
186
252
|
|
|
187
253
|
const viewport = canvas.textInputViewportForWidget(widget, self.widget_tokens) orelse return null;
|
|
188
|
-
const current = canvas.
|
|
254
|
+
const current = canvas.ScrollAxisState{
|
|
189
255
|
.offset = canvas.clampedTextInputScrollOffsetForWidget(widget, self.widget_tokens, widget.value),
|
|
190
256
|
.viewport_extent = viewport.height,
|
|
191
257
|
.content_extent = canvas.textInputContentExtentForWidget(widget, self.widget_tokens),
|
|
@@ -208,10 +274,10 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
208
274
|
}
|
|
209
275
|
|
|
210
276
|
/// Absolute offset write from a native scroll driver: the OS
|
|
211
|
-
/// scroller computed the
|
|
277
|
+
/// scroller computed the offsets (momentum, rubber-band — overscroll
|
|
212
278
|
/// values pass through so the bounce is visible), the engine just
|
|
213
279
|
/// follows. Engine velocity is zeroed; the driver owns physics.
|
|
214
|
-
pub fn applyCanvasWidgetScrollDriverOffset(self: *RuntimeView, scroll_index: usize,
|
|
280
|
+
pub fn applyCanvasWidgetScrollDriverOffset(self: *RuntimeView, scroll_index: usize, offset_x: f32, offset_y: f32) anyerror!?geometry.RectF {
|
|
215
281
|
if (scroll_index >= self.widget_layout_node_count) return null;
|
|
216
282
|
const scroll_node = self.widget_layout_nodes[scroll_index];
|
|
217
283
|
if (scroll_node.widget.kind != .scroll_view or canvasWidgetModelDrivenVirtual(scroll_node.widget)) return null;
|
|
@@ -221,14 +287,24 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
221
287
|
|
|
222
288
|
const current = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport);
|
|
223
289
|
var next = current;
|
|
224
|
-
|
|
225
|
-
|
|
290
|
+
// Driver offsets land only on axes the region grants: the
|
|
291
|
+
// sync pins the native scroller's range on ungranted axes,
|
|
292
|
+
// and a stray report there must not displace content.
|
|
293
|
+
if (canvas.widgetScrollsAxis(scroll_node.widget, .vertical)) {
|
|
294
|
+
next.offset_y = offset_y;
|
|
295
|
+
next.velocity_y = 0;
|
|
296
|
+
}
|
|
297
|
+
if (canvas.widgetScrollsAxis(scroll_node.widget, .horizontal)) {
|
|
298
|
+
next.offset_x = offset_x;
|
|
299
|
+
next.velocity_x = 0;
|
|
300
|
+
}
|
|
226
301
|
self.widget_scroll_states[scroll_index] = next;
|
|
227
|
-
if (next.
|
|
302
|
+
if (next.offset_y == current.offset_y and next.offset_x == current.offset_x) return null;
|
|
228
303
|
|
|
229
|
-
const offset_delta = next.
|
|
230
|
-
self.widget_layout_nodes[scroll_index].widget.value = next.
|
|
231
|
-
self.
|
|
304
|
+
const offset_delta = geometry.OffsetF.init(next.offset_x - current.offset_x, next.offset_y - current.offset_y);
|
|
305
|
+
self.widget_layout_nodes[scroll_index].widget.value = next.offset_y;
|
|
306
|
+
self.widget_layout_nodes[scroll_index].widget.value_x = next.offset_x;
|
|
307
|
+
self.translateCanvasWidgetScrollDescendants(scroll_index, .{ .dx = -offset_delta.dx, .dy = -offset_delta.dy });
|
|
232
308
|
self.noteCanvasWidgetScrollEvent(scroll_node.widget.id);
|
|
233
309
|
|
|
234
310
|
try self.refreshCanvasWidgetSemantics();
|
|
@@ -244,20 +320,40 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
244
320
|
const viewport = scroll_node.frame.inset(scroll_node.widget.layout.padding).normalized();
|
|
245
321
|
if (viewport.isEmpty()) return null;
|
|
246
322
|
|
|
323
|
+
// Home/End land at the content origin/terminus on EVERY axis
|
|
324
|
+
// the region grants: a vertical list jumps top/bottom exactly
|
|
325
|
+
// as before, a horizontal shelf jumps to its left/right edge,
|
|
326
|
+
// and a freely scrolling region jumps to the corner (the
|
|
327
|
+
// NSScrollView document begin/end convention).
|
|
247
328
|
const current = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport);
|
|
248
329
|
var next = current;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
330
|
+
if (canvas.widgetScrollsAxis(scroll_node.widget, .vertical)) {
|
|
331
|
+
var axis_state = current.axis(.vertical);
|
|
332
|
+
axis_state.offset = switch (target) {
|
|
333
|
+
.start => 0,
|
|
334
|
+
.end => axis_state.maxOffset(),
|
|
335
|
+
};
|
|
336
|
+
axis_state.velocity = 0;
|
|
337
|
+
next = next.withAxis(.vertical, axis_state.clamped());
|
|
338
|
+
}
|
|
339
|
+
if (canvas.widgetScrollsAxis(scroll_node.widget, .horizontal)) {
|
|
340
|
+
var axis_state = current.axis(.horizontal);
|
|
341
|
+
axis_state.offset = switch (target) {
|
|
342
|
+
.start => 0,
|
|
343
|
+
.end => axis_state.maxOffset(),
|
|
344
|
+
};
|
|
345
|
+
axis_state.velocity = 0;
|
|
346
|
+
next = next.withAxis(.horizontal, axis_state.clamped());
|
|
347
|
+
}
|
|
255
348
|
self.widget_scroll_states[scroll_index] = next;
|
|
256
|
-
if (next.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
self.widget_layout_nodes[scroll_index].widget.
|
|
260
|
-
self.translateCanvasWidgetScrollDescendants(scroll_index,
|
|
349
|
+
if (next.offset_y == current.offset_y and next.offset_x == current.offset_x) return null;
|
|
350
|
+
|
|
351
|
+
self.widget_layout_nodes[scroll_index].widget.value = next.offset_y;
|
|
352
|
+
self.widget_layout_nodes[scroll_index].widget.value_x = next.offset_x;
|
|
353
|
+
self.translateCanvasWidgetScrollDescendants(scroll_index, .{
|
|
354
|
+
.dx = -(next.offset_x - current.offset_x),
|
|
355
|
+
.dy = -(next.offset_y - current.offset_y),
|
|
356
|
+
});
|
|
261
357
|
self.noteCanvasWidgetScrollEvent(scroll_node.widget.id);
|
|
262
358
|
|
|
263
359
|
try self.refreshCanvasWidgetSemantics();
|
|
@@ -276,24 +372,48 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
276
372
|
|
|
277
373
|
const viewport = scroll_node.frame.inset(scroll_node.widget.layout.padding).normalized();
|
|
278
374
|
if (viewport.isEmpty()) {
|
|
279
|
-
self.widget_scroll_states[scroll_index].
|
|
375
|
+
self.widget_scroll_states[scroll_index].velocity_y = 0;
|
|
376
|
+
self.widget_scroll_states[scroll_index].velocity_x = 0;
|
|
280
377
|
continue;
|
|
281
378
|
}
|
|
282
379
|
|
|
283
380
|
const physics = canvas.widgetScrollPhysics(scroll_node.widget, self.widget_tokens.scroll);
|
|
284
381
|
const current = self.canvasWidgetScrollState(scroll_index, scroll_node, viewport);
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
382
|
+
var next = current;
|
|
383
|
+
var moved = geometry.OffsetF{};
|
|
384
|
+
|
|
385
|
+
if (canvas.widgetScrollsAxis(scroll_node.widget, .vertical)) {
|
|
386
|
+
const current_y = current.axis(.vertical);
|
|
387
|
+
if (current_y.needsKineticStep(physics)) {
|
|
388
|
+
const next_y = current_y.stepKinetic(dt_ms, physics);
|
|
389
|
+
next = next.withAxis(.vertical, next_y);
|
|
390
|
+
moved.dy = next_y.offset - current_y.offset;
|
|
391
|
+
} else {
|
|
392
|
+
next.velocity_y = 0;
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
next.velocity_y = 0;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (canvas.widgetScrollsAxis(scroll_node.widget, .horizontal)) {
|
|
399
|
+
const current_x = current.axis(.horizontal);
|
|
400
|
+
if (current_x.needsKineticStep(physics)) {
|
|
401
|
+
const next_x = current_x.stepKinetic(dt_ms, physics);
|
|
402
|
+
next = next.withAxis(.horizontal, next_x);
|
|
403
|
+
moved.dx = next_x.offset - current_x.offset;
|
|
404
|
+
} else {
|
|
405
|
+
next.velocity_x = 0;
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
next.velocity_x = 0;
|
|
288
409
|
}
|
|
289
410
|
|
|
290
|
-
const next = current.stepKinetic(dt_ms, physics);
|
|
291
411
|
self.widget_scroll_states[scroll_index] = next;
|
|
292
|
-
if (
|
|
412
|
+
if (moved.dx == 0 and moved.dy == 0) continue;
|
|
293
413
|
|
|
294
|
-
|
|
295
|
-
self.widget_layout_nodes[scroll_index].widget.
|
|
296
|
-
self.translateCanvasWidgetScrollDescendants(scroll_index, -
|
|
414
|
+
self.widget_layout_nodes[scroll_index].widget.value = next.offset_y;
|
|
415
|
+
self.widget_layout_nodes[scroll_index].widget.value_x = next.offset_x;
|
|
416
|
+
self.translateCanvasWidgetScrollDescendants(scroll_index, .{ .dx = -moved.dx, .dy = -moved.dy });
|
|
297
417
|
self.noteCanvasWidgetScrollEvent(scroll_node.widget.id);
|
|
298
418
|
dirty = unionRects(dirty, self.canvasWidgetDirtyBounds(scroll_index, scroll_node.frame));
|
|
299
419
|
changed = true;
|
|
@@ -316,23 +436,53 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
316
436
|
if (scroll_index < self.widget_layout_node_count and self.widget_layout_nodes[scroll_index].widget.layout.virtualized) {
|
|
317
437
|
return @max(viewport.height, canvas.virtualWidgetScrollContentExtentWithTokens(self.widget_layout_nodes[scroll_index].widget, viewport.height, self.widget_tokens));
|
|
318
438
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
439
|
+
return canvas_widget_runtime.canvasWidgetLayoutScrollContentExtent(
|
|
440
|
+
self.widget_layout_nodes[0..self.widget_layout_node_count],
|
|
441
|
+
scroll_index,
|
|
442
|
+
viewport,
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/// The horizontal content extent: how far the region's mounted
|
|
447
|
+
/// descendants reach rightward, rebased to offset 0. Textareas
|
|
448
|
+
/// and virtualized containers never scroll horizontally, so
|
|
449
|
+
/// their horizontal content pins to the viewport width. Closed
|
|
450
|
+
/// disclosure subtrees are skipped — concealed content lays out
|
|
451
|
+
/// at full size and must not inflate the scrollable range on
|
|
452
|
+
/// either axis (the semantics walker applies the same rule).
|
|
453
|
+
pub fn canvasWidgetScrollContentExtentX(self: *const RuntimeView, scroll_index: usize, viewport: geometry.RectF) f32 {
|
|
454
|
+
if (scroll_index < self.widget_layout_node_count and
|
|
455
|
+
(self.widget_layout_nodes[scroll_index].widget.kind == .textarea or self.widget_layout_nodes[scroll_index].widget.layout.virtualized))
|
|
456
|
+
{
|
|
457
|
+
return viewport.width;
|
|
325
458
|
}
|
|
326
|
-
return
|
|
459
|
+
return canvas_widget_runtime.canvasWidgetLayoutScrollContentExtentX(
|
|
460
|
+
self.widget_layout_nodes[0..self.widget_layout_node_count],
|
|
461
|
+
scroll_index,
|
|
462
|
+
viewport,
|
|
463
|
+
);
|
|
327
464
|
}
|
|
328
465
|
|
|
329
|
-
|
|
466
|
+
/// Scrolled content carries its descendants — INCLUDING floating
|
|
467
|
+
/// surfaces anchored to widgets inside it (their anchor bases
|
|
468
|
+
/// moved) — but a surface anchored to the SCROLL REGION ITSELF
|
|
469
|
+
/// stays put: its anchor base is the region's own frame, which
|
|
470
|
+
/// never moves when the content under it does.
|
|
471
|
+
pub fn translateCanvasWidgetScrollDescendants(self: *RuntimeView, scroll_index: usize, offset: geometry.OffsetF) void {
|
|
330
472
|
const scroll_depth = self.widget_layout_nodes[scroll_index].depth;
|
|
331
473
|
var index = scroll_index + 1;
|
|
332
|
-
while (index < self.widget_layout_node_count and self.widget_layout_nodes[index].depth > scroll_depth)
|
|
333
|
-
const
|
|
474
|
+
while (index < self.widget_layout_node_count and self.widget_layout_nodes[index].depth > scroll_depth) {
|
|
475
|
+
const node = self.widget_layout_nodes[index];
|
|
476
|
+
if (node.widget.layout.anchor != null and node.parent_index == scroll_index) {
|
|
477
|
+
const subtree_depth = node.depth;
|
|
478
|
+
index += 1;
|
|
479
|
+
while (index < self.widget_layout_node_count and self.widget_layout_nodes[index].depth > subtree_depth) : (index += 1) {}
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
const translated = node.frame.translate(offset);
|
|
334
483
|
self.widget_layout_nodes[index].frame = translated;
|
|
335
484
|
self.widget_layout_nodes[index].widget.frame = translated;
|
|
485
|
+
index += 1;
|
|
336
486
|
}
|
|
337
487
|
}
|
|
338
488
|
|
|
@@ -226,10 +226,19 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/// The text a copy shortcut should place on the clipboard: the
|
|
229
|
-
/// focused editable widget's selection
|
|
230
|
-
/// view's static
|
|
229
|
+
/// focused editable widget's selection or focused terminal's
|
|
230
|
+
/// emulator selection when it has one, else the view's static
|
|
231
|
+
/// text selection.
|
|
231
232
|
pub fn canvasWidgetCopyText(self: *const RuntimeView) ?[]const u8 {
|
|
232
233
|
if (self.canvas_widget_focused_id != 0) {
|
|
234
|
+
if (self.canvasWidgetNodeIndexById(self.canvas_widget_focused_id)) |index| {
|
|
235
|
+
const focused = self.widget_layout_nodes[index].widget;
|
|
236
|
+
if (!focused.state.disabled and focused.kind == .terminal) {
|
|
237
|
+
if (focused.terminal.grid) |grid| {
|
|
238
|
+
if (grid.selection_active) return grid.selection_text;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
233
242
|
if (canvasWidgetSelectionSliceById(self, self.canvas_widget_focused_id, true)) |slice| return slice;
|
|
234
243
|
}
|
|
235
244
|
if (self.canvas_widget_selected_text_id != 0) {
|
|
@@ -194,6 +194,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
194
194
|
if (anchored_count > canvas_limits.max_canvas_widget_anchored_per_view) return error.WidgetAnchoredSurfaceLimitReached;
|
|
195
195
|
if (layout.nodes.len > 0 and layout.nodes.ptr == self.widget_layout_nodes[0..].ptr) {
|
|
196
196
|
self.widget_revision += 1;
|
|
197
|
+
self.canvas_widget_layout_adoptions +%= 1;
|
|
197
198
|
return;
|
|
198
199
|
}
|
|
199
200
|
|
|
@@ -268,6 +269,20 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
|
|
272
|
+
// ADOPTION begins here: the pool resets below are
|
|
273
|
+
// destructive, and a later per-node failure (an invalid
|
|
274
|
+
// command name escapes the pre-validation) leaves a TORN
|
|
275
|
+
// retained tree — so the witness the ui-app hover currency
|
|
276
|
+
// samples must move at this boundary, not at the
|
|
277
|
+
// function's successful return. Everything above —
|
|
278
|
+
// node/anchored/pool-budget validation — rejects with the
|
|
279
|
+
// previous tree fully applied and the witness unmoved. A
|
|
280
|
+
// torn copy also prunes hover containment against whatever
|
|
281
|
+
// partial tree it retained, so the owed leaves dispatch at
|
|
282
|
+
// the failure's own drain instead of waiting for the next
|
|
283
|
+
// pointer move.
|
|
284
|
+
self.canvas_widget_layout_adoptions +%= 1;
|
|
285
|
+
errdefer self.pruneCanvasWidgetHoverMsgChain();
|
|
271
286
|
self.widget_layout_node_count = 0;
|
|
272
287
|
self.widget_semantics_node_count = 0;
|
|
273
288
|
self.widget_text_len = 0;
|
|
@@ -323,6 +338,11 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
323
338
|
if (self.canvas_widget_hovered_id != 0 and !canvasWidgetInteractionTargetExists(self.widgetLayoutTree(), self.canvas_widget_hovered_id)) {
|
|
324
339
|
self.canvas_widget_hovered_id = 0;
|
|
325
340
|
}
|
|
341
|
+
// Hover-Msg entries whose widgets this rebuild unmounted owe
|
|
342
|
+
// their leave edge; survivors keep standing (the adoption
|
|
343
|
+
// reconcile re-hit-tests the stored pointer position right
|
|
344
|
+
// after, wherever one exists).
|
|
345
|
+
self.pruneCanvasWidgetHoverMsgChain();
|
|
326
346
|
// The hover point belongs to the hovered widget's detail
|
|
327
347
|
// chrome; without a hovered widget it means nothing.
|
|
328
348
|
if (self.canvas_widget_hovered_id == 0) self.canvas_widget_hover_point = null;
|
|
@@ -349,6 +369,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
349
369
|
pub fn canvasWidgetRenderState(self: *const RuntimeView) canvas.WidgetRenderState {
|
|
350
370
|
const focused_id: ?canvas.ObjectId = if (!self.focused or self.canvas_widget_focused_id == 0) null else self.canvas_widget_focused_id;
|
|
351
371
|
return .{
|
|
372
|
+
.keyboard_active = self.keyboard_active,
|
|
352
373
|
.focused_id = focused_id,
|
|
353
374
|
.focus_visible_id = if (focused_id) |id| if (self.canvas_widget_focus_visible_id == id) id else null else null,
|
|
354
375
|
.hovered_id = if (self.canvas_widget_hovered_id == 0) null else self.canvas_widget_hovered_id,
|
|
@@ -376,6 +397,35 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
376
397
|
return layout.nodes[target_index].widget.id;
|
|
377
398
|
}
|
|
378
399
|
|
|
400
|
+
/// Recompute the standing hover-Msg chain from a raw hit — the
|
|
401
|
+
/// pointer and scroll seams call this with the SAME raw hit the
|
|
402
|
+
/// wash resolution consumed, so containment and the wash always
|
|
403
|
+
/// agree on where the pointer stands.
|
|
404
|
+
pub fn setCanvasWidgetHoverMsgChainForHit(self: *RuntimeView, hit: ?canvas.WidgetHit) void {
|
|
405
|
+
const chain = self.widgetLayoutTree().hoverMsgChainForHit(hit, &self.canvas_widget_hover_msg_chain);
|
|
406
|
+
self.canvas_widget_hover_msg_chain_len = chain.len;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/// Point-blind prune of the standing hover-Msg chain: drop
|
|
410
|
+
/// entries whose widgets left the tree (their leave edge is
|
|
411
|
+
/// due), keep the rest — the wash's exact rebuild rule (an id
|
|
412
|
+
/// survives a rebuild until a re-hit-test says otherwise).
|
|
413
|
+
pub fn pruneCanvasWidgetHoverMsgChain(self: *RuntimeView) void {
|
|
414
|
+
const layout = self.widgetLayoutTree();
|
|
415
|
+
var kept: usize = 0;
|
|
416
|
+
for (self.canvas_widget_hover_msg_chain[0..self.canvas_widget_hover_msg_chain_len]) |id| {
|
|
417
|
+
// Survival is the HOVER predicate, not the interactive
|
|
418
|
+
// one: a hover-only listener must not be evicted (a
|
|
419
|
+
// false leave), and a widget whose hover bindings this
|
|
420
|
+
// rebuild removed must stop standing (its leave is
|
|
421
|
+
// owed) even though it still exists interactively.
|
|
422
|
+
if (!canvas_widget_runtime.canvasWidgetHoverMsgTargetExists(layout, id)) continue;
|
|
423
|
+
self.canvas_widget_hover_msg_chain[kept] = id;
|
|
424
|
+
kept += 1;
|
|
425
|
+
}
|
|
426
|
+
self.canvas_widget_hover_msg_chain_len = kept;
|
|
427
|
+
}
|
|
428
|
+
|
|
379
429
|
pub fn reconcileCanvasWidgetRenderStateAfterScroll(self: *RuntimeView, point: ?geometry.PointF) void {
|
|
380
430
|
const layout = self.widgetLayoutTree();
|
|
381
431
|
if (self.canvas_widget_focused_id != 0 and layout.focusTargetById(self.canvas_widget_focused_id) == null) {
|
|
@@ -395,13 +445,29 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
395
445
|
// Same hover-target walk as live pointer moves: the wash
|
|
396
446
|
// and cursor a scroll settles on must match what a real
|
|
397
447
|
// move to this point would produce.
|
|
398
|
-
const
|
|
448
|
+
const raw = layout.hitTestWithTokens(value, self.widget_tokens);
|
|
449
|
+
const hit = layout.hoverTargetForHit(raw);
|
|
399
450
|
next_hovered_id = if (hit) |target| target.id else 0;
|
|
400
451
|
next_cursor = platformCursorFromCanvas(layout.cursorForHit(hit));
|
|
401
452
|
} else if (!canvasWidgetInteractionTargetExists(layout, next_hovered_id)) {
|
|
402
453
|
next_hovered_id = 0;
|
|
403
454
|
next_cursor = .arrow;
|
|
404
455
|
}
|
|
456
|
+
// The hover-Msg chain re-resolves whenever a hover-capable
|
|
457
|
+
// pointer stands, at that pointer's OWN anchor — content
|
|
458
|
+
// sliding out from under it fires the same leave a real
|
|
459
|
+
// move off it would, on the wheel path and the point-blind
|
|
460
|
+
// paths (kinetic, drivers, keyboard) alike. Never the
|
|
461
|
+
// passed point: that follows `canvas_last_pointer_position`,
|
|
462
|
+
// which any device updates — a touch drag must not steer
|
|
463
|
+
// the mouse's containment (on single-pointer hosts the two
|
|
464
|
+
// agree). Without a proven pointer, entries survive by id
|
|
465
|
+
// until their widgets leave the tree — the wash's rule.
|
|
466
|
+
if (self.canvas_widget_hover_pointer_live) {
|
|
467
|
+
self.setCanvasWidgetHoverMsgChainForHit(layout.hitTestHoverWithTokens(self.canvas_widget_hover_pointer_position, self.widget_tokens));
|
|
468
|
+
} else {
|
|
469
|
+
self.pruneCanvasWidgetHoverMsgChain();
|
|
470
|
+
}
|
|
405
471
|
|
|
406
472
|
var next_pressed_id = self.canvas_widget_pressed_id;
|
|
407
473
|
if (!canvasWidgetInteractionTargetExists(layout, next_pressed_id)) {
|
|
@@ -557,6 +623,18 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
557
623
|
self.canvas_widget_cursor = .arrow;
|
|
558
624
|
}
|
|
559
625
|
if (self.canvasWidgetIdDescendsFromIndex(self.canvas_widget_pressed_id, surface_index)) self.canvas_widget_pressed_id = 0;
|
|
626
|
+
// Hover-Msg listeners inside the dismissed surface owe their
|
|
627
|
+
// leave edge — the surface is gone from under the pointer;
|
|
628
|
+
// listeners outside it keep standing (the wash rule).
|
|
629
|
+
{
|
|
630
|
+
var kept: usize = 0;
|
|
631
|
+
for (self.canvas_widget_hover_msg_chain[0..self.canvas_widget_hover_msg_chain_len]) |id| {
|
|
632
|
+
if (self.canvasWidgetIdDescendsFromIndex(id, surface_index)) continue;
|
|
633
|
+
self.canvas_widget_hover_msg_chain[kept] = id;
|
|
634
|
+
kept += 1;
|
|
635
|
+
}
|
|
636
|
+
self.canvas_widget_hover_msg_chain_len = kept;
|
|
637
|
+
}
|
|
560
638
|
|
|
561
639
|
try self.refreshCanvasWidgetSemantics();
|
|
562
640
|
self.widget_revision += 1;
|
|
@@ -983,8 +1061,15 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
983
1061
|
};
|
|
984
1062
|
return switch (self.widget_layout_nodes[index].widget.kind) {
|
|
985
1063
|
.grid, .scroll_view, .list, .data_grid, .table => switch (direction) {
|
|
986
|
-
|
|
987
|
-
|
|
1064
|
+
// Page keys step the vertical axis on every keymap
|
|
1065
|
+
// except the horizontal-only one (which mirrors the
|
|
1066
|
+
// whole map sideways) — so a BOTH-axes region whose
|
|
1067
|
+
// live axis is horizontal needs the both-keymap's
|
|
1068
|
+
// horizontal keys instead, or the assistive step
|
|
1069
|
+
// would page a zero-range vertical axis and report
|
|
1070
|
+
// success without moving.
|
|
1071
|
+
.increment => if (canvasWidgetStepAxisHorizontal(self, index)) "arrowright" else "pagedown",
|
|
1072
|
+
.decrement => if (canvasWidgetStepAxisHorizontal(self, index)) "arrowleft" else "pageup",
|
|
988
1073
|
},
|
|
989
1074
|
else => switch (direction) {
|
|
990
1075
|
.increment => "arrowright",
|
|
@@ -993,6 +1078,29 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
993
1078
|
};
|
|
994
1079
|
}
|
|
995
1080
|
|
|
1081
|
+
/// Whether a BOTH-axes scroll region's assistive step must take
|
|
1082
|
+
/// the horizontal keys: the vertical axis has no range while
|
|
1083
|
+
/// the horizontal one does. The extents come from the SEMANTICS
|
|
1084
|
+
/// metrics — the same derivation the assistive node reports its
|
|
1085
|
+
/// primary axis through, concealed-disclosure and anchored
|
|
1086
|
+
/// exclusions included — so the key an increment synthesizes
|
|
1087
|
+
/// can never disagree with the axis the node advertised.
|
|
1088
|
+
/// Vertical-capable regions with vertical range — and
|
|
1089
|
+
/// horizontal-only regions, whose keymap already maps the page
|
|
1090
|
+
/// keys sideways — keep the page keys.
|
|
1091
|
+
fn canvasWidgetStepAxisHorizontal(self: *const RuntimeView, index: usize) bool {
|
|
1092
|
+
const node = self.widget_layout_nodes[index];
|
|
1093
|
+
if (node.widget.kind != .scroll_view or node.widget.scroll_axes != .both) return false;
|
|
1094
|
+
const viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
1095
|
+
if (viewport.isEmpty()) return false;
|
|
1096
|
+
const layout = self.widgetLayoutTree();
|
|
1097
|
+
const vertical = canvas.widgetScrollAxisMetrics(layout, index, canvas.virtualWidgetScrollContentExtent, .vertical, viewport);
|
|
1098
|
+
const horizontal = canvas.widgetScrollAxisMetrics(layout, index, canvas.virtualWidgetScrollContentExtent, .horizontal, viewport);
|
|
1099
|
+
const vertical_range = vertical.present and vertical.content_extent > vertical.viewport_extent;
|
|
1100
|
+
const horizontal_range = horizontal.present and horizontal.content_extent > horizontal.viewport_extent;
|
|
1101
|
+
return !vertical_range and horizontal_range;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
996
1104
|
pub fn refreshCanvasWidgetSemantics(self: *RuntimeView) anyerror!void {
|
|
997
1105
|
const semantics = try self.widgetLayoutTree().collectSemantics(&self.widget_semantics_nodes);
|
|
998
1106
|
self.widget_semantics_node_count = semantics.len;
|