@native-sdk/cli 0.0.0 → 0.4.1
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/LICENSE +176 -0
- package/README.md +50 -1
- package/app.zon +30 -0
- package/assets/icon.icns +0 -0
- package/assets/icon.ico +0 -0
- package/assets/icon.png +0 -0
- package/assets/icon.svg +15 -0
- package/assets/native-sdk.entitlements +10 -0
- package/assets/native-sdk.manifest +12 -0
- package/bin/native.js +156 -0
- package/build/app.zig +716 -0
- package/build.zig +2593 -0
- package/build.zig.zon +24 -0
- package/native-sdk.d.ts +615 -0
- package/package.json +45 -8
- package/skill-data/automation/SKILL.md +248 -0
- package/skill-data/core/SKILL.md +249 -0
- package/skill-data/core/references/app-model-runtime.md +141 -0
- package/skill-data/core/references/bridge-security-native-capabilities.md +230 -0
- package/skill-data/core/references/frontend-assets.md +124 -0
- package/skill-data/core/references/project-anatomy.md +108 -0
- package/skill-data/core/references/web-engines-packaging-debugging.md +199 -0
- package/skill-data/native-ui/SKILL.md +1080 -0
- package/skills/native-sdk/SKILL.md +33 -0
- package/src/app_runner/root.zig +740 -0
- package/src/assets/root.zig +20 -0
- package/src/automation/protocol.zig +285 -0
- package/src/automation/root.zig +13 -0
- package/src/automation/server.zig +506 -0
- package/src/automation/snapshot.zig +1202 -0
- package/src/automation/watcher.zig +165 -0
- package/src/bridge/root.zig +507 -0
- package/src/debug/root.zig +246 -0
- package/src/embed/app_exports.zig +11 -0
- package/src/embed/c_api.zig +793 -0
- package/src/embed/c_exports.zig +10 -0
- package/src/embed/chrome.zig +168 -0
- package/src/embed/conversions.zig +359 -0
- package/src/embed/host.zig +960 -0
- package/src/embed/root.zig +81 -0
- package/src/embed/tests.zig +2552 -0
- package/src/embed/types.zig +382 -0
- package/src/embed/ui_host.zig +289 -0
- package/src/extensions/root.zig +197 -0
- package/src/frontend/root.zig +48 -0
- package/src/js/root.zig +65 -0
- package/src/platform/android/NativeSdkActivity.java +1370 -0
- package/src/platform/android/android_host.c +696 -0
- package/src/platform/android/files.zig +9 -0
- package/src/platform/android/native_sdk_app.h +237 -0
- package/src/platform/ios/files.zig +8 -0
- package/src/platform/ios/native_sdk_app.h +289 -0
- package/src/platform/ios/uikit_host.m +2739 -0
- package/src/platform/linux/cef_host.cpp +599 -0
- package/src/platform/linux/gtk_host.c +5362 -0
- package/src/platform/linux/gtk_host.h +265 -0
- package/src/platform/linux/root.zig +1519 -0
- package/src/platform/macos/appkit_host.h +604 -0
- package/src/platform/macos/appkit_host.m +10392 -0
- package/src/platform/macos/automation_host.h +14 -0
- package/src/platform/macos/automation_host.m +12 -0
- package/src/platform/macos/cef_host.mm +3028 -0
- package/src/platform/macos/root.zig +2260 -0
- package/src/platform/null_platform.zig +2232 -0
- package/src/platform/null_platform_tests.zig +670 -0
- package/src/platform/policy_values.zig +14 -0
- package/src/platform/root.zig +181 -0
- package/src/platform/types.zig +2681 -0
- package/src/platform/windows/cef_host.cpp +3 -0
- package/src/platform/windows/root.zig +1521 -0
- package/src/platform/windows/webview2_host.cpp +6230 -0
- package/src/primitives/app_dirs/root.zig +440 -0
- package/src/primitives/app_manifest/root.zig +109 -0
- package/src/primitives/app_manifest/tests.zig +758 -0
- package/src/primitives/app_manifest/types.zig +587 -0
- package/src/primitives/app_manifest/validation.zig +828 -0
- package/src/primitives/assets/root.zig +520 -0
- package/src/primitives/canvas/a11y_audit.zig +390 -0
- package/src/primitives/canvas/a11y_audit_tests.zig +225 -0
- package/src/primitives/canvas/app_icon.zig +1590 -0
- package/src/primitives/canvas/chart.zig +392 -0
- package/src/primitives/canvas/chart_tests.zig +751 -0
- package/src/primitives/canvas/commands.zig +446 -0
- package/src/primitives/canvas/drawing.zig +309 -0
- package/src/primitives/canvas/equality.zig +316 -0
- package/src/primitives/canvas/events.zig +696 -0
- package/src/primitives/canvas/font_coverage.zig +118 -0
- package/src/primitives/canvas/font_ttf.zig +510 -0
- package/src/primitives/canvas/font_ttf_tests.zig +280 -0
- package/src/primitives/canvas/fonts/Geist-Regular.ttf +0 -0
- package/src/primitives/canvas/fonts/GeistMono-Regular.ttf +0 -0
- package/src/primitives/canvas/frame.zig +679 -0
- package/src/primitives/canvas/frame_metrics.zig +462 -0
- package/src/primitives/canvas/gpu.zig +639 -0
- package/src/primitives/canvas/hash.zig +112 -0
- package/src/primitives/canvas/icons/alert.svg +1 -0
- package/src/primitives/canvas/icons/archive.svg +1 -0
- package/src/primitives/canvas/icons/arrow-down.svg +1 -0
- package/src/primitives/canvas/icons/arrow-right.svg +1 -0
- package/src/primitives/canvas/icons/arrow-up.svg +1 -0
- package/src/primitives/canvas/icons/check-circle.svg +1 -0
- package/src/primitives/canvas/icons/check.svg +1 -0
- package/src/primitives/canvas/icons/chevron-down.svg +1 -0
- package/src/primitives/canvas/icons/chevron-left.svg +1 -0
- package/src/primitives/canvas/icons/chevron-right.svg +1 -0
- package/src/primitives/canvas/icons/chevron-up.svg +1 -0
- package/src/primitives/canvas/icons/circle-dot.svg +1 -0
- package/src/primitives/canvas/icons/clock.svg +1 -0
- package/src/primitives/canvas/icons/copy.svg +1 -0
- package/src/primitives/canvas/icons/download.svg +1 -0
- package/src/primitives/canvas/icons/edit.svg +1 -0
- package/src/primitives/canvas/icons/ellipsis.svg +1 -0
- package/src/primitives/canvas/icons/external-link.svg +1 -0
- package/src/primitives/canvas/icons/eye.svg +1 -0
- package/src/primitives/canvas/icons/file-text.svg +1 -0
- package/src/primitives/canvas/icons/folder-open.svg +1 -0
- package/src/primitives/canvas/icons/folder.svg +1 -0
- package/src/primitives/canvas/icons/git-branch.svg +1 -0
- package/src/primitives/canvas/icons/git-merge.svg +1 -0
- package/src/primitives/canvas/icons/git-pull-request.svg +1 -0
- package/src/primitives/canvas/icons/info.svg +1 -0
- package/src/primitives/canvas/icons/menu.svg +1 -0
- package/src/primitives/canvas/icons/missing.svg +1 -0
- package/src/primitives/canvas/icons/moon.svg +1 -0
- package/src/primitives/canvas/icons/music.svg +1 -0
- package/src/primitives/canvas/icons/panel-left.svg +1 -0
- package/src/primitives/canvas/icons/panel-right.svg +1 -0
- package/src/primitives/canvas/icons/pause.svg +1 -0
- package/src/primitives/canvas/icons/play.svg +1 -0
- package/src/primitives/canvas/icons/plus.svg +1 -0
- package/src/primitives/canvas/icons/refresh-cw.svg +1 -0
- package/src/primitives/canvas/icons/repeat.svg +1 -0
- package/src/primitives/canvas/icons/save.svg +1 -0
- package/src/primitives/canvas/icons/search.svg +1 -0
- package/src/primitives/canvas/icons/send.svg +1 -0
- package/src/primitives/canvas/icons/settings.svg +1 -0
- package/src/primitives/canvas/icons/shuffle.svg +1 -0
- package/src/primitives/canvas/icons/skip-back.svg +1 -0
- package/src/primitives/canvas/icons/skip-forward.svg +1 -0
- package/src/primitives/canvas/icons/sun.svg +1 -0
- package/src/primitives/canvas/icons/terminal.svg +1 -0
- package/src/primitives/canvas/icons/trash.svg +1 -0
- package/src/primitives/canvas/icons/volume.svg +1 -0
- package/src/primitives/canvas/icons/wrench.svg +1 -0
- package/src/primitives/canvas/icons/x-circle.svg +1 -0
- package/src/primitives/canvas/icons/x.svg +1 -0
- package/src/primitives/canvas/icons.zig +249 -0
- package/src/primitives/canvas/layout_audit.zig +744 -0
- package/src/primitives/canvas/layout_audit_tests.zig +426 -0
- package/src/primitives/canvas/markdown.zig +1031 -0
- package/src/primitives/canvas/markdown_hostile_tests.zig +471 -0
- package/src/primitives/canvas/markdown_tests.zig +538 -0
- package/src/primitives/canvas/plan_key_index.zig +120 -0
- package/src/primitives/canvas/png.zig +355 -0
- package/src/primitives/canvas/reference.zig +1457 -0
- package/src/primitives/canvas/reference_blur.zig +104 -0
- package/src/primitives/canvas/reference_memo.zig +322 -0
- package/src/primitives/canvas/reference_paths.zig +184 -0
- package/src/primitives/canvas/reference_tests.zig +1650 -0
- package/src/primitives/canvas/render.zig +747 -0
- package/src/primitives/canvas/render_effects.zig +255 -0
- package/src/primitives/canvas/render_fingerprints.zig +256 -0
- package/src/primitives/canvas/render_generic_resources.zig +376 -0
- package/src/primitives/canvas/render_images.zig +247 -0
- package/src/primitives/canvas/render_layers.zig +260 -0
- package/src/primitives/canvas/render_paths.zig +347 -0
- package/src/primitives/canvas/render_resources.zig +51 -0
- package/src/primitives/canvas/render_tests.zig +3186 -0
- package/src/primitives/canvas/root.zig +744 -0
- package/src/primitives/canvas/serialization.zig +1528 -0
- package/src/primitives/canvas/svg_icon.zig +636 -0
- package/src/primitives/canvas/svg_icon_tests.zig +312 -0
- package/src/primitives/canvas/test_support.zig +422 -0
- package/src/primitives/canvas/testdata/markdown_document.md +83 -0
- package/src/primitives/canvas/tests.zig +30 -0
- package/src/primitives/canvas/text.zig +82 -0
- package/src/primitives/canvas/text_atlas.zig +408 -0
- package/src/primitives/canvas/text_batch_tests.zig +431 -0
- package/src/primitives/canvas/text_interaction.zig +615 -0
- package/src/primitives/canvas/text_layout.zig +1069 -0
- package/src/primitives/canvas/text_layout_cache.zig +281 -0
- package/src/primitives/canvas/text_layout_hash.zig +113 -0
- package/src/primitives/canvas/text_layout_types.zig +128 -0
- package/src/primitives/canvas/text_measure_cache.zig +279 -0
- package/src/primitives/canvas/text_metrics.zig +309 -0
- package/src/primitives/canvas/text_metrics_tests.zig +262 -0
- package/src/primitives/canvas/text_span_tests.zig +608 -0
- package/src/primitives/canvas/text_spans.zig +1010 -0
- package/src/primitives/canvas/text_tests.zig +1949 -0
- package/src/primitives/canvas/themes/geist.zig +470 -0
- package/src/primitives/canvas/tokens.zig +1522 -0
- package/src/primitives/canvas/ui.zig +2686 -0
- package/src/primitives/canvas/ui_markup.zig +3791 -0
- package/src/primitives/canvas/ui_markup_binary.zig +522 -0
- package/src/primitives/canvas/ui_markup_binary_tests.zig +591 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +2565 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1669 -0
- package/src/primitives/canvas/ui_markup_contract.zig +1620 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +953 -0
- package/src/primitives/canvas/ui_markup_edit.zig +416 -0
- package/src/primitives/canvas/ui_markup_edit_tests.zig +341 -0
- package/src/primitives/canvas/ui_markup_expr.zig +1152 -0
- package/src/primitives/canvas/ui_markup_expr_tests.zig +779 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +505 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +1545 -0
- package/src/primitives/canvas/ui_markup_view.zig +2352 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +3709 -0
- package/src/primitives/canvas/ui_provenance.zig +96 -0
- package/src/primitives/canvas/ui_provenance_tests.zig +186 -0
- package/src/primitives/canvas/ui_schema.zig +825 -0
- package/src/primitives/canvas/ui_schema_tests.zig +128 -0
- package/src/primitives/canvas/ui_tests.zig +1432 -0
- package/src/primitives/canvas/vector.zig +919 -0
- package/src/primitives/canvas/vector_tests.zig +547 -0
- package/src/primitives/canvas/virtual_extent_tests.zig +317 -0
- package/src/primitives/canvas/virtual_extents.zig +540 -0
- package/src/primitives/canvas/widget_access.zig +208 -0
- package/src/primitives/canvas/widget_anchored_tests.zig +264 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +3160 -0
- package/src/primitives/canvas/widget_invalidation.zig +748 -0
- package/src/primitives/canvas/widget_layout.zig +2055 -0
- package/src/primitives/canvas/widget_layout_tests.zig +2691 -0
- package/src/primitives/canvas/widget_metrics.zig +228 -0
- package/src/primitives/canvas/widget_render.zig +2534 -0
- package/src/primitives/canvas/widget_render_controls.zig +1563 -0
- package/src/primitives/canvas/widget_render_scroll.zig +136 -0
- package/src/primitives/canvas/widget_render_style.zig +626 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +794 -0
- package/src/primitives/canvas/widget_routing.zig +475 -0
- package/src/primitives/canvas/widget_runtime.zig +307 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +3015 -0
- package/src/primitives/canvas/widget_semantics.zig +480 -0
- package/src/primitives/canvas/widget_semantics_tests.zig +2129 -0
- package/src/primitives/canvas/widget_tests.zig +8 -0
- package/src/primitives/canvas/widget_text_input.zig +351 -0
- package/src/primitives/canvas/widget_text_select.zig +147 -0
- package/src/primitives/canvas/widget_tree.zig +232 -0
- package/src/primitives/canvas/widgets.zig +1319 -0
- package/src/primitives/diagnostics/root.zig +445 -0
- package/src/primitives/geometry/root.zig +889 -0
- package/src/primitives/json/root.zig +272 -0
- package/src/primitives/platform_info/root.zig +450 -0
- package/src/primitives/trace/root.zig +569 -0
- package/src/root.zig +165 -0
- package/src/runtime/api.zig +431 -0
- package/src/runtime/async_bridge.zig +49 -0
- package/src/runtime/automation_commands.zig +686 -0
- package/src/runtime/automation_liveness_tests.zig +140 -0
- package/src/runtime/automation_snapshot.zig +246 -0
- package/src/runtime/automation_widget_dispatch.zig +617 -0
- package/src/runtime/bridge_dispatch_tests.zig +202 -0
- package/src/runtime/bridge_payload.zig +194 -0
- package/src/runtime/bridge_permission_tests.zig +551 -0
- package/src/runtime/bridge_responses.zig +414 -0
- package/src/runtime/builtin_bridge.zig +554 -0
- package/src/runtime/canvas_budget_edge_tests.zig +415 -0
- package/src/runtime/canvas_font_tests.zig +410 -0
- package/src/runtime/canvas_fonts.zig +229 -0
- package/src/runtime/canvas_frame.zig +1734 -0
- package/src/runtime/canvas_frame_animation_tests.zig +609 -0
- package/src/runtime/canvas_frame_cache_tests.zig +333 -0
- package/src/runtime/canvas_frame_helpers.zig +414 -0
- package/src/runtime/canvas_frame_invalidation_tests.zig +544 -0
- package/src/runtime/canvas_frame_packet_tests.zig +1353 -0
- package/src/runtime/canvas_frame_patch_tests.zig +1051 -0
- package/src/runtime/canvas_frame_retained_tests.zig +753 -0
- package/src/runtime/canvas_frame_tests.zig +9 -0
- package/src/runtime/canvas_frame_text_layout_budget_tests.zig +149 -0
- package/src/runtime/canvas_image_tests.zig +362 -0
- package/src/runtime/canvas_images.zig +224 -0
- package/src/runtime/canvas_limits.zig +317 -0
- package/src/runtime/canvas_screenshot_tests.zig +289 -0
- package/src/runtime/canvas_widget_accessibility_tests.zig +1494 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +678 -0
- package/src/runtime/canvas_widget_chart_tests.zig +249 -0
- package/src/runtime/canvas_widget_clipboard_tests.zig +399 -0
- package/src/runtime/canvas_widget_context_menu.zig +318 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +462 -0
- package/src/runtime/canvas_widget_control_tests.zig +2164 -0
- package/src/runtime/canvas_widget_disclosure_tests.zig +440 -0
- package/src/runtime/canvas_widget_display.zig +677 -0
- package/src/runtime/canvas_widget_event_tests.zig +1779 -0
- package/src/runtime/canvas_widget_events.zig +1098 -0
- package/src/runtime/canvas_widget_floating_tests.zig +695 -0
- package/src/runtime/canvas_widget_layout_tests.zig +26 -0
- package/src/runtime/canvas_widget_runtime.zig +1335 -0
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +582 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +202 -0
- package/src/runtime/canvas_widget_scroll_tests.zig +1549 -0
- package/src/runtime/canvas_widget_semantics_tests.zig +810 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +1031 -0
- package/src/runtime/canvas_widget_state.zig +798 -0
- package/src/runtime/canvas_widget_text_tests.zig +2104 -0
- package/src/runtime/canvas_widget_window_drag_tests.zig +284 -0
- package/src/runtime/clock.zig +231 -0
- package/src/runtime/core.zig +927 -0
- package/src/runtime/effects.zig +4197 -0
- package/src/runtime/effects_audio_tests.zig +690 -0
- package/src/runtime/effects_clipboard_tests.zig +317 -0
- package/src/runtime/effects_fetch_tests.zig +1031 -0
- package/src/runtime/effects_file_tests.zig +407 -0
- package/src/runtime/effects_tests.zig +1251 -0
- package/src/runtime/flow.zig +1175 -0
- package/src/runtime/frame_profile.zig +221 -0
- package/src/runtime/gpu_surface_events.zig +639 -0
- package/src/runtime/launch_timing.zig +59 -0
- package/src/runtime/markdown_app_tests.zig +224 -0
- package/src/runtime/native_command_event_tests.zig +431 -0
- package/src/runtime/platform_bridge_tests.zig +8 -0
- package/src/runtime/platform_config_tests.zig +392 -0
- package/src/runtime/root.zig +150 -0
- package/src/runtime/runtime_event_tests.zig +1079 -0
- package/src/runtime/session_journal.zig +1522 -0
- package/src/runtime/session_record.zig +332 -0
- package/src/runtime/session_replay.zig +274 -0
- package/src/runtime/session_state.zig +30 -0
- package/src/runtime/session_tests.zig +399 -0
- package/src/runtime/shell_layout.zig +472 -0
- package/src/runtime/shell_layout_tests.zig +1246 -0
- package/src/runtime/shell_view_tests.zig +604 -0
- package/src/runtime/state.zig +110 -0
- package/src/runtime/system_services.zig +392 -0
- package/src/runtime/test_support.zig +79 -0
- package/src/runtime/tests.zig +30 -0
- package/src/runtime/ui_app.zig +3290 -0
- package/src/runtime/ui_app_huge_model_tests.zig +351 -0
- package/src/runtime/ui_app_provenance.zig +370 -0
- package/src/runtime/ui_app_tests.zig +3254 -0
- package/src/runtime/ui_app_virtual_variable_tests.zig +485 -0
- package/src/runtime/ui_app_window_tests.zig +442 -0
- package/src/runtime/validation.zig +206 -0
- package/src/runtime/view.zig +908 -0
- package/src/runtime/view_canvas.zig +850 -0
- package/src/runtime/view_widget_control.zig +433 -0
- package/src/runtime/view_widget_scroll.zig +360 -0
- package/src/runtime/view_widget_text.zig +275 -0
- package/src/runtime/view_widget_tree.zig +843 -0
- package/src/runtime/webview_view_bridge_tests.zig +664 -0
- package/src/runtime/widget_bridge.zig +231 -0
- package/src/runtime/window_command_bridge_tests.zig +403 -0
- package/src/runtime/window_storage.zig +255 -0
- package/src/runtime/window_view_runtime.zig +727 -0
- package/src/runtime/window_views.zig +334 -0
- package/src/security/root.zig +118 -0
- package/src/tooling/android.zig +1172 -0
- package/src/tooling/assets.zig +128 -0
- package/src/tooling/buildgraph.zig +379 -0
- package/src/tooling/cef.zig +671 -0
- package/src/tooling/codesign.zig +172 -0
- package/src/tooling/components/identity_tests.zig +185 -0
- package/src/tooling/components/stepper.zig +113 -0
- package/src/tooling/components/timeline.native +27 -0
- package/src/tooling/components/timeline_item.zig +131 -0
- package/src/tooling/default_icon.icns +0 -0
- package/src/tooling/default_icon.png +0 -0
- package/src/tooling/dev.zig +172 -0
- package/src/tooling/doctor.zig +349 -0
- package/src/tooling/eject_components.zig +170 -0
- package/src/tooling/embedlib.zig +290 -0
- package/src/tooling/ios.zig +528 -0
- package/src/tooling/manifest.zig +1939 -0
- package/src/tooling/package.zig +2388 -0
- package/src/tooling/process_tree.zig +114 -0
- package/src/tooling/raw_manifest.zig +193 -0
- package/src/tooling/root.zig +22 -0
- package/src/tooling/templates.zig +3191 -0
- package/src/tooling/toolchain.zig +371 -0
- package/src/tooling/verbs.zig +204 -0
- package/src/tooling/web_engine.zig +135 -0
- package/src/tooling/xcodeproj.zig +462 -0
- package/src/window_state/root.zig +507 -0
- package/index.js +0 -2
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
const widget_model = @import("widgets.zig");
|
|
2
|
+
const event_model = @import("events.zig");
|
|
3
|
+
const text_model = @import("text.zig");
|
|
4
|
+
|
|
5
|
+
const Widget = widget_model.Widget;
|
|
6
|
+
const WidgetActions = widget_model.WidgetActions;
|
|
7
|
+
const WidgetCursor = widget_model.WidgetCursor;
|
|
8
|
+
const WidgetHit = event_model.WidgetHit;
|
|
9
|
+
const WidgetKind = widget_model.WidgetKind;
|
|
10
|
+
const WidgetState = widget_model.WidgetState;
|
|
11
|
+
const TextRange = text_model.TextRange;
|
|
12
|
+
const defaultSemanticActions = event_model.defaultSemanticActions;
|
|
13
|
+
const defaultFocusable = event_model.defaultFocusable;
|
|
14
|
+
const snapTextRange = text_model.snapTextRange;
|
|
15
|
+
|
|
16
|
+
/// The engine's cursor register follows NATIVE platform convention, not
|
|
17
|
+
/// the web's: the pointing hand is a HYPERLINK affordance, so it appears
|
|
18
|
+
/// only over link-role targets (link spans in text, or any widget given
|
|
19
|
+
/// `role = .link`). Every ordinary control — buttons, toggles, checkboxes,
|
|
20
|
+
/// menu items, tabs, list rows, sliders — keeps the arrow, exactly like
|
|
21
|
+
/// the platform's own controls do.
|
|
22
|
+
pub fn cursorForWidgetHit(hit: ?WidgetHit) WidgetCursor {
|
|
23
|
+
const target = hit orelse return .arrow;
|
|
24
|
+
if (target.role == .link and !target.state.disabled) return .pointing_hand;
|
|
25
|
+
return cursorForWidgetTarget(target.kind, target.state);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// The kind-level half of the register: I-beam over editable text (a
|
|
29
|
+
/// click places the caret, the cursor advertises it), resize arrows over
|
|
30
|
+
/// the divider affordances (`resizable`'s grip edge and `split_divider`),
|
|
31
|
+
/// arrow over everything else — including sliders, which keep the arrow
|
|
32
|
+
/// at rest AND during a drag on every native platform. The pointing hand
|
|
33
|
+
/// never comes from a kind; it is role-driven (`cursorForWidgetHit`).
|
|
34
|
+
pub fn cursorForWidgetTarget(kind: WidgetKind, state: WidgetState) WidgetCursor {
|
|
35
|
+
if (state.disabled) return .arrow;
|
|
36
|
+
return switch (kind) {
|
|
37
|
+
.input, .text_field, .search_field, .combobox, .textarea => .text,
|
|
38
|
+
.resizable, .split_divider => .resize_horizontal,
|
|
39
|
+
else => .arrow,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pub fn semanticFocusable(widget: Widget, actions: WidgetActions) bool {
|
|
44
|
+
if (widget.id == 0 or widget.state.disabled or widget.semantics.hidden) return false;
|
|
45
|
+
return widget.semantics.focusable or widget.semantics.actions.focus or actions.focus or defaultFocusable(widget);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
pub fn isFocusable(widget: Widget) bool {
|
|
49
|
+
if (widget.id == 0 or widget.state.disabled or widget.semantics.hidden) return false;
|
|
50
|
+
return widget.semantics.focusable or widget.semantics.actions.focus or defaultFocusable(widget);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
pub fn isDropTarget(widget: Widget) bool {
|
|
54
|
+
return widget.id != 0 and
|
|
55
|
+
!widget.state.disabled and
|
|
56
|
+
!widget.semantics.hidden and
|
|
57
|
+
widget.semantics.actions.drop_files;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
pub fn isDragSource(widget: Widget) bool {
|
|
61
|
+
return widget.id != 0 and
|
|
62
|
+
!widget.state.disabled and
|
|
63
|
+
!widget.semantics.hidden and
|
|
64
|
+
(widget.semantics.actions.drag or defaultSemanticActions(widget).drag);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// Widget KINDS the engine hit-tests. Kinds listed `false` are layout and
|
|
68
|
+
/// decoration only: pointer events pass through them to whatever they
|
|
69
|
+
/// contain. This is the kind-level half of hit-target-ness — the runtime's
|
|
70
|
+
/// `canvasWidgetRuntimeHitTarget`, both markup engines, and (via a name
|
|
71
|
+
/// list kept in sync by a test in ui_markup_view_tests.zig) the markup
|
|
72
|
+
/// validator all derive from it. The widget-level predicate is
|
|
73
|
+
/// `isHitTarget`: a bound press/toggle handler (stamped into
|
|
74
|
+
/// `semantics.actions` by the builder and both markup engines) makes ANY
|
|
75
|
+
/// widget a hit target, so `on_press` on a row/stack/icon works.
|
|
76
|
+
pub fn widgetKindHitTarget(kind: WidgetKind) bool {
|
|
77
|
+
return switch (kind) {
|
|
78
|
+
.row, .column, .grid, .data_grid, .table, .data_row, .list, .breadcrumb, .button_group, .pagination, .radio_group, .tabs, .toggle_group, .stack, .tooltip, .icon, .image, .avatar, .badge, .separator, .skeleton, .spinner, .chart, .split, .tree, .input_group => false,
|
|
79
|
+
.scroll_view, .accordion, .alert, .bubble, .card, .dialog, .drawer, .sheet, .resizable, .panel, .popover, .menu_surface, .dropdown_menu, .text, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .menu_item, .list_item, .data_cell, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .split_divider => true,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
pub fn isHitTarget(widget: Widget) bool {
|
|
84
|
+
if (widget.id == 0 or widget.state.disabled) return false;
|
|
85
|
+
if (widget.semantics.actions.press or widget.semantics.actions.toggle) return true;
|
|
86
|
+
if (widget.window_drag) return true;
|
|
87
|
+
// A chart with hover details opted in is hoverable (the runtime
|
|
88
|
+
// tracks the pointer over it to snap the detail card to the nearest
|
|
89
|
+
// sample). It still claims no presses — clicks fall through to the
|
|
90
|
+
// nearest claiming ancestor exactly like plain text — so this flips
|
|
91
|
+
// only where hover attributes, not where clicks land.
|
|
92
|
+
if (widget.kind == .chart) return widget.chart.hover_details;
|
|
93
|
+
return widgetKindHitTarget(widget.kind);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// Whether this widget is a live window-drag surface: a press landing
|
|
97
|
+
/// on it (or falling through to it) moves the WINDOW. Disabled widgets
|
|
98
|
+
/// stand down exactly like they do for presses.
|
|
99
|
+
pub fn isWindowDragRegion(widget: Widget) bool {
|
|
100
|
+
return widget.id != 0 and !widget.state.disabled and widget.window_drag;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// Widget KINDS that stop (claim) a press gesture themselves: interactive
|
|
104
|
+
/// controls, editable text (a click places the caret, never activates the
|
|
105
|
+
/// row around it), scroll containers, and dismissible overlay surfaces (a
|
|
106
|
+
/// click inside a dialog must never activate what it covers). Hit-target
|
|
107
|
+
/// decorations — plain text, panel, card, alert, bubble, status_bar,
|
|
108
|
+
/// progress — are deliberately NOT here: presses fall through them to the
|
|
109
|
+
/// nearest claiming ancestor (`widgetPressTargetForHit`).
|
|
110
|
+
///
|
|
111
|
+
/// See also `widgetKindDismissibleSurface` below for the overlay set the
|
|
112
|
+
/// runtime's dismissal machinery closes.
|
|
113
|
+
pub fn widgetKindClaimsPress(kind: WidgetKind) bool {
|
|
114
|
+
return switch (kind) {
|
|
115
|
+
.button,
|
|
116
|
+
.toggle_button,
|
|
117
|
+
.icon_button,
|
|
118
|
+
.select,
|
|
119
|
+
.menu_item,
|
|
120
|
+
.list_item,
|
|
121
|
+
.data_cell,
|
|
122
|
+
.segmented_control,
|
|
123
|
+
.checkbox,
|
|
124
|
+
.radio,
|
|
125
|
+
.switch_control,
|
|
126
|
+
.toggle,
|
|
127
|
+
.accordion,
|
|
128
|
+
.slider,
|
|
129
|
+
.resizable,
|
|
130
|
+
.split_divider,
|
|
131
|
+
.input,
|
|
132
|
+
.text_field,
|
|
133
|
+
.search_field,
|
|
134
|
+
.combobox,
|
|
135
|
+
.textarea,
|
|
136
|
+
.scroll_view,
|
|
137
|
+
.dialog,
|
|
138
|
+
.drawer,
|
|
139
|
+
.sheet,
|
|
140
|
+
.popover,
|
|
141
|
+
.menu_surface,
|
|
142
|
+
.dropdown_menu,
|
|
143
|
+
=> true,
|
|
144
|
+
else => false,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// Whether a press gesture stops at this widget instead of falling
|
|
149
|
+
/// through to the nearest claiming ancestor: an interactive kind
|
|
150
|
+
/// (`widgetKindClaimsPress`), or ANY widget with a bound press/toggle
|
|
151
|
+
/// handler (`on_press`/`on_toggle` stamp `semantics.actions`, and
|
|
152
|
+
/// engine-owned `command` dispatch only exists on kinds already claiming).
|
|
153
|
+
/// Disabled widgets never claim — the hit test skips them too, so a press
|
|
154
|
+
/// on a disabled control keeps today's behavior of landing on whatever is
|
|
155
|
+
/// around it.
|
|
156
|
+
pub fn widgetClaimsPress(widget: Widget) bool {
|
|
157
|
+
if (widget.id == 0 or widget.state.disabled) return false;
|
|
158
|
+
if (widget.semantics.actions.press or widget.semantics.actions.toggle) return true;
|
|
159
|
+
return widgetKindClaimsPress(widget.kind);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/// Widget KINDS the runtime's dismissal machinery closes (Escape, click
|
|
163
|
+
/// outside, automation/accessibility dismiss): the overlay surfaces. The
|
|
164
|
+
/// runtime's `canvasWidgetDismissibleSurfaceKind` delegates here and
|
|
165
|
+
/// `defaultSemanticActions` exposes the matching `dismiss` action, so the
|
|
166
|
+
/// set cannot drift. `on_dismiss` handlers only ever fire on these.
|
|
167
|
+
pub fn widgetKindDismissibleSurface(kind: WidgetKind) bool {
|
|
168
|
+
return switch (kind) {
|
|
169
|
+
.dialog,
|
|
170
|
+
.drawer,
|
|
171
|
+
.sheet,
|
|
172
|
+
.popover,
|
|
173
|
+
.menu_surface,
|
|
174
|
+
.dropdown_menu,
|
|
175
|
+
.tooltip,
|
|
176
|
+
=> true,
|
|
177
|
+
else => false,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
pub fn booleanControlSelected(widget: Widget) bool {
|
|
182
|
+
return widget.state.selected or widget.value >= 0.5;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
pub fn widgetTextSelectionRange(widget: Widget) ?TextRange {
|
|
186
|
+
if (!widgetSelectableTextKind(widget.kind)) return null;
|
|
187
|
+
if (widget.text_selection) |selection| return snapTextRange(widget.text, selection.range(widget.text.len));
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// Kinds whose `text_selection` is live state: editable text inputs plus
|
|
192
|
+
/// static `.text` widgets (read-only click-drag selection for copy).
|
|
193
|
+
pub fn widgetSelectableTextKind(kind: WidgetKind) bool {
|
|
194
|
+
return widgetTextInputKind(kind) or kind == .text;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
pub fn widgetTextCompositionRange(widget: Widget) ?TextRange {
|
|
198
|
+
if (!widgetTextInputKind(widget.kind)) return null;
|
|
199
|
+
if (widget.text_composition) |range| return snapTextRange(widget.text, range);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
pub fn widgetTextInputKind(kind: WidgetKind) bool {
|
|
204
|
+
return switch (kind) {
|
|
205
|
+
.input, .text_field, .search_field, .combobox, .textarea => true,
|
|
206
|
+
else => false,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
//! Anchored floating surfaces: geometry (placement, flip, alignment,
|
|
2
|
+
//! clamping), layout integration (no flow push, leaf-trigger children),
|
|
3
|
+
//! the late render z-pass, and hit-test hoisting/clip escape.
|
|
4
|
+
|
|
5
|
+
const support = @import("test_support.zig");
|
|
6
|
+
const std = support.std;
|
|
7
|
+
const geometry = support.geometry;
|
|
8
|
+
const canvas = support.canvas;
|
|
9
|
+
|
|
10
|
+
const Widget = canvas.Widget;
|
|
11
|
+
const WidgetLayoutNode = canvas.WidgetLayoutNode;
|
|
12
|
+
|
|
13
|
+
const window = geometry.RectF.init(0, 0, 400, 300);
|
|
14
|
+
|
|
15
|
+
fn anchoredFrame(child: Widget, anchor: canvas.WidgetAnchor, anchor_rect: geometry.RectF) geometry.RectF {
|
|
16
|
+
return canvas.anchoredWidgetFrame(child, anchor, anchor_rect, window, .{});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
test "anchored frame places below the anchor with the default offset" {
|
|
20
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
21
|
+
const frame = anchoredFrame(child, .{}, geometry.RectF.init(20, 20, 120, 28));
|
|
22
|
+
try std.testing.expectEqual(@as(f32, 20), frame.x);
|
|
23
|
+
try std.testing.expectEqual(@as(f32, 52), frame.y); // 20 + 28 + 4
|
|
24
|
+
try std.testing.expectEqual(@as(f32, 140), frame.width);
|
|
25
|
+
try std.testing.expectEqual(@as(f32, 90), frame.height);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
test "anchored frame flips above when below does not fit and above has more room" {
|
|
29
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
30
|
+
// Anchor near the bottom: below has 300-190-4 = 106... use a lower one.
|
|
31
|
+
const frame = anchoredFrame(child, .{}, geometry.RectF.init(20, 250, 120, 28));
|
|
32
|
+
// below space = 300 - 278 - 4 = 18 < 90; above space = 250 - 4 = 246.
|
|
33
|
+
try std.testing.expectEqual(@as(f32, 250 - 4 - 90), frame.y);
|
|
34
|
+
try std.testing.expectEqual(@as(f32, 90), frame.height);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
test "anchored frame prefers above and flips below symmetrically" {
|
|
38
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 90) };
|
|
39
|
+
const above = anchoredFrame(child, .{ .placement = .above }, geometry.RectF.init(20, 200, 120, 28));
|
|
40
|
+
try std.testing.expectEqual(@as(f32, 200 - 4 - 90), above.y);
|
|
41
|
+
// Anchor near the top: above has no room, below does — flip.
|
|
42
|
+
const flipped = anchoredFrame(child, .{ .placement = .above }, geometry.RectF.init(20, 10, 120, 28));
|
|
43
|
+
try std.testing.expectEqual(@as(f32, 10 + 28 + 4), flipped.y);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
test "anchored frame clamps height to the chosen side's space" {
|
|
47
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 140, 500) };
|
|
48
|
+
const frame = anchoredFrame(child, .{}, geometry.RectF.init(20, 20, 120, 28));
|
|
49
|
+
// below space = 300 - 48 - 4 = 248.
|
|
50
|
+
try std.testing.expectEqual(@as(f32, 248), frame.height);
|
|
51
|
+
try std.testing.expectEqual(@as(f32, 52), frame.y);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
test "anchored frame alignment start end and stretch" {
|
|
55
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 60, 40) };
|
|
56
|
+
const anchor_rect = geometry.RectF.init(100, 20, 120, 28);
|
|
57
|
+
const start = anchoredFrame(child, .{ .alignment = .start }, anchor_rect);
|
|
58
|
+
try std.testing.expectEqual(@as(f32, 100), start.x);
|
|
59
|
+
try std.testing.expectEqual(@as(f32, 60), start.width);
|
|
60
|
+
const end = anchoredFrame(child, .{ .alignment = .end }, anchor_rect);
|
|
61
|
+
try std.testing.expectEqual(@as(f32, 220 - 60), end.x);
|
|
62
|
+
// stretch widens to at least the anchor's width.
|
|
63
|
+
const stretch = anchoredFrame(child, .{ .alignment = .stretch }, anchor_rect);
|
|
64
|
+
try std.testing.expectEqual(@as(f32, 100), stretch.x);
|
|
65
|
+
try std.testing.expectEqual(@as(f32, 120), stretch.width);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
test "anchored frame clamps into the window horizontally and by offset" {
|
|
69
|
+
const child = Widget{ .kind = .dropdown_menu, .frame = geometry.RectF.init(0, 0, 200, 40) };
|
|
70
|
+
// end-aligned near the left edge would go negative; clamps to 0.
|
|
71
|
+
const frame = anchoredFrame(child, .{ .alignment = .end, .offset = 10 }, geometry.RectF.init(4, 20, 40, 28));
|
|
72
|
+
try std.testing.expectEqual(@as(f32, 0), frame.x);
|
|
73
|
+
try std.testing.expectEqual(@as(f32, 58), frame.y); // 20 + 28 + 10
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
test "anchored children consume no flow space and float against the parent" {
|
|
77
|
+
const menu_items = [_]Widget{.{ .id = 4, .kind = .menu_item, .text = "One" }};
|
|
78
|
+
const dropdown = Widget{
|
|
79
|
+
.id = 3,
|
|
80
|
+
.kind = .dropdown_menu,
|
|
81
|
+
.frame = geometry.RectF.init(0, 0, 140, 90),
|
|
82
|
+
.layout = .{ .anchor = .{} },
|
|
83
|
+
.children = &menu_items,
|
|
84
|
+
};
|
|
85
|
+
const trigger = Widget{ .id = 2, .kind = .select, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Pick" };
|
|
86
|
+
const wrap_children = [_]Widget{ trigger, dropdown };
|
|
87
|
+
const wrap = Widget{ .id = 10, .kind = .stack, .frame = geometry.RectF.init(0, 0, 0, 28), .children = &wrap_children };
|
|
88
|
+
const after = Widget{ .id = 5, .kind = .button, .text = "After" };
|
|
89
|
+
const column_children = [_]Widget{ wrap, after };
|
|
90
|
+
const column = Widget{ .id = 1, .kind = .column, .layout = .{ .gap = 8 }, .children = &column_children };
|
|
91
|
+
|
|
92
|
+
var nodes: [8]WidgetLayoutNode = undefined;
|
|
93
|
+
const layout = try canvas.layoutWidgetTree(column, window, &nodes);
|
|
94
|
+
|
|
95
|
+
const wrap_frame = layout.findById(10).?.frame;
|
|
96
|
+
const dropdown_frame = layout.findById(3).?.frame;
|
|
97
|
+
const after_frame = layout.findById(5).?.frame;
|
|
98
|
+
// The sibling after the trigger stack flows as if the dropdown did
|
|
99
|
+
// not exist: directly below the 28-high stack plus the gap.
|
|
100
|
+
try std.testing.expectEqual(wrap_frame.maxY() + 8, after_frame.y);
|
|
101
|
+
// The dropdown floats below its parent (the trigger stack).
|
|
102
|
+
try std.testing.expectEqual(wrap_frame.maxY() + 4, dropdown_frame.y);
|
|
103
|
+
try std.testing.expectEqual(@as(f32, 90), dropdown_frame.height);
|
|
104
|
+
// Its menu item lays out inside the floating frame.
|
|
105
|
+
const item_frame = layout.findById(4).?.frame;
|
|
106
|
+
try std.testing.expect(item_frame.y >= dropdown_frame.y);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
test "leaf trigger kinds lay out their anchored children" {
|
|
110
|
+
const menu_items = [_]Widget{.{ .id = 4, .kind = .menu_item, .text = "One" }};
|
|
111
|
+
const dropdown = Widget{
|
|
112
|
+
.id = 3,
|
|
113
|
+
.kind = .dropdown_menu,
|
|
114
|
+
.frame = geometry.RectF.init(0, 0, 140, 90),
|
|
115
|
+
.layout = .{ .anchor = .{ .alignment = .stretch } },
|
|
116
|
+
.children = &menu_items,
|
|
117
|
+
};
|
|
118
|
+
const select_children = [_]Widget{dropdown};
|
|
119
|
+
const select = Widget{
|
|
120
|
+
.id = 2,
|
|
121
|
+
.kind = .select,
|
|
122
|
+
.frame = geometry.RectF.init(30, 40, 180, 28),
|
|
123
|
+
.text = "Pick",
|
|
124
|
+
.children = &select_children,
|
|
125
|
+
};
|
|
126
|
+
const root_children = [_]Widget{select};
|
|
127
|
+
const root = Widget{ .id = 1, .kind = .stack, .children = &root_children };
|
|
128
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
129
|
+
const layout = try canvas.layoutWidgetTree(root, window, &nodes);
|
|
130
|
+
const dropdown_node = layout.findById(3) orelse return error.TestUnexpectedResult;
|
|
131
|
+
// Anchored below the select, stretched to its width.
|
|
132
|
+
try std.testing.expectEqual(@as(f32, 40 + 28 + 4), dropdown_node.frame.y);
|
|
133
|
+
try std.testing.expectEqual(@as(f32, 180), dropdown_node.frame.width);
|
|
134
|
+
try std.testing.expect(layout.findById(4) != null);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// The shared fixture for z-order/clip tests: a scroll pane whose content
|
|
138
|
+
/// holds the trigger + anchored dropdown, and a LATER sibling panel the
|
|
139
|
+
/// dropdown overlaps. In-tree paint order would put the panel above the
|
|
140
|
+
/// dropdown and the scroll clip would crop it; hoisting must do neither.
|
|
141
|
+
fn buildOverlapFixture(nodes: []WidgetLayoutNode) !canvas.WidgetLayoutTree {
|
|
142
|
+
const menu_items = [_]Widget{.{ .id = 4, .kind = .menu_item, .frame = geometry.RectF.init(0, 0, 0, 24), .text = "One" }};
|
|
143
|
+
const dropdown = Widget{
|
|
144
|
+
.id = 3,
|
|
145
|
+
.kind = .dropdown_menu,
|
|
146
|
+
.frame = geometry.RectF.init(0, 0, 140, 120),
|
|
147
|
+
.layout = .{ .anchor = .{} },
|
|
148
|
+
.children = &menu_items,
|
|
149
|
+
};
|
|
150
|
+
const trigger = Widget{ .id = 2, .kind = .select, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Pick" };
|
|
151
|
+
const wrap_children = [_]Widget{ trigger, dropdown };
|
|
152
|
+
const wrap = Widget{ .id = 10, .kind = .stack, .frame = geometry.RectF.init(0, 0, 0, 28), .children = &wrap_children };
|
|
153
|
+
const scroll_children = [_]Widget{wrap};
|
|
154
|
+
// Short scroll viewport: the dropdown (120 tall, below a 28-high
|
|
155
|
+
// trigger) extends far past its 40-high frame.
|
|
156
|
+
const scroll = Widget{ .id = 20, .kind = .scroll_view, .frame = geometry.RectF.init(0, 0, 200, 40), .children = &scroll_children };
|
|
157
|
+
const after = Widget{ .id = 5, .kind = .button, .frame = geometry.RectF.init(0, 60, 200, 40), .text = "After" };
|
|
158
|
+
const root_children = [_]Widget{ scroll, after };
|
|
159
|
+
const root = Widget{ .id = 1, .kind = .stack, .children = &root_children };
|
|
160
|
+
return canvas.layoutWidgetTree(root, window, nodes);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fn firstCommandIndexForWidget(list: canvas.DisplayList, widget_id: canvas.ObjectId) ?usize {
|
|
164
|
+
for (list.commands, 0..) |command, index| {
|
|
165
|
+
const id = command.objectId() orelse continue;
|
|
166
|
+
// Widget part ids pack `widget_id * 16 + slot`.
|
|
167
|
+
if (id / 16 == widget_id) return index;
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
test "anchored surfaces render in a late z-pass above later siblings and outside ancestor clips" {
|
|
173
|
+
var nodes: [8]WidgetLayoutNode = undefined;
|
|
174
|
+
const layout = try buildOverlapFixture(&nodes);
|
|
175
|
+
|
|
176
|
+
var commands: [128]canvas.CanvasCommand = undefined;
|
|
177
|
+
var builder = canvas.Builder.init(&commands);
|
|
178
|
+
try layout.emitDisplayList(&builder, .{});
|
|
179
|
+
const list = builder.displayList();
|
|
180
|
+
|
|
181
|
+
const dropdown_index = firstCommandIndexForWidget(list, 3) orelse return error.TestUnexpectedResult;
|
|
182
|
+
const item_index = firstCommandIndexForWidget(list, 4) orelse return error.TestUnexpectedResult;
|
|
183
|
+
const after_index = firstCommandIndexForWidget(list, 5) orelse return error.TestUnexpectedResult;
|
|
184
|
+
// The dropdown paints AFTER the later sibling (topmost), and so do
|
|
185
|
+
// its items.
|
|
186
|
+
try std.testing.expect(dropdown_index > after_index);
|
|
187
|
+
try std.testing.expect(item_index > after_index);
|
|
188
|
+
// The scroll clip closes BEFORE the dropdown paints: no clip command
|
|
189
|
+
// is open at the dropdown's position (its commands sit outside every
|
|
190
|
+
// push/pop pair).
|
|
191
|
+
var open_clips: isize = 0;
|
|
192
|
+
for (list.commands[0..dropdown_index]) |command| {
|
|
193
|
+
switch (command) {
|
|
194
|
+
.push_clip => open_clips += 1,
|
|
195
|
+
.pop_clip => open_clips -= 1,
|
|
196
|
+
else => {},
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
try std.testing.expectEqual(@as(isize, 0), open_clips);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
test "anchored surfaces hit-test topmost and escape ancestor clips" {
|
|
203
|
+
var nodes: [8]WidgetLayoutNode = undefined;
|
|
204
|
+
const layout = try buildOverlapFixture(&nodes);
|
|
205
|
+
|
|
206
|
+
const dropdown_frame = layout.findById(3).?.frame;
|
|
207
|
+
// The dropdown starts below the trigger (y = 32) and extends past the
|
|
208
|
+
// scroll viewport (40) over the later button (y = 60..100).
|
|
209
|
+
try std.testing.expect(dropdown_frame.maxY() > 60);
|
|
210
|
+
const inside_overlay = geometry.PointF.init(dropdown_frame.x + 8, 70);
|
|
211
|
+
const hit = layout.hitTest(inside_overlay) orelse return error.TestUnexpectedResult;
|
|
212
|
+
// The overlay wins over the button it overlaps, and the point is
|
|
213
|
+
// OUTSIDE the scroll ancestor's 40-high frame — the clip escape.
|
|
214
|
+
try std.testing.expect(hit.id == 3 or hit.id == 4);
|
|
215
|
+
// Next to the overlay the button hits as usual.
|
|
216
|
+
const beside = geometry.PointF.init(dropdown_frame.maxX() + 20, 70);
|
|
217
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 5), layout.hitTest(beside).?.id);
|
|
218
|
+
// Focus targets inside the overlay stay live outside the scroll
|
|
219
|
+
// ancestor's bounds.
|
|
220
|
+
try std.testing.expect(layout.focusTargetById(4) != null);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
test "hidden ancestors hide their anchored surfaces" {
|
|
224
|
+
const dropdown = Widget{
|
|
225
|
+
.id = 3,
|
|
226
|
+
.kind = .dropdown_menu,
|
|
227
|
+
.frame = geometry.RectF.init(0, 0, 140, 90),
|
|
228
|
+
.layout = .{ .anchor = .{} },
|
|
229
|
+
};
|
|
230
|
+
const wrap_children = [_]Widget{dropdown};
|
|
231
|
+
const wrap = Widget{
|
|
232
|
+
.id = 10,
|
|
233
|
+
.kind = .stack,
|
|
234
|
+
.frame = geometry.RectF.init(0, 0, 120, 28),
|
|
235
|
+
.semantics = .{ .hidden = true },
|
|
236
|
+
.children = &wrap_children,
|
|
237
|
+
};
|
|
238
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
239
|
+
const layout = try canvas.layoutWidgetTree(wrap, window, &nodes);
|
|
240
|
+
|
|
241
|
+
var commands: [64]canvas.CanvasCommand = undefined;
|
|
242
|
+
var builder = canvas.Builder.init(&commands);
|
|
243
|
+
try layout.emitDisplayList(&builder, .{});
|
|
244
|
+
try std.testing.expectEqual(@as(?usize, null), firstCommandIndexForWidget(builder.displayList(), 3));
|
|
245
|
+
try std.testing.expect(layout.hitTest(geometry.PointF.init(30, 60)) == null);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
test "anchored children do not grow their parent's intrinsic size" {
|
|
249
|
+
const dropdown = Widget{
|
|
250
|
+
.id = 3,
|
|
251
|
+
.kind = .dropdown_menu,
|
|
252
|
+
.frame = geometry.RectF.init(0, 0, 300, 200),
|
|
253
|
+
.layout = .{ .anchor = .{} },
|
|
254
|
+
};
|
|
255
|
+
const label = Widget{ .id = 2, .kind = .text, .text = "Pick" };
|
|
256
|
+
const with_children = [_]Widget{ label, dropdown };
|
|
257
|
+
const without_children = [_]Widget{label};
|
|
258
|
+
const with = Widget{ .kind = .stack, .children = &with_children };
|
|
259
|
+
const without = Widget{ .kind = .stack, .children = &without_children };
|
|
260
|
+
const with_size = canvas.intrinsicWidgetSize(with, .{});
|
|
261
|
+
const without_size = canvas.intrinsicWidgetSize(without, .{});
|
|
262
|
+
try std.testing.expectEqual(without_size.width, with_size.width);
|
|
263
|
+
try std.testing.expectEqual(without_size.height, with_size.height);
|
|
264
|
+
}
|