@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,2129 @@
|
|
|
1
|
+
const support = @import("test_support.zig");
|
|
2
|
+
const std = support.std;
|
|
3
|
+
const geometry = support.geometry;
|
|
4
|
+
const canvas = support.canvas;
|
|
5
|
+
const drawing_model = support.drawing_model;
|
|
6
|
+
const text_model = support.text_model;
|
|
7
|
+
const render_model = support.render_model;
|
|
8
|
+
const event_model = support.event_model;
|
|
9
|
+
const equality_model = support.equality_model;
|
|
10
|
+
const widget_runtime = support.widget_runtime;
|
|
11
|
+
const Error = support.Error;
|
|
12
|
+
const ObjectId = support.ObjectId;
|
|
13
|
+
const ImageId = support.ImageId;
|
|
14
|
+
const FontId = support.FontId;
|
|
15
|
+
const default_sans_font_id = support.default_sans_font_id;
|
|
16
|
+
const default_mono_font_id = support.default_mono_font_id;
|
|
17
|
+
const default_sans_font_family = support.default_sans_font_family;
|
|
18
|
+
const default_mono_font_family = support.default_mono_font_family;
|
|
19
|
+
const default_glyph_atlas_cache_retention_frames = support.default_glyph_atlas_cache_retention_frames;
|
|
20
|
+
const default_text_layout_cache_retention_frames = support.default_text_layout_cache_retention_frames;
|
|
21
|
+
const Color = support.Color;
|
|
22
|
+
const Affine = support.Affine;
|
|
23
|
+
const Radius = support.Radius;
|
|
24
|
+
const GradientStop = support.GradientStop;
|
|
25
|
+
const LinearGradient = support.LinearGradient;
|
|
26
|
+
const Fill = support.Fill;
|
|
27
|
+
const Stroke = support.Stroke;
|
|
28
|
+
const Clip = support.Clip;
|
|
29
|
+
const FillRect = support.FillRect;
|
|
30
|
+
const StrokeRect = support.StrokeRect;
|
|
31
|
+
const FillRoundedRect = support.FillRoundedRect;
|
|
32
|
+
const Line = support.Line;
|
|
33
|
+
const PathVerb = support.PathVerb;
|
|
34
|
+
const PathElement = support.PathElement;
|
|
35
|
+
const FillPath = support.FillPath;
|
|
36
|
+
const StrokePath = support.StrokePath;
|
|
37
|
+
const ImageFit = support.ImageFit;
|
|
38
|
+
const ImageSampling = support.ImageSampling;
|
|
39
|
+
const DrawImage = support.DrawImage;
|
|
40
|
+
const Shadow = support.Shadow;
|
|
41
|
+
const Blur = support.Blur;
|
|
42
|
+
const Glyph = support.Glyph;
|
|
43
|
+
const GlyphAtlasKey = support.GlyphAtlasKey;
|
|
44
|
+
const GlyphAtlasEntry = support.GlyphAtlasEntry;
|
|
45
|
+
const GlyphAtlasPlan = support.GlyphAtlasPlan;
|
|
46
|
+
const GlyphAtlasPlanner = support.GlyphAtlasPlanner;
|
|
47
|
+
const GlyphAtlasCacheEntry = support.GlyphAtlasCacheEntry;
|
|
48
|
+
const GlyphAtlasCacheActionKind = support.GlyphAtlasCacheActionKind;
|
|
49
|
+
const GlyphAtlasCacheAction = support.GlyphAtlasCacheAction;
|
|
50
|
+
const GlyphAtlasCachePlan = support.GlyphAtlasCachePlan;
|
|
51
|
+
const GlyphAtlasCachePlanner = support.GlyphAtlasCachePlanner;
|
|
52
|
+
const DrawText = support.DrawText;
|
|
53
|
+
const TextWrap = support.TextWrap;
|
|
54
|
+
const TextAlign = support.TextAlign;
|
|
55
|
+
const TextLayoutOptions = support.TextLayoutOptions;
|
|
56
|
+
const TextLine = support.TextLine;
|
|
57
|
+
const TextLayout = support.TextLayout;
|
|
58
|
+
const TextLayoutKey = support.TextLayoutKey;
|
|
59
|
+
const TextLayoutPlan = support.TextLayoutPlan;
|
|
60
|
+
const TextLayoutPlanSet = support.TextLayoutPlanSet;
|
|
61
|
+
const TextLayoutPlanner = support.TextLayoutPlanner;
|
|
62
|
+
const TextLayoutCacheEntry = support.TextLayoutCacheEntry;
|
|
63
|
+
const TextLayoutCacheActionKind = support.TextLayoutCacheActionKind;
|
|
64
|
+
const TextLayoutCacheAction = support.TextLayoutCacheAction;
|
|
65
|
+
const TextLayoutCachePlan = support.TextLayoutCachePlan;
|
|
66
|
+
const TextLayoutCachePlanner = support.TextLayoutCachePlanner;
|
|
67
|
+
const TextRange = support.TextRange;
|
|
68
|
+
const TextSelectionRect = support.TextSelectionRect;
|
|
69
|
+
const TextSelection = support.TextSelection;
|
|
70
|
+
const TextCaretDirection = support.TextCaretDirection;
|
|
71
|
+
const TextCaretMove = support.TextCaretMove;
|
|
72
|
+
const TextCompositionUpdate = support.TextCompositionUpdate;
|
|
73
|
+
const TextInputEvent = support.TextInputEvent;
|
|
74
|
+
const TextEditState = support.TextEditState;
|
|
75
|
+
const CanvasCommand = support.CanvasCommand;
|
|
76
|
+
const CommandRef = support.CommandRef;
|
|
77
|
+
const DiffKind = support.DiffKind;
|
|
78
|
+
const DiffChange = support.DiffChange;
|
|
79
|
+
const Builder = support.Builder;
|
|
80
|
+
const max_render_state_stack = support.max_render_state_stack;
|
|
81
|
+
const RenderState = support.RenderState;
|
|
82
|
+
const RenderCommand = support.RenderCommand;
|
|
83
|
+
const CanvasRenderOverride = support.CanvasRenderOverride;
|
|
84
|
+
const CanvasRenderAnimation = support.CanvasRenderAnimation;
|
|
85
|
+
const applyRenderOverrides = support.applyRenderOverrides;
|
|
86
|
+
const renderOverrideDirtyBounds = support.renderOverrideDirtyBounds;
|
|
87
|
+
const RenderPlan = support.RenderPlan;
|
|
88
|
+
const RenderPlanner = support.RenderPlanner;
|
|
89
|
+
const RenderPipelineKind = support.RenderPipelineKind;
|
|
90
|
+
const RenderBatch = support.RenderBatch;
|
|
91
|
+
const RenderBatchPlanner = support.RenderBatchPlanner;
|
|
92
|
+
const RenderBatchPlan = support.RenderBatchPlan;
|
|
93
|
+
const RenderPipelineCacheEntry = support.RenderPipelineCacheEntry;
|
|
94
|
+
const RenderPipelineCacheActionKind = support.RenderPipelineCacheActionKind;
|
|
95
|
+
const RenderPipelineCacheAction = support.RenderPipelineCacheAction;
|
|
96
|
+
const RenderPipelineCachePlanner = support.RenderPipelineCachePlanner;
|
|
97
|
+
const RenderPipelineCachePlan = support.RenderPipelineCachePlan;
|
|
98
|
+
const RenderPathGeometryKind = support.RenderPathGeometryKind;
|
|
99
|
+
const RenderPathGeometry = support.RenderPathGeometry;
|
|
100
|
+
const RenderPathGeometryPlan = support.RenderPathGeometryPlan;
|
|
101
|
+
const RenderPathGeometryPlanner = support.RenderPathGeometryPlanner;
|
|
102
|
+
const RenderPathGeometryKey = support.RenderPathGeometryKey;
|
|
103
|
+
const RenderPathGeometryCacheEntry = support.RenderPathGeometryCacheEntry;
|
|
104
|
+
const RenderPathGeometryCacheActionKind = support.RenderPathGeometryCacheActionKind;
|
|
105
|
+
const RenderPathGeometryCacheAction = support.RenderPathGeometryCacheAction;
|
|
106
|
+
const RenderPathGeometryCachePlan = support.RenderPathGeometryCachePlan;
|
|
107
|
+
const RenderPathGeometryCachePlanner = support.RenderPathGeometryCachePlanner;
|
|
108
|
+
const RenderImage = support.RenderImage;
|
|
109
|
+
const RenderImagePlan = support.RenderImagePlan;
|
|
110
|
+
const RenderImagePlanner = support.RenderImagePlanner;
|
|
111
|
+
const RenderImageKey = support.RenderImageKey;
|
|
112
|
+
const RenderImageCacheEntry = support.RenderImageCacheEntry;
|
|
113
|
+
const RenderImageCacheActionKind = support.RenderImageCacheActionKind;
|
|
114
|
+
const RenderImageCacheAction = support.RenderImageCacheAction;
|
|
115
|
+
const RenderImageCachePlan = support.RenderImageCachePlan;
|
|
116
|
+
const RenderImageCachePlanner = support.RenderImageCachePlanner;
|
|
117
|
+
const RenderResourceKind = support.RenderResourceKind;
|
|
118
|
+
const RenderResource = support.RenderResource;
|
|
119
|
+
const RenderResourcePlan = support.RenderResourcePlan;
|
|
120
|
+
const RenderResourcePlanner = support.RenderResourcePlanner;
|
|
121
|
+
const RenderResourceKey = support.RenderResourceKey;
|
|
122
|
+
const RenderResourceCacheEntry = support.RenderResourceCacheEntry;
|
|
123
|
+
const RenderResourceCacheActionKind = support.RenderResourceCacheActionKind;
|
|
124
|
+
const RenderResourceCacheAction = support.RenderResourceCacheAction;
|
|
125
|
+
const RenderResourceCachePlan = support.RenderResourceCachePlan;
|
|
126
|
+
const RenderResourceCachePlanner = support.RenderResourceCachePlanner;
|
|
127
|
+
const RenderLayer = support.RenderLayer;
|
|
128
|
+
const RenderLayerPlan = support.RenderLayerPlan;
|
|
129
|
+
const RenderLayerPlanner = support.RenderLayerPlanner;
|
|
130
|
+
const RenderLayerKey = support.RenderLayerKey;
|
|
131
|
+
const RenderLayerCacheEntry = support.RenderLayerCacheEntry;
|
|
132
|
+
const RenderLayerCacheActionKind = support.RenderLayerCacheActionKind;
|
|
133
|
+
const RenderLayerCacheAction = support.RenderLayerCacheAction;
|
|
134
|
+
const RenderLayerCachePlan = support.RenderLayerCachePlan;
|
|
135
|
+
const RenderLayerCachePlanner = support.RenderLayerCachePlanner;
|
|
136
|
+
const VisualEffectKind = support.VisualEffectKind;
|
|
137
|
+
const VisualEffect = support.VisualEffect;
|
|
138
|
+
const VisualEffectPlan = support.VisualEffectPlan;
|
|
139
|
+
const VisualEffectPlanner = support.VisualEffectPlanner;
|
|
140
|
+
const VisualEffectKey = support.VisualEffectKey;
|
|
141
|
+
const VisualEffectCacheEntry = support.VisualEffectCacheEntry;
|
|
142
|
+
const VisualEffectCacheActionKind = support.VisualEffectCacheActionKind;
|
|
143
|
+
const VisualEffectCacheAction = support.VisualEffectCacheAction;
|
|
144
|
+
const VisualEffectCachePlan = support.VisualEffectCachePlan;
|
|
145
|
+
const VisualEffectCachePlanner = support.VisualEffectCachePlanner;
|
|
146
|
+
const CanvasFrameOptions = support.CanvasFrameOptions;
|
|
147
|
+
const CanvasFrameStorage = support.CanvasFrameStorage;
|
|
148
|
+
const CanvasFrameBudget = support.CanvasFrameBudget;
|
|
149
|
+
const CanvasFrameBudgetStatus = support.CanvasFrameBudgetStatus;
|
|
150
|
+
const CanvasFrameDiagnostics = support.CanvasFrameDiagnostics;
|
|
151
|
+
const CanvasFrameProfileRisk = support.CanvasFrameProfileRisk;
|
|
152
|
+
const CanvasFrameProfile = support.CanvasFrameProfile;
|
|
153
|
+
const CanvasRenderPass = support.CanvasRenderPass;
|
|
154
|
+
const CanvasFrame = support.CanvasFrame;
|
|
155
|
+
const buildCanvasFrame = support.buildCanvasFrame;
|
|
156
|
+
const CanvasRenderPassLoadAction = support.CanvasRenderPassLoadAction;
|
|
157
|
+
const RenderEncoderBeginPass = support.RenderEncoderBeginPass;
|
|
158
|
+
const RenderEncoderCommand = support.RenderEncoderCommand;
|
|
159
|
+
const RenderEncoderPlan = support.RenderEncoderPlan;
|
|
160
|
+
const RenderEncoderPlanner = support.RenderEncoderPlanner;
|
|
161
|
+
const CanvasGpuCommandKind = support.CanvasGpuCommandKind;
|
|
162
|
+
const CanvasGpuRoundedRect = support.CanvasGpuRoundedRect;
|
|
163
|
+
const CanvasGpuStrokeRect = support.CanvasGpuStrokeRect;
|
|
164
|
+
const CanvasGpuLine = support.CanvasGpuLine;
|
|
165
|
+
const CanvasGpuShape = support.CanvasGpuShape;
|
|
166
|
+
const CanvasGpuPaint = support.CanvasGpuPaint;
|
|
167
|
+
const CanvasGpuImage = support.CanvasGpuImage;
|
|
168
|
+
const CanvasGpuText = support.CanvasGpuText;
|
|
169
|
+
const CanvasGpuShadow = support.CanvasGpuShadow;
|
|
170
|
+
const CanvasGpuBlur = support.CanvasGpuBlur;
|
|
171
|
+
const CanvasGpuEffect = support.CanvasGpuEffect;
|
|
172
|
+
const CanvasGpuCommand = support.CanvasGpuCommand;
|
|
173
|
+
const CanvasGpuPacket = support.CanvasGpuPacket;
|
|
174
|
+
const CanvasGpuPacketSummary = support.CanvasGpuPacketSummary;
|
|
175
|
+
const CanvasGpuPacketPlanner = support.CanvasGpuPacketPlanner;
|
|
176
|
+
const ReferenceImage = support.ReferenceImage;
|
|
177
|
+
const ReferenceRenderSurface = support.ReferenceRenderSurface;
|
|
178
|
+
const Density = support.Density;
|
|
179
|
+
const Easing = support.Easing;
|
|
180
|
+
const ColorScheme = support.ColorScheme;
|
|
181
|
+
const ColorContrast = support.ColorContrast;
|
|
182
|
+
const ThemeOptions = support.ThemeOptions;
|
|
183
|
+
const ColorTokens = support.ColorTokens;
|
|
184
|
+
const FontFamily = support.FontFamily;
|
|
185
|
+
const TypographyTokens = support.TypographyTokens;
|
|
186
|
+
const SpacingTokens = support.SpacingTokens;
|
|
187
|
+
const RadiusTokens = support.RadiusTokens;
|
|
188
|
+
const StrokeTokens = support.StrokeTokens;
|
|
189
|
+
const ShadowToken = support.ShadowToken;
|
|
190
|
+
const ShadowTokens = support.ShadowTokens;
|
|
191
|
+
const BlurTokens = support.BlurTokens;
|
|
192
|
+
const MotionDuration = support.MotionDuration;
|
|
193
|
+
const MotionAnimationOptions = support.MotionAnimationOptions;
|
|
194
|
+
const MotionTokens = support.MotionTokens;
|
|
195
|
+
const SpringToken = support.SpringToken;
|
|
196
|
+
const BlurTokenRef = support.BlurTokenRef;
|
|
197
|
+
const ScrollPhysics = support.ScrollPhysics;
|
|
198
|
+
const ScrollState = support.ScrollState;
|
|
199
|
+
const VirtualListOptions = support.VirtualListOptions;
|
|
200
|
+
const VirtualListRange = support.VirtualListRange;
|
|
201
|
+
const virtualListRange = support.virtualListRange;
|
|
202
|
+
const LayerTokens = support.LayerTokens;
|
|
203
|
+
const PixelSnapTokens = support.PixelSnapTokens;
|
|
204
|
+
const ControlVisualTokens = support.ControlVisualTokens;
|
|
205
|
+
const ControlTokens = support.ControlTokens;
|
|
206
|
+
const ColorTokenOverrides = support.ColorTokenOverrides;
|
|
207
|
+
const TypographyTokenOverrides = support.TypographyTokenOverrides;
|
|
208
|
+
const SpacingTokenOverrides = support.SpacingTokenOverrides;
|
|
209
|
+
const RadiusTokenOverrides = support.RadiusTokenOverrides;
|
|
210
|
+
const StrokeTokenOverrides = support.StrokeTokenOverrides;
|
|
211
|
+
const ShadowTokenOverrides = support.ShadowTokenOverrides;
|
|
212
|
+
const ShadowTokensOverrides = support.ShadowTokensOverrides;
|
|
213
|
+
const BlurTokenOverrides = support.BlurTokenOverrides;
|
|
214
|
+
const SpringTokenOverrides = support.SpringTokenOverrides;
|
|
215
|
+
const MotionTokenOverrides = support.MotionTokenOverrides;
|
|
216
|
+
const ScrollPhysicsOverrides = support.ScrollPhysicsOverrides;
|
|
217
|
+
const LayerTokenOverrides = support.LayerTokenOverrides;
|
|
218
|
+
const PixelSnapTokenOverrides = support.PixelSnapTokenOverrides;
|
|
219
|
+
const ControlVisualTokenOverrides = support.ControlVisualTokenOverrides;
|
|
220
|
+
const ControlTokenOverrides = support.ControlTokenOverrides;
|
|
221
|
+
const DesignTokenOverrides = support.DesignTokenOverrides;
|
|
222
|
+
const DesignTokens = support.DesignTokens;
|
|
223
|
+
const WidgetKind = support.WidgetKind;
|
|
224
|
+
const WidgetCursor = support.WidgetCursor;
|
|
225
|
+
const WidgetState = support.WidgetState;
|
|
226
|
+
const WidgetRenderState = support.WidgetRenderState;
|
|
227
|
+
const WidgetMainAlignment = support.WidgetMainAlignment;
|
|
228
|
+
const WidgetCrossAlignment = support.WidgetCrossAlignment;
|
|
229
|
+
const WidgetLayoutStyle = support.WidgetLayoutStyle;
|
|
230
|
+
const WidgetStyle = support.WidgetStyle;
|
|
231
|
+
const WidgetVariant = support.WidgetVariant;
|
|
232
|
+
const WidgetSize = support.WidgetSize;
|
|
233
|
+
const WidgetRole = support.WidgetRole;
|
|
234
|
+
const BuiltinComponentStyle = support.BuiltinComponentStyle;
|
|
235
|
+
const BuiltinComponentKind = support.BuiltinComponentKind;
|
|
236
|
+
const builtin_component_kinds = support.builtin_component_kinds;
|
|
237
|
+
const builtin_component_names = support.builtin_component_names;
|
|
238
|
+
const BuiltinComponentDescriptor = support.BuiltinComponentDescriptor;
|
|
239
|
+
const builtinComponentCount = support.builtinComponentCount;
|
|
240
|
+
const builtinComponentName = support.builtinComponentName;
|
|
241
|
+
const builtinComponentDescriptor = support.builtinComponentDescriptor;
|
|
242
|
+
const WidgetActions = support.WidgetActions;
|
|
243
|
+
const WidgetSemantics = support.WidgetSemantics;
|
|
244
|
+
const Widget = support.Widget;
|
|
245
|
+
const BuiltinComponentOptions = support.BuiltinComponentOptions;
|
|
246
|
+
const WidgetCommandPart = support.WidgetCommandPart;
|
|
247
|
+
const BuiltinSurfacePlacementOptions = support.BuiltinSurfacePlacementOptions;
|
|
248
|
+
const BuiltinSurfaceBackdropOptions = support.BuiltinSurfaceBackdropOptions;
|
|
249
|
+
const BuiltinStatusBarOptions = support.BuiltinStatusBarOptions;
|
|
250
|
+
const BuiltinSurfaceEnterAnimationOptions = support.BuiltinSurfaceEnterAnimationOptions;
|
|
251
|
+
const builtinComponentWidget = support.builtinComponentWidget;
|
|
252
|
+
const widgetCommandPartId = support.widgetCommandPartId;
|
|
253
|
+
const builtinSurfaceBackdropWidget = support.builtinSurfaceBackdropWidget;
|
|
254
|
+
const builtinStatusBarWidget = support.builtinStatusBarWidget;
|
|
255
|
+
const builtinSurfaceFrame = support.builtinSurfaceFrame;
|
|
256
|
+
const appendBuiltinSurfaceEnterAnimations = support.appendBuiltinSurfaceEnterAnimations;
|
|
257
|
+
const builtinSurfaceEnterOffset = support.builtinSurfaceEnterOffset;
|
|
258
|
+
const max_widget_depth = support.max_widget_depth;
|
|
259
|
+
const max_widget_text_range_rects = support.max_widget_text_range_rects;
|
|
260
|
+
const WidgetLayoutNode = support.WidgetLayoutNode;
|
|
261
|
+
const WidgetHit = support.WidgetHit;
|
|
262
|
+
const WidgetPointerPhase = support.WidgetPointerPhase;
|
|
263
|
+
const WidgetPointerEvent = support.WidgetPointerEvent;
|
|
264
|
+
const WidgetKeyboardPhase = support.WidgetKeyboardPhase;
|
|
265
|
+
const WidgetKeyboardModifiers = support.WidgetKeyboardModifiers;
|
|
266
|
+
const WidgetKeyboardEvent = support.WidgetKeyboardEvent;
|
|
267
|
+
const WidgetControlIntentKind = support.WidgetControlIntentKind;
|
|
268
|
+
const WidgetControlIntent = support.WidgetControlIntent;
|
|
269
|
+
const WidgetSemanticAction = support.WidgetSemanticAction;
|
|
270
|
+
const WidgetFileDropEvent = support.WidgetFileDropEvent;
|
|
271
|
+
const WidgetDragEvent = support.WidgetDragEvent;
|
|
272
|
+
const WidgetEventPhase = support.WidgetEventPhase;
|
|
273
|
+
const WidgetEventRouteEntry = support.WidgetEventRouteEntry;
|
|
274
|
+
const WidgetEventRoute = support.WidgetEventRoute;
|
|
275
|
+
const WidgetKeyboardRoute = support.WidgetKeyboardRoute;
|
|
276
|
+
const WidgetFocusDirection = support.WidgetFocusDirection;
|
|
277
|
+
const WidgetFocusTarget = support.WidgetFocusTarget;
|
|
278
|
+
const WidgetScrollMetrics = support.WidgetScrollMetrics;
|
|
279
|
+
const WidgetListMetrics = support.WidgetListMetrics;
|
|
280
|
+
const WidgetSemanticsNode = support.WidgetSemanticsNode;
|
|
281
|
+
const WidgetInvalidationKind = support.WidgetInvalidationKind;
|
|
282
|
+
const WidgetInvalidation = support.WidgetInvalidation;
|
|
283
|
+
const widgetKeyboardControlIntent = support.widgetKeyboardControlIntent;
|
|
284
|
+
const widgetSemanticControlIntent = support.widgetSemanticControlIntent;
|
|
285
|
+
const widgetSemanticControlIntentWithActions = support.widgetSemanticControlIntentWithActions;
|
|
286
|
+
const isWidgetActivationKey = support.isWidgetActivationKey;
|
|
287
|
+
const widgetSliderKeyboardValue = support.widgetSliderKeyboardValue;
|
|
288
|
+
const widgetScrollKeyboardIntent = support.widgetScrollKeyboardIntent;
|
|
289
|
+
const widgetScrollKeyboardDelta = support.widgetScrollKeyboardDelta;
|
|
290
|
+
const WidgetLayoutTree = support.WidgetLayoutTree;
|
|
291
|
+
const DisplayList = support.DisplayList;
|
|
292
|
+
const emitWidgetTree = support.emitWidgetTree;
|
|
293
|
+
const layoutWidgetTree = support.layoutWidgetTree;
|
|
294
|
+
const layoutWidgetTreeWithTokens = support.layoutWidgetTreeWithTokens;
|
|
295
|
+
const layoutTextRun = support.layoutTextRun;
|
|
296
|
+
const layoutTextRunPlan = support.layoutTextRunPlan;
|
|
297
|
+
const layoutTextCaretRect = support.layoutTextCaretRect;
|
|
298
|
+
const textCaretRectForLayout = support.textCaretRectForLayout;
|
|
299
|
+
const layoutTextSelectionRects = support.layoutTextSelectionRects;
|
|
300
|
+
const textSelectionRectsForLayout = support.textSelectionRectsForLayout;
|
|
301
|
+
const layoutTextOffsetForPoint = support.layoutTextOffsetForPoint;
|
|
302
|
+
const textOffsetForLayoutPoint = support.textOffsetForLayoutPoint;
|
|
303
|
+
const applyTextInputEvent = support.applyTextInputEvent;
|
|
304
|
+
const sampleCanvasRenderAnimations = support.sampleCanvasRenderAnimations;
|
|
305
|
+
const emitWidgetLayout = support.emitWidgetLayout;
|
|
306
|
+
const toggleWidgetKnobCommandId = support.toggleWidgetKnobCommandId;
|
|
307
|
+
const toggleWidgetKnobTravel = support.toggleWidgetKnobTravel;
|
|
308
|
+
const textSelectionForWidgetPoint = support.textSelectionForWidgetPoint;
|
|
309
|
+
const textOffsetForWidgetPoint = support.textOffsetForWidgetPoint;
|
|
310
|
+
const textInputViewportForWidget = support.textInputViewportForWidget;
|
|
311
|
+
const textInputContentExtentForWidget = support.textInputContentExtentForWidget;
|
|
312
|
+
const textInputMaxScrollOffsetForWidget = support.textInputMaxScrollOffsetForWidget;
|
|
313
|
+
const clampedTextInputScrollOffsetForWidget = support.clampedTextInputScrollOffsetForWidget;
|
|
314
|
+
const intrinsicWidgetSize = support.intrinsicWidgetSize;
|
|
315
|
+
const cursorForWidgetHit = support.cursorForWidgetHit;
|
|
316
|
+
const cursorForWidgetTarget = support.cursorForWidgetTarget;
|
|
317
|
+
const WidgetTextGeometry = support.WidgetTextGeometry;
|
|
318
|
+
const textGeometryForWidget = support.textGeometryForWidget;
|
|
319
|
+
const virtualWidgetScrollContentExtent = support.virtualWidgetScrollContentExtent;
|
|
320
|
+
const virtualWidgetScrollContentExtentWithTokens = support.virtualWidgetScrollContentExtentWithTokens;
|
|
321
|
+
const writeCanvasGpuPacketJson = support.writeCanvasGpuPacketJson;
|
|
322
|
+
const strokeBounds = support.strokeBounds;
|
|
323
|
+
const shadowBounds = support.shadowBounds;
|
|
324
|
+
const semanticActions = support.semanticActions;
|
|
325
|
+
const defaultSemanticActions = support.defaultSemanticActions;
|
|
326
|
+
const defaultFocusable = support.defaultFocusable;
|
|
327
|
+
const textLineBounds = support.textLineBounds;
|
|
328
|
+
const textBounds = support.textBounds;
|
|
329
|
+
const estimateTextWidth = support.estimateTextWidth;
|
|
330
|
+
const estimateTextWidthForFont = support.estimateTextWidthForFont;
|
|
331
|
+
const estimateTextAdvanceForBytes = support.estimateTextAdvanceForBytes;
|
|
332
|
+
const estimatedGlyphAdvance = support.estimatedGlyphAdvance;
|
|
333
|
+
const snapTextSelection = support.snapTextSelection;
|
|
334
|
+
const snapTextRange = support.snapTextRange;
|
|
335
|
+
const nextTextOffset = support.nextTextOffset;
|
|
336
|
+
const nextTextLineEnd = support.nextTextLineEnd;
|
|
337
|
+
const isTextBreakByte = support.isTextBreakByte;
|
|
338
|
+
const textLineRange = support.textLineRange;
|
|
339
|
+
const textLineCaretX = support.textLineCaretX;
|
|
340
|
+
const motionProgress = support.motionProgress;
|
|
341
|
+
const renderImageFingerprint = support.renderImageFingerprint;
|
|
342
|
+
const renderImageFingerprintForResource = support.renderImageFingerprintForResource;
|
|
343
|
+
const commandsEqual = support.commandsEqual;
|
|
344
|
+
const rectsEqual = support.rectsEqual;
|
|
345
|
+
const optionalRectsEqual = support.optionalRectsEqual;
|
|
346
|
+
const sizesEqual = support.sizesEqual;
|
|
347
|
+
const insetsEqual = support.insetsEqual;
|
|
348
|
+
const optionalColorsEqual = support.optionalColorsEqual;
|
|
349
|
+
const radiiEqual = support.radiiEqual;
|
|
350
|
+
const affinesEqual = support.affinesEqual;
|
|
351
|
+
const optionalF32Equal = support.optionalF32Equal;
|
|
352
|
+
const optionalTextSelectionsEqual = support.optionalTextSelectionsEqual;
|
|
353
|
+
const optionalTextRangesEqual = support.optionalTextRangesEqual;
|
|
354
|
+
const widgetPartId = support.widgetPartId;
|
|
355
|
+
const colorWithAlpha = support.colorWithAlpha;
|
|
356
|
+
const widgetControlHeight = support.widgetControlHeight;
|
|
357
|
+
const textSelectionFillColor = support.textSelectionFillColor;
|
|
358
|
+
const textSelectionTextColor = support.textSelectionTextColor;
|
|
359
|
+
const textEditingInkColor = support.textEditingInkColor;
|
|
360
|
+
const staticTextSelectionFillColor = support.staticTextSelectionFillColor;
|
|
361
|
+
const transparentColor = support.transparentColor;
|
|
362
|
+
const expectRect = support.expectRect;
|
|
363
|
+
const expectRectApprox = support.expectRectApprox;
|
|
364
|
+
const expectPixelRgba8 = support.expectPixelRgba8;
|
|
365
|
+
const expectVisiblePixel = support.expectVisiblePixel;
|
|
366
|
+
const referenceSurfaceSignature = support.referenceSurfaceSignature;
|
|
367
|
+
const expectLayoutFrame = support.expectLayoutFrame;
|
|
368
|
+
const expectRouteEntry = support.expectRouteEntry;
|
|
369
|
+
const expectFillColor = support.expectFillColor;
|
|
370
|
+
const expectGpuPaintColor = support.expectGpuPaintColor;
|
|
371
|
+
|
|
372
|
+
test "widget spatial focus traversal moves across data grid cells" {
|
|
373
|
+
const header_cells = [_]Widget{
|
|
374
|
+
.{ .id = 3, .kind = .data_cell, .text = "Project", .layout = .{ .grow = 1 } },
|
|
375
|
+
.{ .id = 4, .kind = .data_cell, .text = "Status", .layout = .{ .grow = 1 } },
|
|
376
|
+
};
|
|
377
|
+
const row_cells = [_]Widget{
|
|
378
|
+
.{ .id = 6, .kind = .data_cell, .text = "Edge API", .layout = .{ .grow = 1 } },
|
|
379
|
+
.{ .id = 7, .kind = .data_cell, .text = "Live", .layout = .{ .grow = 1 } },
|
|
380
|
+
};
|
|
381
|
+
const rows = [_]Widget{
|
|
382
|
+
.{ .id = 2, .kind = .data_row, .frame = geometry.RectF.init(0, 0, 0, 28), .children = &header_cells },
|
|
383
|
+
.{ .id = 5, .kind = .data_row, .frame = geometry.RectF.init(0, 0, 0, 28), .children = &row_cells },
|
|
384
|
+
};
|
|
385
|
+
const grid = Widget{
|
|
386
|
+
.id = 1,
|
|
387
|
+
.kind = .data_grid,
|
|
388
|
+
.layout = .{ .gap = 2 },
|
|
389
|
+
.children = &rows,
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
var nodes: [8]WidgetLayoutNode = undefined;
|
|
393
|
+
const layout = try layoutWidgetTree(grid, geometry.RectF.init(0, 0, 240, 58), &nodes);
|
|
394
|
+
try std.testing.expectEqual(@as(ObjectId, 4), layout.focusTarget(3, .right).?.id);
|
|
395
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(4, .left).?.id);
|
|
396
|
+
try std.testing.expectEqual(@as(ObjectId, 6), layout.focusTarget(3, .down).?.id);
|
|
397
|
+
try std.testing.expectEqual(@as(ObjectId, 7), layout.focusTarget(4, .down).?.id);
|
|
398
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(6, .up).?.id);
|
|
399
|
+
try std.testing.expect(layout.focusTarget(3, .left) == null);
|
|
400
|
+
try std.testing.expect(layout.focusTarget(3, .up) == null);
|
|
401
|
+
try std.testing.expect(layout.focusTarget(null, .right) == null);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
test "widget spatial focus traversal reaches staggered targets" {
|
|
405
|
+
const children = [_]Widget{
|
|
406
|
+
.{
|
|
407
|
+
.id = 2,
|
|
408
|
+
.kind = .button,
|
|
409
|
+
.frame = geometry.RectF.init(0, 0, 40, 24),
|
|
410
|
+
.text = "Start",
|
|
411
|
+
},
|
|
412
|
+
.{
|
|
413
|
+
.id = 3,
|
|
414
|
+
.kind = .button,
|
|
415
|
+
.frame = geometry.RectF.init(72, 40, 40, 24),
|
|
416
|
+
.text = "Next",
|
|
417
|
+
},
|
|
418
|
+
.{
|
|
419
|
+
.id = 4,
|
|
420
|
+
.kind = .button,
|
|
421
|
+
.frame = geometry.RectF.init(60, 88, 40, 24),
|
|
422
|
+
.text = "Lower",
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
const root = Widget{ .kind = .stack, .children = &children };
|
|
426
|
+
|
|
427
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
428
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 140, 128), &nodes);
|
|
429
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(2, .right).?.id);
|
|
430
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(2, .down).?.id);
|
|
431
|
+
try std.testing.expectEqual(@as(ObjectId, 2), layout.focusTarget(3, .left).?.id);
|
|
432
|
+
try std.testing.expectEqual(@as(ObjectId, 2), layout.focusTarget(3, .up).?.id);
|
|
433
|
+
try std.testing.expectEqual(@as(ObjectId, 4), layout.focusTarget(3, .down).?.id);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
test "widget layout collects accessibility semantics" {
|
|
437
|
+
const children = [_]Widget{
|
|
438
|
+
.{
|
|
439
|
+
.id = 2,
|
|
440
|
+
.kind = .button,
|
|
441
|
+
.frame = geometry.RectF.init(10, 10, 100, 32),
|
|
442
|
+
.text = "Run",
|
|
443
|
+
.semantics = .{ .label = "Run query" },
|
|
444
|
+
},
|
|
445
|
+
.{
|
|
446
|
+
.id = 3,
|
|
447
|
+
.kind = .progress,
|
|
448
|
+
.frame = geometry.RectF.init(10, 52, 160, 8),
|
|
449
|
+
.value = 0.75,
|
|
450
|
+
},
|
|
451
|
+
.{
|
|
452
|
+
.id = 4,
|
|
453
|
+
.kind = .text,
|
|
454
|
+
.frame = geometry.RectF.init(10, 68, 120, 20),
|
|
455
|
+
.text = "Hidden note",
|
|
456
|
+
.semantics = .{ .hidden = true },
|
|
457
|
+
},
|
|
458
|
+
};
|
|
459
|
+
const root = Widget{
|
|
460
|
+
.id = 1,
|
|
461
|
+
.kind = .panel,
|
|
462
|
+
.semantics = .{ .label = "Dashboard card" },
|
|
463
|
+
.children = &children,
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
var nodes: [6]WidgetLayoutNode = undefined;
|
|
467
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 240, 120), &nodes);
|
|
468
|
+
var semantics_buffer: [4]WidgetSemanticsNode = undefined;
|
|
469
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
470
|
+
|
|
471
|
+
try std.testing.expectEqual(@as(usize, 3), semantics.len);
|
|
472
|
+
try std.testing.expectEqual(WidgetRole.group, semantics[0].role);
|
|
473
|
+
try std.testing.expectEqualStrings("Dashboard card", semantics[0].label);
|
|
474
|
+
try std.testing.expect(semantics[0].parent_index == null);
|
|
475
|
+
|
|
476
|
+
try std.testing.expectEqual(WidgetRole.button, semantics[1].role);
|
|
477
|
+
// The label-replace contract: an explicit semantics.label REPLACES the
|
|
478
|
+
// widget's text ("Run") as the accessible name — the sources never
|
|
479
|
+
// combine, so screen readers and snapshots see the label alone.
|
|
480
|
+
try std.testing.expectEqualStrings("Run query", semantics[1].label);
|
|
481
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[1].parent_index);
|
|
482
|
+
try std.testing.expect(semantics[1].focusable);
|
|
483
|
+
try std.testing.expect(semantics[1].actions.focus);
|
|
484
|
+
try std.testing.expect(semantics[1].actions.press);
|
|
485
|
+
try std.testing.expect(!semantics[1].actions.toggle);
|
|
486
|
+
|
|
487
|
+
try std.testing.expectEqual(WidgetRole.progressbar, semantics[2].role);
|
|
488
|
+
try std.testing.expectEqual(@as(?f32, 0.75), semantics[2].value);
|
|
489
|
+
try std.testing.expect(semantics[2].actions.isEmpty());
|
|
490
|
+
try expectRect(geometry.RectF.init(10, 52, 160, 8), semantics[2].bounds);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
test "widget text size rungs do not change semantics" {
|
|
494
|
+
// heading/display are VISUAL typography rungs, not document
|
|
495
|
+
// structure: a display-size stat announces exactly like a body-size
|
|
496
|
+
// one (same role, same label, no heading level), so assistive tech
|
|
497
|
+
// output never shifts when a surface adopts the ladder.
|
|
498
|
+
const sizes = [_]canvas.WidgetSize{ .default, .heading, .display };
|
|
499
|
+
inline for (sizes) |size| {
|
|
500
|
+
const children = [_]Widget{
|
|
501
|
+
.{ .id = 2, .kind = .text, .frame = geometry.RectF.init(10, 10, 200, 60), .text = "42.7%", .size = size },
|
|
502
|
+
};
|
|
503
|
+
const root = Widget{ .id = 1, .kind = .column, .children = &children };
|
|
504
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
505
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 240, 120), &nodes);
|
|
506
|
+
var semantics_buffer: [4]WidgetSemanticsNode = undefined;
|
|
507
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
508
|
+
try std.testing.expectEqual(@as(usize, 2), semantics.len);
|
|
509
|
+
try std.testing.expectEqual(WidgetRole.text, semantics[1].role);
|
|
510
|
+
try std.testing.expectEqualStrings("42.7%", semantics[1].label);
|
|
511
|
+
try std.testing.expect(!semantics[1].focusable);
|
|
512
|
+
try std.testing.expect(semantics[1].actions.isEmpty());
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
test "widget disabled semantics suppresses focusability and actions" {
|
|
517
|
+
const children = [_]Widget{
|
|
518
|
+
.{
|
|
519
|
+
.id = 2,
|
|
520
|
+
.kind = .button,
|
|
521
|
+
.frame = geometry.RectF.init(8, 8, 100, 32),
|
|
522
|
+
.text = "Disabled",
|
|
523
|
+
.state = .{ .disabled = true },
|
|
524
|
+
.semantics = .{ .focusable = true, .actions = .{ .focus = true, .press = true } },
|
|
525
|
+
},
|
|
526
|
+
.{
|
|
527
|
+
.id = 3,
|
|
528
|
+
.kind = .text,
|
|
529
|
+
.frame = geometry.RectF.init(8, 48, 140, 20),
|
|
530
|
+
.text = "Disabled copy",
|
|
531
|
+
.state = .{ .disabled = true },
|
|
532
|
+
.semantics = .{ .focusable = true },
|
|
533
|
+
},
|
|
534
|
+
.{
|
|
535
|
+
.id = 4,
|
|
536
|
+
.kind = .button,
|
|
537
|
+
.frame = geometry.RectF.init(8, 76, 100, 32),
|
|
538
|
+
.text = "Active",
|
|
539
|
+
},
|
|
540
|
+
};
|
|
541
|
+
const root = Widget{ .kind = .stack, .children = &children };
|
|
542
|
+
|
|
543
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
544
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 160, 120), &nodes);
|
|
545
|
+
try std.testing.expectEqual(@as(ObjectId, 4), layout.focusTarget(null, .forward).?.id);
|
|
546
|
+
try std.testing.expect(layout.focusTargetById(2) == null);
|
|
547
|
+
try std.testing.expect(layout.focusTargetById(3) == null);
|
|
548
|
+
|
|
549
|
+
var semantics_buffer: [3]WidgetSemanticsNode = undefined;
|
|
550
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
551
|
+
try std.testing.expectEqual(@as(usize, 3), semantics.len);
|
|
552
|
+
|
|
553
|
+
try std.testing.expectEqual(@as(ObjectId, 2), semantics[0].id);
|
|
554
|
+
try std.testing.expect(semantics[0].state.disabled);
|
|
555
|
+
try std.testing.expect(!semantics[0].focusable);
|
|
556
|
+
try std.testing.expect(semantics[0].actions.isEmpty());
|
|
557
|
+
|
|
558
|
+
try std.testing.expectEqual(@as(ObjectId, 3), semantics[1].id);
|
|
559
|
+
try std.testing.expect(semantics[1].state.disabled);
|
|
560
|
+
try std.testing.expect(!semantics[1].focusable);
|
|
561
|
+
try std.testing.expect(semantics[1].actions.isEmpty());
|
|
562
|
+
|
|
563
|
+
try std.testing.expectEqual(@as(ObjectId, 4), semantics[2].id);
|
|
564
|
+
try std.testing.expect(semantics[2].focusable);
|
|
565
|
+
try std.testing.expect(semantics[2].actions.focus);
|
|
566
|
+
try std.testing.expect(semantics[2].actions.press);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
test "widget hidden semantics suppresses descendant semantics" {
|
|
570
|
+
const hidden_children = [_]Widget{.{
|
|
571
|
+
.id = 3,
|
|
572
|
+
.kind = .button,
|
|
573
|
+
.frame = geometry.RectF.init(0, 0, 100, 32),
|
|
574
|
+
.text = "Hidden child",
|
|
575
|
+
}};
|
|
576
|
+
const children = [_]Widget{
|
|
577
|
+
.{
|
|
578
|
+
.id = 2,
|
|
579
|
+
.kind = .panel,
|
|
580
|
+
.frame = geometry.RectF.init(8, 8, 120, 48),
|
|
581
|
+
.semantics = .{ .hidden = true },
|
|
582
|
+
.children = &hidden_children,
|
|
583
|
+
},
|
|
584
|
+
.{
|
|
585
|
+
.id = 4,
|
|
586
|
+
.kind = .button,
|
|
587
|
+
.frame = geometry.RectF.init(8, 64, 120, 32),
|
|
588
|
+
.text = "Visible",
|
|
589
|
+
},
|
|
590
|
+
};
|
|
591
|
+
const root = Widget{
|
|
592
|
+
.id = 1,
|
|
593
|
+
.kind = .panel,
|
|
594
|
+
.semantics = .{ .label = "Root" },
|
|
595
|
+
.children = &children,
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
599
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 160, 120), &nodes);
|
|
600
|
+
var semantics_buffer: [4]WidgetSemanticsNode = undefined;
|
|
601
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
602
|
+
|
|
603
|
+
try std.testing.expectEqual(@as(usize, 2), semantics.len);
|
|
604
|
+
try std.testing.expectEqual(@as(ObjectId, 1), semantics[0].id);
|
|
605
|
+
try std.testing.expectEqualStrings("Root", semantics[0].label);
|
|
606
|
+
try std.testing.expectEqual(@as(ObjectId, 4), semantics[1].id);
|
|
607
|
+
try std.testing.expectEqualStrings("Visible", semantics[1].label);
|
|
608
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[1].parent_index);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
test "widget hidden subtrees do not receive input routes" {
|
|
612
|
+
const hidden_children = [_]Widget{.{
|
|
613
|
+
.id = 3,
|
|
614
|
+
.kind = .button,
|
|
615
|
+
.frame = geometry.RectF.init(0, 0, 100, 32),
|
|
616
|
+
.text = "Hidden child",
|
|
617
|
+
.semantics = .{ .actions = .{ .drag = true, .drop_files = true } },
|
|
618
|
+
}};
|
|
619
|
+
const children = [_]Widget{
|
|
620
|
+
.{
|
|
621
|
+
.id = 2,
|
|
622
|
+
.kind = .panel,
|
|
623
|
+
.frame = geometry.RectF.init(8, 8, 120, 48),
|
|
624
|
+
.semantics = .{ .hidden = true },
|
|
625
|
+
.children = &hidden_children,
|
|
626
|
+
},
|
|
627
|
+
.{
|
|
628
|
+
.id = 4,
|
|
629
|
+
.kind = .button,
|
|
630
|
+
.frame = geometry.RectF.init(8, 64, 120, 32),
|
|
631
|
+
.text = "Visible",
|
|
632
|
+
},
|
|
633
|
+
};
|
|
634
|
+
const root = Widget{ .id = 1, .kind = .stack, .children = &children };
|
|
635
|
+
|
|
636
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
637
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 160, 120), &nodes);
|
|
638
|
+
|
|
639
|
+
try std.testing.expect(layout.hitTest(geometry.PointF.init(16, 16)) == null);
|
|
640
|
+
try std.testing.expectEqual(@as(ObjectId, 4), layout.hitTest(geometry.PointF.init(16, 72)).?.id);
|
|
641
|
+
try std.testing.expectEqual(@as(ObjectId, 4), layout.focusTarget(null, .forward).?.id);
|
|
642
|
+
try std.testing.expect(layout.focusTargetById(3) == null);
|
|
643
|
+
|
|
644
|
+
var route_buffer: [4]WidgetEventRouteEntry = undefined;
|
|
645
|
+
const pointer_route = try layout.routePointerEvent(.{ .phase = .down, .point = geometry.PointF.init(16, 16) }, &route_buffer);
|
|
646
|
+
try std.testing.expect(pointer_route.target == null);
|
|
647
|
+
try std.testing.expectEqual(@as(usize, 0), pointer_route.entries.len);
|
|
648
|
+
|
|
649
|
+
const keyboard_route = try layout.routeKeyboardEvent(.{ .phase = .key_down, .focused_id = 3, .key = "Enter" }, &route_buffer);
|
|
650
|
+
try std.testing.expect(keyboard_route.target == null);
|
|
651
|
+
try std.testing.expectEqual(@as(usize, 0), keyboard_route.entries.len);
|
|
652
|
+
|
|
653
|
+
const paths = [_][]const u8{"/tmp/report.csv"};
|
|
654
|
+
const drop_route = try layout.routeFileDropEvent(.{ .point = geometry.PointF.init(16, 16), .paths = &paths }, &route_buffer);
|
|
655
|
+
try std.testing.expect(drop_route.target == null);
|
|
656
|
+
try std.testing.expectEqual(@as(usize, 0), drop_route.entries.len);
|
|
657
|
+
|
|
658
|
+
const drag_route = try layout.routeDragEvent(.{ .source_id = 3, .point = geometry.PointF.init(16, 16) }, &route_buffer);
|
|
659
|
+
try std.testing.expect(drag_route.target == null);
|
|
660
|
+
try std.testing.expectEqual(@as(usize, 0), drag_route.entries.len);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
test "widget controls expose roles values focus and hit testing" {
|
|
664
|
+
const children = [_]Widget{
|
|
665
|
+
.{
|
|
666
|
+
.id = 2,
|
|
667
|
+
.kind = .checkbox,
|
|
668
|
+
.frame = geometry.RectF.init(10, 10, 120, 28),
|
|
669
|
+
.text = "Live",
|
|
670
|
+
.state = .{ .selected = true },
|
|
671
|
+
},
|
|
672
|
+
.{
|
|
673
|
+
.id = 3,
|
|
674
|
+
.kind = .radio,
|
|
675
|
+
.frame = geometry.RectF.init(10, 46, 120, 28),
|
|
676
|
+
.text = "Monthly",
|
|
677
|
+
.state = .{ .selected = true },
|
|
678
|
+
},
|
|
679
|
+
.{
|
|
680
|
+
.id = 4,
|
|
681
|
+
.kind = .toggle,
|
|
682
|
+
.frame = geometry.RectF.init(10, 82, 120, 28),
|
|
683
|
+
.text = "Focus",
|
|
684
|
+
},
|
|
685
|
+
.{
|
|
686
|
+
.id = 5,
|
|
687
|
+
.kind = .slider,
|
|
688
|
+
.frame = geometry.RectF.init(10, 118, 160, 32),
|
|
689
|
+
.value = 0.35,
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
const root = Widget{ .id = 1, .kind = .panel, .children = &children };
|
|
693
|
+
|
|
694
|
+
var nodes: [6]WidgetLayoutNode = undefined;
|
|
695
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 220, 176), &nodes);
|
|
696
|
+
try std.testing.expectEqual(@as(ObjectId, 2), layout.focusTarget(null, .forward).?.id);
|
|
697
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(2, .forward).?.id);
|
|
698
|
+
try std.testing.expectEqual(@as(ObjectId, 4), layout.focusTarget(3, .forward).?.id);
|
|
699
|
+
try std.testing.expectEqual(@as(ObjectId, 5), layout.focusTarget(4, .forward).?.id);
|
|
700
|
+
try std.testing.expectEqual(@as(ObjectId, 4), layout.focusTarget(5, .backward).?.id);
|
|
701
|
+
|
|
702
|
+
const slider_hit = layout.hitTest(geometry.PointF.init(40, 130)).?;
|
|
703
|
+
try std.testing.expectEqual(@as(ObjectId, 5), slider_hit.id);
|
|
704
|
+
try std.testing.expectEqual(WidgetKind.slider, slider_hit.kind);
|
|
705
|
+
|
|
706
|
+
const checkbox_label_hit = layout.hitTest(geometry.PointF.init(80, 24)).?;
|
|
707
|
+
try std.testing.expectEqual(@as(ObjectId, 2), checkbox_label_hit.id);
|
|
708
|
+
try std.testing.expectEqual(WidgetKind.checkbox, checkbox_label_hit.kind);
|
|
709
|
+
|
|
710
|
+
const toggle_label_hit = layout.hitTest(geometry.PointF.init(100, 96)).?;
|
|
711
|
+
try std.testing.expectEqual(@as(ObjectId, 4), toggle_label_hit.id);
|
|
712
|
+
try std.testing.expectEqual(WidgetKind.toggle, toggle_label_hit.kind);
|
|
713
|
+
|
|
714
|
+
var semantics_buffer: [5]WidgetSemanticsNode = undefined;
|
|
715
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
716
|
+
try std.testing.expectEqual(@as(usize, 5), semantics.len);
|
|
717
|
+
try std.testing.expectEqual(WidgetRole.checkbox, semantics[1].role);
|
|
718
|
+
try std.testing.expectEqualStrings("Live", semantics[1].label);
|
|
719
|
+
try std.testing.expectEqual(@as(?f32, 1), semantics[1].value);
|
|
720
|
+
try std.testing.expect(semantics[1].focusable);
|
|
721
|
+
try std.testing.expect(semantics[1].actions.focus);
|
|
722
|
+
try std.testing.expect(semantics[1].actions.toggle);
|
|
723
|
+
try std.testing.expectEqual(WidgetRole.radio, semantics[2].role);
|
|
724
|
+
try std.testing.expectEqualStrings("Monthly", semantics[2].label);
|
|
725
|
+
try std.testing.expectEqual(@as(?f32, 1), semantics[2].value);
|
|
726
|
+
try std.testing.expect(semantics[2].focusable);
|
|
727
|
+
try std.testing.expect(semantics[2].actions.select);
|
|
728
|
+
try std.testing.expect(!semantics[2].actions.toggle);
|
|
729
|
+
// `toggle` is the pressed-state button family; the switch role
|
|
730
|
+
// belongs to `switch_control` alone.
|
|
731
|
+
try std.testing.expectEqual(WidgetRole.button, semantics[3].role);
|
|
732
|
+
try std.testing.expectEqual(@as(?f32, 0), semantics[3].value);
|
|
733
|
+
try std.testing.expect(semantics[3].actions.toggle);
|
|
734
|
+
try std.testing.expectEqual(WidgetRole.slider, semantics[4].role);
|
|
735
|
+
try std.testing.expectEqual(@as(?f32, 0.35), semantics[4].value);
|
|
736
|
+
try std.testing.expect(semantics[4].actions.focus);
|
|
737
|
+
try std.testing.expect(semantics[4].actions.increment);
|
|
738
|
+
try std.testing.expect(semantics[4].actions.decrement);
|
|
739
|
+
try std.testing.expect(!semantics[4].actions.press);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
test "widget icons expose image and button semantics" {
|
|
743
|
+
const children = [_]Widget{
|
|
744
|
+
.{
|
|
745
|
+
.id = 2,
|
|
746
|
+
.kind = .icon,
|
|
747
|
+
.frame = geometry.RectF.init(8, 8, 24, 24),
|
|
748
|
+
.text = "?",
|
|
749
|
+
.semantics = .{ .label = "Help" },
|
|
750
|
+
},
|
|
751
|
+
.{
|
|
752
|
+
.id = 3,
|
|
753
|
+
.kind = .icon_button,
|
|
754
|
+
.frame = geometry.RectF.init(40, 4, 32, 32),
|
|
755
|
+
.text = "+",
|
|
756
|
+
.state = .{ .focused = true },
|
|
757
|
+
.semantics = .{ .label = "Add item" },
|
|
758
|
+
},
|
|
759
|
+
};
|
|
760
|
+
const root = Widget{ .kind = .stack, .children = &children };
|
|
761
|
+
|
|
762
|
+
var nodes: [3]WidgetLayoutNode = undefined;
|
|
763
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 120, 48), &nodes);
|
|
764
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(null, .forward).?.id);
|
|
765
|
+
try std.testing.expect(layout.hitTest(geometry.PointF.init(16, 16)) == null);
|
|
766
|
+
|
|
767
|
+
const button_hit = layout.hitTest(geometry.PointF.init(48, 16)).?;
|
|
768
|
+
try std.testing.expectEqual(@as(ObjectId, 3), button_hit.id);
|
|
769
|
+
try std.testing.expectEqual(WidgetKind.icon_button, button_hit.kind);
|
|
770
|
+
|
|
771
|
+
var semantics_buffer: [2]WidgetSemanticsNode = undefined;
|
|
772
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
773
|
+
try std.testing.expectEqual(@as(usize, 2), semantics.len);
|
|
774
|
+
try std.testing.expectEqual(WidgetRole.image, semantics[0].role);
|
|
775
|
+
try std.testing.expectEqualStrings("Help", semantics[0].label);
|
|
776
|
+
try std.testing.expect(!semantics[0].focusable);
|
|
777
|
+
try std.testing.expectEqual(WidgetRole.button, semantics[1].role);
|
|
778
|
+
try std.testing.expectEqualStrings("Add item", semantics[1].label);
|
|
779
|
+
try std.testing.expect(semantics[1].focusable);
|
|
780
|
+
|
|
781
|
+
const tokens = DesignTokens{
|
|
782
|
+
.colors = .{ .focus_ring = Color.rgb8(1, 2, 3) },
|
|
783
|
+
.stroke = .{ .focus = 4 },
|
|
784
|
+
};
|
|
785
|
+
var icon_commands: [1]CanvasCommand = undefined;
|
|
786
|
+
var icon_builder = Builder.init(&icon_commands);
|
|
787
|
+
try emitWidgetTree(&icon_builder, children[0], tokens);
|
|
788
|
+
const icon_display_list = icon_builder.displayList();
|
|
789
|
+
try std.testing.expectEqual(@as(usize, 1), icon_display_list.commandCount());
|
|
790
|
+
switch (icon_display_list.commands[0]) {
|
|
791
|
+
.draw_text => |text| {
|
|
792
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(2, 1)), text.id);
|
|
793
|
+
try std.testing.expectEqualStrings("?", text.text);
|
|
794
|
+
},
|
|
795
|
+
else => return error.TestUnexpectedResult,
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
var button_commands: [5]CanvasCommand = undefined;
|
|
799
|
+
var button_builder = Builder.init(&button_commands);
|
|
800
|
+
try emitWidgetTree(&button_builder, children[1], tokens);
|
|
801
|
+
const button_display_list = button_builder.displayList();
|
|
802
|
+
// Focus no longer restyles the border: fill, border, offset focus
|
|
803
|
+
// ring, then the glyph (the button register is flat — no shadow).
|
|
804
|
+
try std.testing.expectEqual(@as(usize, 4), button_display_list.commandCount());
|
|
805
|
+
switch (button_display_list.commands[2]) {
|
|
806
|
+
.stroke_rect => |stroke| {
|
|
807
|
+
try std.testing.expectEqual(@as(f32, 4), stroke.stroke.width);
|
|
808
|
+
try expectFillColor(tokens.colors.focus_ring, stroke.stroke.fill);
|
|
809
|
+
// The ring sits 2px outside the control frame.
|
|
810
|
+
try std.testing.expectEqual(@as(f32, 40 - 2), stroke.rect.x);
|
|
811
|
+
try std.testing.expectEqual(@as(f32, 32 + 4), stroke.rect.width);
|
|
812
|
+
},
|
|
813
|
+
else => return error.TestUnexpectedResult,
|
|
814
|
+
}
|
|
815
|
+
switch (button_display_list.commands[3]) {
|
|
816
|
+
.draw_text => |text| {
|
|
817
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(3, 3)), text.id);
|
|
818
|
+
try std.testing.expectEqualStrings("+", text.text);
|
|
819
|
+
},
|
|
820
|
+
else => return error.TestUnexpectedResult,
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
test "widget image emits draw image and exposes image semantics" {
|
|
825
|
+
const image = Widget{
|
|
826
|
+
.id = 8,
|
|
827
|
+
.kind = .image,
|
|
828
|
+
.frame = geometry.RectF.init(12, 14, 80, 48),
|
|
829
|
+
.image_id = 42,
|
|
830
|
+
.image_src = geometry.RectF.init(0, 0, 320, 192),
|
|
831
|
+
.image_fit = .cover,
|
|
832
|
+
.image_sampling = .nearest,
|
|
833
|
+
.image_opacity = 0.75,
|
|
834
|
+
.semantics = .{ .label = "Deployment preview" },
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
838
|
+
const layout = try layoutWidgetTree(image, image.frame, &nodes);
|
|
839
|
+
try std.testing.expect(layout.hitTest(geometry.PointF.init(20, 20)) == null);
|
|
840
|
+
|
|
841
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
842
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
843
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
844
|
+
try std.testing.expectEqual(WidgetRole.image, semantics[0].role);
|
|
845
|
+
try std.testing.expectEqualStrings("Deployment preview", semantics[0].label);
|
|
846
|
+
try std.testing.expect(!semantics[0].focusable);
|
|
847
|
+
|
|
848
|
+
var commands: [3]CanvasCommand = undefined;
|
|
849
|
+
var builder = Builder.init(&commands);
|
|
850
|
+
try layout.emitDisplayList(&builder, .{});
|
|
851
|
+
const display_list = builder.displayList();
|
|
852
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
853
|
+
switch (display_list.commands[0]) {
|
|
854
|
+
.push_clip => |clip| {
|
|
855
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(8, 2)), clip.id);
|
|
856
|
+
try expectRect(geometry.RectF.init(12, 14, 80, 48), clip.rect);
|
|
857
|
+
},
|
|
858
|
+
else => return error.TestUnexpectedResult,
|
|
859
|
+
}
|
|
860
|
+
switch (display_list.commands[1]) {
|
|
861
|
+
.draw_image => |draw| {
|
|
862
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(8, 1)), draw.id);
|
|
863
|
+
try std.testing.expectEqual(@as(ImageId, 42), draw.image_id);
|
|
864
|
+
try expectRect(geometry.RectF.init(0, 0, 320, 192), draw.src);
|
|
865
|
+
try expectRect(geometry.RectF.init(12, 14, 80, 48), draw.dst);
|
|
866
|
+
try std.testing.expectEqual(ImageFit.cover, draw.fit);
|
|
867
|
+
try std.testing.expectEqual(ImageSampling.nearest, draw.sampling);
|
|
868
|
+
try std.testing.expectEqual(@as(f32, 0.75), draw.opacity);
|
|
869
|
+
},
|
|
870
|
+
else => return error.TestUnexpectedResult,
|
|
871
|
+
}
|
|
872
|
+
try std.testing.expect(display_list.commands[2] == .pop_clip);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
test "widget text fields expose textbox semantics and render focused chrome" {
|
|
876
|
+
const text_field = Widget{
|
|
877
|
+
.id = 8,
|
|
878
|
+
.kind = .text_field,
|
|
879
|
+
.frame = geometry.RectF.init(10, 12, 180, 36),
|
|
880
|
+
.text = "search terms",
|
|
881
|
+
.state = .{ .focused = true },
|
|
882
|
+
.semantics = .{ .label = "Search" },
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
886
|
+
const layout = try layoutWidgetTree(text_field, text_field.frame, &nodes);
|
|
887
|
+
try std.testing.expectEqual(@as(ObjectId, 8), layout.focusTarget(null, .forward).?.id);
|
|
888
|
+
try std.testing.expectEqual(WidgetKind.text_field, layout.hitTest(geometry.PointF.init(20, 24)).?.kind);
|
|
889
|
+
|
|
890
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
891
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
892
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
893
|
+
try std.testing.expectEqual(WidgetRole.textbox, semantics[0].role);
|
|
894
|
+
try std.testing.expectEqualStrings("Search", semantics[0].label);
|
|
895
|
+
try std.testing.expectEqualStrings("search terms", semantics[0].text_value);
|
|
896
|
+
try std.testing.expect(semantics[0].focusable);
|
|
897
|
+
|
|
898
|
+
const tokens = DesignTokens{
|
|
899
|
+
.colors = .{ .focus_ring = Color.rgb8(1, 2, 3) },
|
|
900
|
+
.stroke = .{ .focus = 3 },
|
|
901
|
+
};
|
|
902
|
+
var commands: [4]CanvasCommand = undefined;
|
|
903
|
+
var builder = Builder.init(&commands);
|
|
904
|
+
try emitWidgetTree(&builder, text_field, tokens);
|
|
905
|
+
const display_list = builder.displayList();
|
|
906
|
+
// Fill, border, offset focus ring, text: focus adds a ring instead
|
|
907
|
+
// of recoloring the border.
|
|
908
|
+
try std.testing.expectEqual(@as(usize, 4), display_list.commandCount());
|
|
909
|
+
switch (display_list.commands[2]) {
|
|
910
|
+
.stroke_rect => |stroke| {
|
|
911
|
+
try std.testing.expectEqual(@as(f32, 3), stroke.stroke.width);
|
|
912
|
+
try expectFillColor(tokens.colors.focus_ring, stroke.stroke.fill);
|
|
913
|
+
try std.testing.expectEqual(@as(f32, 10 - 2), stroke.rect.x);
|
|
914
|
+
},
|
|
915
|
+
else => return error.TestUnexpectedResult,
|
|
916
|
+
}
|
|
917
|
+
switch (display_list.commands[3]) {
|
|
918
|
+
.draw_text => |text| try std.testing.expectEqualStrings("search terms", text.text),
|
|
919
|
+
else => return error.TestUnexpectedResult,
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
test "widget inputs expose textbox semantics and render house input tokens" {
|
|
924
|
+
const input = Widget{
|
|
925
|
+
.id = 18,
|
|
926
|
+
.kind = .input,
|
|
927
|
+
.frame = geometry.RectF.init(10, 12, 180, 36),
|
|
928
|
+
.text = "native-sdk",
|
|
929
|
+
.semantics = .{ .label = "Project name" },
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
933
|
+
const layout = try layoutWidgetTree(input, input.frame, &nodes);
|
|
934
|
+
try std.testing.expectEqual(@as(ObjectId, 18), layout.focusTarget(null, .forward).?.id);
|
|
935
|
+
try std.testing.expectEqual(WidgetKind.input, layout.hitTest(geometry.PointF.init(20, 24)).?.kind);
|
|
936
|
+
try std.testing.expectEqual(WidgetCursor.text, cursorForWidgetTarget(.input, .{}));
|
|
937
|
+
|
|
938
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
939
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
940
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
941
|
+
try std.testing.expectEqual(WidgetRole.textbox, semantics[0].role);
|
|
942
|
+
try std.testing.expectEqualStrings("Project name", semantics[0].label);
|
|
943
|
+
try std.testing.expectEqualStrings("native-sdk", semantics[0].text_value);
|
|
944
|
+
try std.testing.expectEqualStrings("", semantics[0].placeholder);
|
|
945
|
+
try std.testing.expect(semantics[0].focusable);
|
|
946
|
+
try std.testing.expect(semantics[0].actions.set_text);
|
|
947
|
+
try std.testing.expect(semantics[0].actions.set_selection);
|
|
948
|
+
|
|
949
|
+
const tokens = DesignTokens{
|
|
950
|
+
.controls = .{
|
|
951
|
+
.input = .{
|
|
952
|
+
.background = Color.rgb8(18, 24, 30),
|
|
953
|
+
.foreground = Color.rgb8(230, 236, 242),
|
|
954
|
+
.border = Color.rgb8(78, 88, 98),
|
|
955
|
+
.radius = 7,
|
|
956
|
+
.stroke_width = 1.25,
|
|
957
|
+
},
|
|
958
|
+
},
|
|
959
|
+
};
|
|
960
|
+
var commands: [3]CanvasCommand = undefined;
|
|
961
|
+
var builder = Builder.init(&commands);
|
|
962
|
+
try emitWidgetTree(&builder, input, tokens);
|
|
963
|
+
const display_list = builder.displayList();
|
|
964
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
965
|
+
switch (display_list.commands[0]) {
|
|
966
|
+
.fill_rounded_rect => |fill| {
|
|
967
|
+
try std.testing.expectEqualDeep(Radius.all(7), fill.radius);
|
|
968
|
+
try expectFillColor(Color.rgb8(18, 24, 30), fill.fill);
|
|
969
|
+
},
|
|
970
|
+
else => return error.TestUnexpectedResult,
|
|
971
|
+
}
|
|
972
|
+
switch (display_list.commands[1]) {
|
|
973
|
+
.stroke_rect => |stroke| {
|
|
974
|
+
try std.testing.expectEqual(@as(f32, 1.25), stroke.stroke.width);
|
|
975
|
+
try expectFillColor(Color.rgb8(78, 88, 98), stroke.stroke.fill);
|
|
976
|
+
},
|
|
977
|
+
else => return error.TestUnexpectedResult,
|
|
978
|
+
}
|
|
979
|
+
switch (display_list.commands[2]) {
|
|
980
|
+
.draw_text => |text| {
|
|
981
|
+
try std.testing.expectEqualStrings("native-sdk", text.text);
|
|
982
|
+
try std.testing.expectEqualDeep(Color.rgb8(230, 236, 242), text.color);
|
|
983
|
+
},
|
|
984
|
+
else => return error.TestUnexpectedResult,
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
test "widget text inputs render explicit placeholders without changing text value" {
|
|
989
|
+
const input = Widget{
|
|
990
|
+
.id = 20,
|
|
991
|
+
.kind = .input,
|
|
992
|
+
.frame = geometry.RectF.init(10, 12, 180, 36),
|
|
993
|
+
.placeholder = "Project name",
|
|
994
|
+
.semantics = .{ .label = "Name" },
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
998
|
+
const layout = try layoutWidgetTree(input, input.frame, &nodes);
|
|
999
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1000
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1001
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1002
|
+
try std.testing.expectEqualStrings("Name", semantics[0].label);
|
|
1003
|
+
try std.testing.expectEqualStrings("", semantics[0].text_value);
|
|
1004
|
+
try std.testing.expectEqualStrings("Project name", semantics[0].placeholder);
|
|
1005
|
+
|
|
1006
|
+
const tokens = DesignTokens{
|
|
1007
|
+
.colors = .{ .text_muted = Color.rgb8(90, 91, 92) },
|
|
1008
|
+
};
|
|
1009
|
+
var commands: [3]CanvasCommand = undefined;
|
|
1010
|
+
var builder = Builder.init(&commands);
|
|
1011
|
+
try emitWidgetTree(&builder, input, tokens);
|
|
1012
|
+
const display_list = builder.displayList();
|
|
1013
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1014
|
+
switch (display_list.commands[2]) {
|
|
1015
|
+
.draw_text => |text| {
|
|
1016
|
+
try std.testing.expectEqualStrings("Project name", text.text);
|
|
1017
|
+
try std.testing.expectEqualDeep(Color.rgb8(90, 91, 92), text.color);
|
|
1018
|
+
},
|
|
1019
|
+
else => return error.TestUnexpectedResult,
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
const textarea = Widget{
|
|
1023
|
+
.id = 21,
|
|
1024
|
+
.kind = .textarea,
|
|
1025
|
+
.frame = geometry.RectF.init(0, 0, 180, 84),
|
|
1026
|
+
.placeholder = "Write a message",
|
|
1027
|
+
.semantics = .{ .label = "Message" },
|
|
1028
|
+
};
|
|
1029
|
+
var textarea_nodes: [1]WidgetLayoutNode = undefined;
|
|
1030
|
+
const textarea_layout = try layoutWidgetTree(textarea, textarea.frame, &textarea_nodes);
|
|
1031
|
+
var textarea_semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1032
|
+
const textarea_semantics = try textarea_layout.collectSemantics(&textarea_semantics_buffer);
|
|
1033
|
+
try std.testing.expectEqualStrings("", textarea_semantics[0].text_value);
|
|
1034
|
+
try std.testing.expectEqualStrings("Write a message", textarea_semantics[0].placeholder);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
test "widget inputs expose required read-only and invalid form state" {
|
|
1038
|
+
const input = Widget{
|
|
1039
|
+
.id = 19,
|
|
1040
|
+
.kind = .input,
|
|
1041
|
+
.frame = geometry.RectF.init(0, 0, 180, 36),
|
|
1042
|
+
.text = "readonly",
|
|
1043
|
+
.state = .{ .required = true, .read_only = true, .invalid = true },
|
|
1044
|
+
.semantics = .{ .label = "Readonly project name" },
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1048
|
+
const layout = try layoutWidgetTree(input, input.frame, &nodes);
|
|
1049
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1050
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1051
|
+
|
|
1052
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1053
|
+
try std.testing.expectEqual(WidgetRole.textbox, semantics[0].role);
|
|
1054
|
+
try std.testing.expect(semantics[0].state.required);
|
|
1055
|
+
try std.testing.expect(semantics[0].state.read_only);
|
|
1056
|
+
try std.testing.expect(semantics[0].state.invalid);
|
|
1057
|
+
try std.testing.expect(semantics[0].focusable);
|
|
1058
|
+
try std.testing.expect(!semantics[0].actions.set_text);
|
|
1059
|
+
try std.testing.expect(semantics[0].actions.set_selection);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
test "widget selects expose trigger semantics and render chevron chrome" {
|
|
1063
|
+
const select = Widget{
|
|
1064
|
+
.id = 9,
|
|
1065
|
+
.kind = .select,
|
|
1066
|
+
.frame = geometry.RectF.init(10, 12, 180, 36),
|
|
1067
|
+
.text = "Production",
|
|
1068
|
+
.command = "environment.open",
|
|
1069
|
+
.state = .{ .focused = true },
|
|
1070
|
+
.semantics = .{ .label = "Environment" },
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1074
|
+
const layout = try layoutWidgetTree(select, select.frame, &nodes);
|
|
1075
|
+
try std.testing.expectEqual(@as(ObjectId, 9), layout.focusTarget(null, .forward).?.id);
|
|
1076
|
+
try std.testing.expectEqual(WidgetKind.select, layout.hitTest(geometry.PointF.init(20, 24)).?.kind);
|
|
1077
|
+
|
|
1078
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1079
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1080
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1081
|
+
try std.testing.expectEqual(WidgetRole.button, semantics[0].role);
|
|
1082
|
+
try std.testing.expectEqualStrings("Environment", semantics[0].label);
|
|
1083
|
+
try std.testing.expectEqualStrings("", semantics[0].placeholder);
|
|
1084
|
+
try std.testing.expectEqual(@as(?bool, false), semantics[0].state.expanded);
|
|
1085
|
+
try std.testing.expect(semantics[0].focusable);
|
|
1086
|
+
try std.testing.expect(semantics[0].actions.press);
|
|
1087
|
+
try std.testing.expect(!semantics[0].actions.set_text);
|
|
1088
|
+
|
|
1089
|
+
const tokens = DesignTokens{
|
|
1090
|
+
.colors = .{ .focus_ring = Color.rgb8(1, 2, 3), .text_muted = Color.rgb8(90, 91, 92) },
|
|
1091
|
+
.stroke = .{ .focus = 3 },
|
|
1092
|
+
.controls = .{
|
|
1093
|
+
.select = .{
|
|
1094
|
+
.background = Color.rgb8(20, 24, 28),
|
|
1095
|
+
.foreground = Color.rgb8(238, 242, 246),
|
|
1096
|
+
.border = Color.rgb8(80, 90, 100),
|
|
1097
|
+
.radius = 5,
|
|
1098
|
+
.stroke_width = 2,
|
|
1099
|
+
},
|
|
1100
|
+
},
|
|
1101
|
+
};
|
|
1102
|
+
var commands: [7]CanvasCommand = undefined;
|
|
1103
|
+
var builder = Builder.init(&commands);
|
|
1104
|
+
try emitWidgetTree(&builder, select, tokens);
|
|
1105
|
+
const display_list = builder.displayList();
|
|
1106
|
+
// Fill, border, offset focus ring, text, then the registry chevron
|
|
1107
|
+
// (a transform pair bracketing its stroked path).
|
|
1108
|
+
try std.testing.expectEqual(@as(usize, 7), display_list.commandCount());
|
|
1109
|
+
switch (display_list.commands[0]) {
|
|
1110
|
+
.fill_rounded_rect => |fill| {
|
|
1111
|
+
try expectFillColor(Color.rgb8(20, 24, 28), fill.fill);
|
|
1112
|
+
try std.testing.expectEqualDeep(Radius.all(5), fill.radius);
|
|
1113
|
+
},
|
|
1114
|
+
else => return error.TestUnexpectedResult,
|
|
1115
|
+
}
|
|
1116
|
+
switch (display_list.commands[1]) {
|
|
1117
|
+
.stroke_rect => |stroke| {
|
|
1118
|
+
try std.testing.expectEqual(@as(f32, 2), stroke.stroke.width);
|
|
1119
|
+
try expectFillColor(Color.rgb8(80, 90, 100), stroke.stroke.fill);
|
|
1120
|
+
},
|
|
1121
|
+
else => return error.TestUnexpectedResult,
|
|
1122
|
+
}
|
|
1123
|
+
switch (display_list.commands[2]) {
|
|
1124
|
+
.stroke_rect => |stroke| {
|
|
1125
|
+
try std.testing.expectEqual(@as(f32, 3), stroke.stroke.width);
|
|
1126
|
+
try expectFillColor(tokens.colors.focus_ring, stroke.stroke.fill);
|
|
1127
|
+
try std.testing.expectEqual(@as(f32, 10 - 2), stroke.rect.x);
|
|
1128
|
+
},
|
|
1129
|
+
else => return error.TestUnexpectedResult,
|
|
1130
|
+
}
|
|
1131
|
+
switch (display_list.commands[3]) {
|
|
1132
|
+
.draw_text => |text| {
|
|
1133
|
+
try std.testing.expectEqualStrings("Production", text.text);
|
|
1134
|
+
try std.testing.expectEqualDeep(Color.rgb8(238, 242, 246), text.color);
|
|
1135
|
+
try std.testing.expect(text.text_layout != null);
|
|
1136
|
+
try std.testing.expect(text.text_layout.?.max_width < select.frame.width);
|
|
1137
|
+
},
|
|
1138
|
+
else => return error.TestUnexpectedResult,
|
|
1139
|
+
}
|
|
1140
|
+
switch (display_list.commands[4]) {
|
|
1141
|
+
.transform => {},
|
|
1142
|
+
else => return error.TestUnexpectedResult,
|
|
1143
|
+
}
|
|
1144
|
+
switch (display_list.commands[5]) {
|
|
1145
|
+
.stroke_path => |stroke| try expectFillColor(Color.rgb8(238, 242, 246), stroke.stroke.fill),
|
|
1146
|
+
else => return error.TestUnexpectedResult,
|
|
1147
|
+
}
|
|
1148
|
+
switch (display_list.commands[6]) {
|
|
1149
|
+
.transform => {},
|
|
1150
|
+
else => return error.TestUnexpectedResult,
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
var placeholder_commands: [6]CanvasCommand = undefined;
|
|
1154
|
+
var placeholder_builder = Builder.init(&placeholder_commands);
|
|
1155
|
+
try emitWidgetTree(&placeholder_builder, .{
|
|
1156
|
+
.id = 10,
|
|
1157
|
+
.kind = .select,
|
|
1158
|
+
.frame = geometry.RectF.init(0, 0, 180, 36),
|
|
1159
|
+
.semantics = .{ .label = "Choose item" },
|
|
1160
|
+
}, tokens);
|
|
1161
|
+
var placeholder_nodes: [1]WidgetLayoutNode = undefined;
|
|
1162
|
+
const placeholder_layout = try layoutWidgetTree(.{
|
|
1163
|
+
.id = 10,
|
|
1164
|
+
.kind = .select,
|
|
1165
|
+
.frame = geometry.RectF.init(0, 0, 180, 36),
|
|
1166
|
+
.placeholder = "Choose item",
|
|
1167
|
+
.semantics = .{ .label = "Environment" },
|
|
1168
|
+
}, geometry.RectF.init(0, 0, 180, 36), &placeholder_nodes);
|
|
1169
|
+
var placeholder_semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1170
|
+
const placeholder_semantics = try placeholder_layout.collectSemantics(&placeholder_semantics_buffer);
|
|
1171
|
+
try std.testing.expectEqualStrings("", placeholder_semantics[0].text_value);
|
|
1172
|
+
try std.testing.expectEqualStrings("Choose item", placeholder_semantics[0].placeholder);
|
|
1173
|
+
|
|
1174
|
+
const placeholder_list = placeholder_builder.displayList();
|
|
1175
|
+
switch (placeholder_list.commands[2]) {
|
|
1176
|
+
.draw_text => |text| {
|
|
1177
|
+
try std.testing.expectEqualStrings("Choose item", text.text);
|
|
1178
|
+
try std.testing.expectEqualDeep(Color.rgb8(90, 91, 92), text.color);
|
|
1179
|
+
},
|
|
1180
|
+
else => return error.TestUnexpectedResult,
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
test "widget search fields expose textbox semantics and render search chrome" {
|
|
1185
|
+
const search_field = Widget{
|
|
1186
|
+
.id = 10,
|
|
1187
|
+
.kind = .search_field,
|
|
1188
|
+
.frame = geometry.RectF.init(10, 12, 220, 36),
|
|
1189
|
+
.text = "customers",
|
|
1190
|
+
.text_selection = TextSelection.collapsed(9),
|
|
1191
|
+
.state = .{ .focused = true },
|
|
1192
|
+
.semantics = .{ .label = "Search customers" },
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1196
|
+
const layout = try layoutWidgetTree(search_field, search_field.frame, &nodes);
|
|
1197
|
+
try std.testing.expectEqual(@as(ObjectId, 10), layout.focusTarget(null, .forward).?.id);
|
|
1198
|
+
try std.testing.expectEqual(WidgetKind.search_field, layout.hitTest(geometry.PointF.init(20, 24)).?.kind);
|
|
1199
|
+
|
|
1200
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1201
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1202
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1203
|
+
try std.testing.expectEqual(WidgetRole.textbox, semantics[0].role);
|
|
1204
|
+
try std.testing.expectEqualStrings("Search customers", semantics[0].label);
|
|
1205
|
+
try std.testing.expectEqualStrings("customers", semantics[0].text_value);
|
|
1206
|
+
try std.testing.expect(semantics[0].focusable);
|
|
1207
|
+
try std.testing.expectEqualDeep(TextRange.init(9, 9), semantics[0].text_selection.?);
|
|
1208
|
+
const search_geometry = layout.textGeometry(10, .{}).?;
|
|
1209
|
+
try expectRectApprox(geometry.RectF.init(111.818, 21.25, 1, 17.5), search_geometry.caret_bounds.?);
|
|
1210
|
+
try std.testing.expectEqual(@as(usize, 0), search_geometry.selection_rect_count);
|
|
1211
|
+
|
|
1212
|
+
const tokens = DesignTokens{
|
|
1213
|
+
.colors = .{ .focus_ring = Color.rgb8(1, 2, 3), .text_muted = Color.rgb8(90, 91, 92) },
|
|
1214
|
+
.stroke = .{ .focus = 3 },
|
|
1215
|
+
};
|
|
1216
|
+
var commands: [13]CanvasCommand = undefined;
|
|
1217
|
+
var builder = Builder.init(&commands);
|
|
1218
|
+
try emitWidgetTree(&builder, search_field, tokens);
|
|
1219
|
+
const display_list = builder.displayList();
|
|
1220
|
+
// Fill, border, offset focus ring, then the vector magnifier
|
|
1221
|
+
// (transform, circle + handle stroke paths, inverse transform),
|
|
1222
|
+
// text, caret, and the trailing clear affordance (transform, two
|
|
1223
|
+
// stroke paths, inverse transform) since the field holds text.
|
|
1224
|
+
try std.testing.expectEqual(@as(usize, 13), display_list.commandCount());
|
|
1225
|
+
switch (display_list.commands[2]) {
|
|
1226
|
+
.stroke_rect => |stroke| {
|
|
1227
|
+
try std.testing.expectEqual(@as(f32, 3), stroke.stroke.width);
|
|
1228
|
+
try expectFillColor(tokens.colors.focus_ring, stroke.stroke.fill);
|
|
1229
|
+
},
|
|
1230
|
+
else => return error.TestUnexpectedResult,
|
|
1231
|
+
}
|
|
1232
|
+
// The magnifier is the registry `search` icon: a true circle as a
|
|
1233
|
+
// stroked path, not the old hand-drawn line box.
|
|
1234
|
+
switch (display_list.commands[4]) {
|
|
1235
|
+
.stroke_path => |stroke| {
|
|
1236
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(10, 4)), stroke.id);
|
|
1237
|
+
const registered = canvas.icons.find("search").?;
|
|
1238
|
+
try std.testing.expectEqual(registered.elements.ptr, stroke.elements.ptr);
|
|
1239
|
+
},
|
|
1240
|
+
else => return error.TestUnexpectedResult,
|
|
1241
|
+
}
|
|
1242
|
+
switch (display_list.commands[7]) {
|
|
1243
|
+
.draw_text => |text| try std.testing.expectEqualStrings("customers", text.text),
|
|
1244
|
+
else => return error.TestUnexpectedResult,
|
|
1245
|
+
}
|
|
1246
|
+
// The built-in clear affordance: the registry `x` icon over the
|
|
1247
|
+
// trailing inset (its two strokes land on part slots 16 and 18).
|
|
1248
|
+
switch (display_list.commands[10]) {
|
|
1249
|
+
.stroke_path => |stroke| {
|
|
1250
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(10, 16)), stroke.id);
|
|
1251
|
+
const registered = canvas.icons.find("x").?;
|
|
1252
|
+
try std.testing.expectEqual(registered.elements.ptr, stroke.elements.ptr);
|
|
1253
|
+
},
|
|
1254
|
+
else => return error.TestUnexpectedResult,
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
test "widget comboboxes expose textbox semantics and render trigger chrome" {
|
|
1259
|
+
const combobox = Widget{
|
|
1260
|
+
.id = 14,
|
|
1261
|
+
.kind = .combobox,
|
|
1262
|
+
.frame = geometry.RectF.init(10, 12, 220, 36),
|
|
1263
|
+
.text = "components",
|
|
1264
|
+
.command = "components.open",
|
|
1265
|
+
.semantics = .{ .label = "Component combobox" },
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1269
|
+
const layout = try layoutWidgetTree(combobox, combobox.frame, &nodes);
|
|
1270
|
+
try std.testing.expectEqual(@as(ObjectId, 14), layout.focusTarget(null, .forward).?.id);
|
|
1271
|
+
try std.testing.expectEqual(WidgetKind.combobox, layout.hitTest(geometry.PointF.init(20, 24)).?.kind);
|
|
1272
|
+
|
|
1273
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1274
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1275
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1276
|
+
try std.testing.expectEqual(WidgetRole.textbox, semantics[0].role);
|
|
1277
|
+
try std.testing.expectEqualStrings("Component combobox", semantics[0].label);
|
|
1278
|
+
try std.testing.expectEqualStrings("components", semantics[0].text_value);
|
|
1279
|
+
try std.testing.expectEqual(@as(?bool, false), semantics[0].state.expanded);
|
|
1280
|
+
try std.testing.expect(semantics[0].actions.press);
|
|
1281
|
+
try std.testing.expect(semantics[0].actions.set_text);
|
|
1282
|
+
try std.testing.expect(semantics[0].actions.set_selection);
|
|
1283
|
+
|
|
1284
|
+
var commands: [10]CanvasCommand = undefined;
|
|
1285
|
+
var builder = Builder.init(&commands);
|
|
1286
|
+
try emitWidgetTree(&builder, combobox, .{});
|
|
1287
|
+
const display_list = builder.displayList();
|
|
1288
|
+
// Fill, border, vector magnifier (4 commands), text, then the
|
|
1289
|
+
// registry chevron-down (a transform pair bracketing its stroked
|
|
1290
|
+
// path) — the same icon register the select trigger draws.
|
|
1291
|
+
try std.testing.expectEqual(@as(usize, 10), display_list.commandCount());
|
|
1292
|
+
switch (display_list.commands[6]) {
|
|
1293
|
+
.draw_text => |text| {
|
|
1294
|
+
try std.testing.expectEqualStrings("components", text.text);
|
|
1295
|
+
try std.testing.expect(text.text_layout != null);
|
|
1296
|
+
try std.testing.expect(text.text_layout.?.max_width < combobox.frame.width);
|
|
1297
|
+
},
|
|
1298
|
+
else => return error.TestUnexpectedResult,
|
|
1299
|
+
}
|
|
1300
|
+
switch (display_list.commands[7]) {
|
|
1301
|
+
.transform => {},
|
|
1302
|
+
else => return error.TestUnexpectedResult,
|
|
1303
|
+
}
|
|
1304
|
+
switch (display_list.commands[8]) {
|
|
1305
|
+
// The chevron's stroke path lands on slot 13 (the icon's shape
|
|
1306
|
+
// range starts at 12: fill slot skipped for a stroke-only icon).
|
|
1307
|
+
.stroke_path => |stroke| try std.testing.expectEqual(@as(ObjectId, widgetPartId(14, 13)), stroke.id),
|
|
1308
|
+
else => return error.TestUnexpectedResult,
|
|
1309
|
+
}
|
|
1310
|
+
switch (display_list.commands[9]) {
|
|
1311
|
+
.transform => {},
|
|
1312
|
+
else => return error.TestUnexpectedResult,
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
test "widget textareas expose multiline textbox semantics and render wrapped text" {
|
|
1317
|
+
const textarea = Widget{
|
|
1318
|
+
.id = 12,
|
|
1319
|
+
.kind = .textarea,
|
|
1320
|
+
.frame = geometry.RectF.init(10, 12, 150, 84),
|
|
1321
|
+
.text = "First line Second line",
|
|
1322
|
+
.text_selection = TextSelection.collapsed(10),
|
|
1323
|
+
.state = .{ .focused = true },
|
|
1324
|
+
.semantics = .{ .label = "Message" },
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1328
|
+
const layout = try layoutWidgetTree(textarea, textarea.frame, &nodes);
|
|
1329
|
+
try std.testing.expectEqual(@as(ObjectId, 12), layout.focusTarget(null, .forward).?.id);
|
|
1330
|
+
try std.testing.expectEqual(WidgetKind.textarea, layout.hitTest(geometry.PointF.init(20, 24)).?.kind);
|
|
1331
|
+
|
|
1332
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1333
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1334
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1335
|
+
try std.testing.expectEqual(WidgetRole.textbox, semantics[0].role);
|
|
1336
|
+
try std.testing.expectEqualStrings("Message", semantics[0].label);
|
|
1337
|
+
try std.testing.expectEqualStrings("First line Second line", semantics[0].text_value);
|
|
1338
|
+
try std.testing.expect(semantics[0].focusable);
|
|
1339
|
+
try std.testing.expect(semantics[0].actions.set_text);
|
|
1340
|
+
try std.testing.expect(semantics[0].actions.set_selection);
|
|
1341
|
+
|
|
1342
|
+
const text_geometry = layout.textGeometry(12, .{}).?;
|
|
1343
|
+
try std.testing.expect(text_geometry.caret_bounds != null);
|
|
1344
|
+
try std.testing.expectEqual(@as(usize, 0), text_geometry.selection_rect_count);
|
|
1345
|
+
|
|
1346
|
+
const offset = textOffsetForWidgetPoint(textarea, geometry.PointF.init(28, 36), .{}) orelse return error.TestUnexpectedResult;
|
|
1347
|
+
try std.testing.expect(offset <= textarea.text.len);
|
|
1348
|
+
|
|
1349
|
+
var commands: [7]CanvasCommand = undefined;
|
|
1350
|
+
var builder = Builder.init(&commands);
|
|
1351
|
+
try emitWidgetTree(&builder, textarea, .{});
|
|
1352
|
+
const display_list = builder.displayList();
|
|
1353
|
+
// Fill, border, offset focus ring, clip, text, caret, pop.
|
|
1354
|
+
try std.testing.expectEqual(@as(usize, 7), display_list.commandCount());
|
|
1355
|
+
switch (display_list.commands[3]) {
|
|
1356
|
+
.push_clip => |clip| try expectRectApprox(textInputViewportForWidget(textarea, .{}).?, clip.rect),
|
|
1357
|
+
else => return error.TestUnexpectedResult,
|
|
1358
|
+
}
|
|
1359
|
+
switch (display_list.commands[4]) {
|
|
1360
|
+
.draw_text => |text| {
|
|
1361
|
+
try std.testing.expectEqualStrings("First line Second line", text.text);
|
|
1362
|
+
try std.testing.expect(text.text_layout != null);
|
|
1363
|
+
try std.testing.expectEqual(TextWrap.word, text.text_layout.?.wrap);
|
|
1364
|
+
try std.testing.expect(text.origin.y < textarea.frame.y + textarea.frame.height * 0.5);
|
|
1365
|
+
},
|
|
1366
|
+
else => return error.TestUnexpectedResult,
|
|
1367
|
+
}
|
|
1368
|
+
switch (display_list.commands[5]) {
|
|
1369
|
+
// The caret is a filled one-point bar in the field's text ink —
|
|
1370
|
+
// full reading contrast, not the soft focus-ring gray.
|
|
1371
|
+
.fill_rect => |caret| {
|
|
1372
|
+
try expectFillColor(ColorTokens.light().text, caret.fill);
|
|
1373
|
+
try std.testing.expectEqual(@as(f32, 1), caret.rect.width);
|
|
1374
|
+
},
|
|
1375
|
+
else => return error.TestUnexpectedResult,
|
|
1376
|
+
}
|
|
1377
|
+
try std.testing.expectEqual(CanvasCommand.pop_clip, display_list.commands[6]);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
test "widget text fields render selection caret and composition ranges" {
|
|
1381
|
+
// The caret and composition underline take the field's own text ink
|
|
1382
|
+
// (the control foreground here), and the selection inverts: solid
|
|
1383
|
+
// accent fill under accent-foreground glyphs.
|
|
1384
|
+
const ink_color = Color.rgb8(40, 80, 120);
|
|
1385
|
+
const tokens = DesignTokens{
|
|
1386
|
+
.colors = .{ .focus_ring = Color.rgb8(10, 20, 30) },
|
|
1387
|
+
.controls = .{
|
|
1388
|
+
.text_field = .{ .foreground = ink_color },
|
|
1389
|
+
},
|
|
1390
|
+
};
|
|
1391
|
+
const composing = Widget{
|
|
1392
|
+
.id = 9,
|
|
1393
|
+
.kind = .text_field,
|
|
1394
|
+
.frame = geometry.RectF.init(8, 10, 180, 36),
|
|
1395
|
+
.text = "abcdef",
|
|
1396
|
+
.text_selection = .{ .anchor = 1, .focus = 4 },
|
|
1397
|
+
.text_composition = TextRange.init(2, 4),
|
|
1398
|
+
.state = .{ .focused = true },
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1402
|
+
const layout = try layoutWidgetTree(composing, composing.frame, &nodes);
|
|
1403
|
+
|
|
1404
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1405
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1406
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1407
|
+
try std.testing.expectEqualDeep(TextRange.init(1, 4), semantics[0].text_selection.?);
|
|
1408
|
+
try std.testing.expectEqualDeep(TextRange.init(2, 4), semantics[0].text_composition.?);
|
|
1409
|
+
const text_geometry = layout.textGeometry(9, .{}).?;
|
|
1410
|
+
try std.testing.expect(text_geometry.caret_bounds == null);
|
|
1411
|
+
try std.testing.expectEqual(@as(usize, 1), text_geometry.selection_rect_count);
|
|
1412
|
+
try expectRectApprox(geometry.RectF.init(27.98, 19.25, 24.472, 17.5), text_geometry.selection_bounds.?);
|
|
1413
|
+
try std.testing.expectEqual(@as(usize, 1), text_geometry.composition_rect_count);
|
|
1414
|
+
try expectRectApprox(geometry.RectF.init(36.352, 19.25, 16.1, 17.5), text_geometry.composition_bounds.?);
|
|
1415
|
+
|
|
1416
|
+
var commands: [10]CanvasCommand = undefined;
|
|
1417
|
+
var builder = Builder.init(&commands);
|
|
1418
|
+
try layout.emitDisplayList(&builder, tokens);
|
|
1419
|
+
const display_list = builder.displayList();
|
|
1420
|
+
// Fill, border, offset focus ring, selection fill, text, the
|
|
1421
|
+
// clipped selected-glyph repaint (clip + text + pop), composition.
|
|
1422
|
+
try std.testing.expectEqual(@as(usize, 9), display_list.commandCount());
|
|
1423
|
+
const selection_fill_rect = switch (display_list.commands[3]) {
|
|
1424
|
+
.fill_rect => |selection| blk: {
|
|
1425
|
+
try expectFillColor(textSelectionFillColor(composing, tokens), selection.fill);
|
|
1426
|
+
break :blk selection.rect;
|
|
1427
|
+
},
|
|
1428
|
+
else => return error.TestUnexpectedResult,
|
|
1429
|
+
};
|
|
1430
|
+
switch (display_list.commands[4]) {
|
|
1431
|
+
.draw_text => |text| {
|
|
1432
|
+
try std.testing.expectEqualStrings("abcdef", text.text);
|
|
1433
|
+
try std.testing.expectEqualDeep(ink_color, text.color);
|
|
1434
|
+
try std.testing.expect(text.text_layout != null);
|
|
1435
|
+
try std.testing.expectEqual(TextWrap.none, text.text_layout.?.wrap);
|
|
1436
|
+
},
|
|
1437
|
+
else => return error.TestUnexpectedResult,
|
|
1438
|
+
}
|
|
1439
|
+
// The repaint clip shares the highlight's exact rect, so the glyph
|
|
1440
|
+
// ink swaps precisely at the fill edge.
|
|
1441
|
+
switch (display_list.commands[5]) {
|
|
1442
|
+
.push_clip => |clip| try expectRectApprox(selection_fill_rect, clip.rect),
|
|
1443
|
+
else => return error.TestUnexpectedResult,
|
|
1444
|
+
}
|
|
1445
|
+
switch (display_list.commands[6]) {
|
|
1446
|
+
.draw_text => |text| {
|
|
1447
|
+
try std.testing.expectEqualStrings("abcdef", text.text);
|
|
1448
|
+
try std.testing.expectEqualDeep(textSelectionTextColor(composing, tokens), text.color);
|
|
1449
|
+
},
|
|
1450
|
+
else => return error.TestUnexpectedResult,
|
|
1451
|
+
}
|
|
1452
|
+
try std.testing.expectEqual(CanvasCommand.pop_clip, display_list.commands[7]);
|
|
1453
|
+
switch (display_list.commands[8]) {
|
|
1454
|
+
.fill_rect => |underline| try expectFillColor(ink_color, underline.fill),
|
|
1455
|
+
else => return error.TestUnexpectedResult,
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
const caret = Widget{
|
|
1459
|
+
.id = 10,
|
|
1460
|
+
.kind = .text_field,
|
|
1461
|
+
.frame = geometry.RectF.init(8, 10, 180, 36),
|
|
1462
|
+
.text = "abcd",
|
|
1463
|
+
.text_selection = TextSelection.collapsed(2),
|
|
1464
|
+
.state = .{ .focused = true },
|
|
1465
|
+
};
|
|
1466
|
+
var caret_commands: [5]CanvasCommand = undefined;
|
|
1467
|
+
var caret_builder = Builder.init(&caret_commands);
|
|
1468
|
+
try emitWidgetTree(&caret_builder, caret, tokens);
|
|
1469
|
+
const caret_display_list = caret_builder.displayList();
|
|
1470
|
+
try std.testing.expectEqual(@as(usize, 5), caret_display_list.commandCount());
|
|
1471
|
+
switch (caret_display_list.commands[4]) {
|
|
1472
|
+
.fill_rect => |caret_bar| {
|
|
1473
|
+
try expectFillColor(ink_color, caret_bar.fill);
|
|
1474
|
+
try std.testing.expectEqual(@as(f32, 1), caret_bar.rect.width);
|
|
1475
|
+
},
|
|
1476
|
+
else => return error.TestUnexpectedResult,
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
test "text editing affordance colors resolve tokens and per-widget overrides" {
|
|
1481
|
+
const tokens = DesignTokens{};
|
|
1482
|
+
const field = Widget{ .id = 3, .kind = .text_field, .frame = geometry.RectF.init(0, 0, 100, 32), .text = "abc" };
|
|
1483
|
+
|
|
1484
|
+
// Defaults: caret/underline take the text ink; the selection takes
|
|
1485
|
+
// the solid accent with the accent foreground for selected glyphs;
|
|
1486
|
+
// static text keeps a translucent accent wash under untouched inks.
|
|
1487
|
+
try std.testing.expectEqualDeep(tokens.colors.text, textEditingInkColor(field, tokens));
|
|
1488
|
+
try std.testing.expectEqualDeep(tokens.colors.accent, textSelectionFillColor(field, tokens));
|
|
1489
|
+
try std.testing.expectEqualDeep(tokens.colors.accent_text, textSelectionTextColor(field, tokens));
|
|
1490
|
+
const wash = staticTextSelectionFillColor(field, tokens);
|
|
1491
|
+
try std.testing.expectEqual(tokens.colors.accent.r, wash.r);
|
|
1492
|
+
try std.testing.expectEqual(tokens.colors.accent.g, wash.g);
|
|
1493
|
+
try std.testing.expectEqual(tokens.colors.accent.b, wash.b);
|
|
1494
|
+
try std.testing.expectApproxEqAbs(@as(f32, 0.3), wash.a, 0.001);
|
|
1495
|
+
|
|
1496
|
+
// Per-widget style overrides win: foreground drives the ink, accent
|
|
1497
|
+
// and accent_foreground drive the selection pair.
|
|
1498
|
+
var styled = field;
|
|
1499
|
+
styled.style.foreground = Color.rgb8(1, 2, 3);
|
|
1500
|
+
styled.style.accent = Color.rgb8(4, 5, 6);
|
|
1501
|
+
styled.style.accent_foreground = Color.rgb8(7, 8, 9);
|
|
1502
|
+
try std.testing.expectEqualDeep(Color.rgb8(1, 2, 3), textEditingInkColor(styled, tokens));
|
|
1503
|
+
try std.testing.expectEqualDeep(Color.rgb8(4, 5, 6), textSelectionFillColor(styled, tokens));
|
|
1504
|
+
try std.testing.expectEqualDeep(Color.rgb8(7, 8, 9), textSelectionTextColor(styled, tokens));
|
|
1505
|
+
const styled_wash = staticTextSelectionFillColor(styled, tokens);
|
|
1506
|
+
try std.testing.expectEqual(Color.rgb8(4, 5, 6).r, styled_wash.r);
|
|
1507
|
+
try std.testing.expectApproxEqAbs(@as(f32, 0.3), styled_wash.a, 0.001);
|
|
1508
|
+
|
|
1509
|
+
// A disabled field's ink mutes with its text.
|
|
1510
|
+
var disabled = field;
|
|
1511
|
+
disabled.state.disabled = true;
|
|
1512
|
+
try std.testing.expectEqualDeep(tokens.colors.text_muted, textEditingInkColor(disabled, tokens));
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
test "widget text fields render wrapped selection geometry" {
|
|
1516
|
+
const tokens = DesignTokens{
|
|
1517
|
+
.colors = .{ .focus_ring = Color.rgb8(10, 20, 30) },
|
|
1518
|
+
.typography = .{ .body_size = 10 },
|
|
1519
|
+
.spacing = .{ .sm = 4, .md = 4 },
|
|
1520
|
+
};
|
|
1521
|
+
const field = Widget{
|
|
1522
|
+
.id = 11,
|
|
1523
|
+
.kind = .text_field,
|
|
1524
|
+
.frame = geometry.RectF.init(4, 6, 28, 60),
|
|
1525
|
+
.text = "AB CD",
|
|
1526
|
+
.text_selection = .{ .anchor = 1, .focus = 5 },
|
|
1527
|
+
.state = .{ .focused = true },
|
|
1528
|
+
};
|
|
1529
|
+
|
|
1530
|
+
var commands: [12]CanvasCommand = undefined;
|
|
1531
|
+
var builder = Builder.init(&commands);
|
|
1532
|
+
try emitWidgetTree(&builder, field, tokens);
|
|
1533
|
+
|
|
1534
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1535
|
+
const layout = try layoutWidgetTree(field, field.frame, &nodes);
|
|
1536
|
+
const text_geometry = layout.textGeometry(11, tokens).?;
|
|
1537
|
+
try std.testing.expectEqual(@as(usize, 2), text_geometry.selection_rect_count);
|
|
1538
|
+
try expectRectApprox(geometry.RectF.init(8, 10, 14.13, 25), text_geometry.selection_bounds.?);
|
|
1539
|
+
|
|
1540
|
+
const display_list = builder.displayList();
|
|
1541
|
+
// Fill, border, offset focus ring, two selection rects, text, then
|
|
1542
|
+
// the selected-glyph repaint per rect (clip + text + pop, twice).
|
|
1543
|
+
try std.testing.expectEqual(@as(usize, 12), display_list.commandCount());
|
|
1544
|
+
switch (display_list.commands[3]) {
|
|
1545
|
+
.fill_rect => |selection| {
|
|
1546
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(11, 3)), selection.id);
|
|
1547
|
+
try expectRectApprox(geometry.RectF.init(14.7, 10, 6.8, 12.5), selection.rect);
|
|
1548
|
+
},
|
|
1549
|
+
else => return error.TestUnexpectedResult,
|
|
1550
|
+
}
|
|
1551
|
+
switch (display_list.commands[4]) {
|
|
1552
|
+
.fill_rect => |selection| {
|
|
1553
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(11, 13)), selection.id);
|
|
1554
|
+
try expectRectApprox(geometry.RectF.init(8, 22.5, 14.13, 12.5), selection.rect);
|
|
1555
|
+
},
|
|
1556
|
+
else => return error.TestUnexpectedResult,
|
|
1557
|
+
}
|
|
1558
|
+
switch (display_list.commands[5]) {
|
|
1559
|
+
.draw_text => |text| {
|
|
1560
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(11, 4)), text.id);
|
|
1561
|
+
try std.testing.expectEqualStrings("AB CD", text.text);
|
|
1562
|
+
try std.testing.expectEqual(TextWrap.word, text.text_layout.?.wrap);
|
|
1563
|
+
try std.testing.expectEqual(@as(f32, 20), text.text_layout.?.max_width);
|
|
1564
|
+
},
|
|
1565
|
+
else => return error.TestUnexpectedResult,
|
|
1566
|
+
}
|
|
1567
|
+
// Each repaint clip pairs with one full-run redraw in the selection
|
|
1568
|
+
// foreground; the clip rects mirror the two highlight rects above.
|
|
1569
|
+
switch (display_list.commands[6]) {
|
|
1570
|
+
.push_clip => |clip| try expectRectApprox(geometry.RectF.init(14.7, 10, 6.8, 12.5), clip.rect),
|
|
1571
|
+
else => return error.TestUnexpectedResult,
|
|
1572
|
+
}
|
|
1573
|
+
switch (display_list.commands[7]) {
|
|
1574
|
+
.draw_text => |text| try std.testing.expectEqualDeep(textSelectionTextColor(field, tokens), text.color),
|
|
1575
|
+
else => return error.TestUnexpectedResult,
|
|
1576
|
+
}
|
|
1577
|
+
try std.testing.expectEqual(CanvasCommand.pop_clip, display_list.commands[8]);
|
|
1578
|
+
switch (display_list.commands[9]) {
|
|
1579
|
+
.push_clip => |clip| try expectRectApprox(geometry.RectF.init(8, 22.5, 14.13, 12.5), clip.rect),
|
|
1580
|
+
else => return error.TestUnexpectedResult,
|
|
1581
|
+
}
|
|
1582
|
+
switch (display_list.commands[10]) {
|
|
1583
|
+
.draw_text => |text| try std.testing.expectEqualStrings("AB CD", text.text),
|
|
1584
|
+
else => return error.TestUnexpectedResult,
|
|
1585
|
+
}
|
|
1586
|
+
try std.testing.expectEqual(CanvasCommand.pop_clip, display_list.commands[11]);
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
test "widget text fields map pointer positions to caret selections" {
|
|
1590
|
+
const tokens = DesignTokens{};
|
|
1591
|
+
const field = Widget{
|
|
1592
|
+
.id = 2,
|
|
1593
|
+
.kind = .text_field,
|
|
1594
|
+
.frame = geometry.RectF.init(10, 12, 160, 32),
|
|
1595
|
+
.text = "AéB",
|
|
1596
|
+
};
|
|
1597
|
+
try std.testing.expectEqual(@as(usize, 0), textOffsetForWidgetPoint(field, geometry.PointF.init(18, 24), tokens).?);
|
|
1598
|
+
try std.testing.expectEqual(@as(usize, 1), textOffsetForWidgetPoint(field, geometry.PointF.init(27, 24), tokens).?);
|
|
1599
|
+
try std.testing.expectEqual(@as(usize, 3), textOffsetForWidgetPoint(field, geometry.PointF.init(37, 24), tokens).?);
|
|
1600
|
+
try std.testing.expectEqual(@as(usize, 4), textOffsetForWidgetPoint(field, geometry.PointF.init(80, 24), tokens).?);
|
|
1601
|
+
try std.testing.expectEqualDeep(TextSelection.collapsed(3), textSelectionForWidgetPoint(field, geometry.PointF.init(37, 24), null, tokens).?);
|
|
1602
|
+
try std.testing.expectEqualDeep(TextSelection{ .anchor = 1, .focus = 4 }, textSelectionForWidgetPoint(field, geometry.PointF.init(80, 24), 1, tokens).?);
|
|
1603
|
+
|
|
1604
|
+
const search = Widget{
|
|
1605
|
+
.id = 3,
|
|
1606
|
+
.kind = .search_field,
|
|
1607
|
+
.frame = geometry.RectF.init(10, 52, 180, 32),
|
|
1608
|
+
.text = "Find",
|
|
1609
|
+
};
|
|
1610
|
+
try std.testing.expectEqual(@as(usize, 0), textOffsetForWidgetPoint(search, geometry.PointF.init(24, 64), tokens).?);
|
|
1611
|
+
try std.testing.expectEqual(@as(usize, 1), textOffsetForWidgetPoint(search, geometry.PointF.init(48, 64), tokens).?);
|
|
1612
|
+
try std.testing.expect(textOffsetForWidgetPoint(.{ .kind = .text_field, .state = .{ .disabled = true } }, geometry.PointF.init(0, 0), tokens) == null);
|
|
1613
|
+
|
|
1614
|
+
const wrapped_tokens = DesignTokens{
|
|
1615
|
+
.typography = .{ .body_size = 10 },
|
|
1616
|
+
.spacing = .{ .sm = 4, .md = 4 },
|
|
1617
|
+
};
|
|
1618
|
+
const wrapped = Widget{
|
|
1619
|
+
.id = 4,
|
|
1620
|
+
.kind = .text_field,
|
|
1621
|
+
.frame = geometry.RectF.init(4, 6, 28, 60),
|
|
1622
|
+
.text = "AB CD",
|
|
1623
|
+
};
|
|
1624
|
+
try std.testing.expectEqual(@as(usize, 4), textOffsetForWidgetPoint(wrapped, geometry.PointF.init(14, 24), wrapped_tokens).?);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
test "widget tooltip emits overlay chrome and tooltip semantics" {
|
|
1628
|
+
const tokens = DesignTokens{};
|
|
1629
|
+
const tooltip = Widget{
|
|
1630
|
+
.id = 1,
|
|
1631
|
+
.kind = .tooltip,
|
|
1632
|
+
.frame = geometry.RectF.init(10, 12, 140, 28),
|
|
1633
|
+
.text = "Saved",
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1637
|
+
const layout = try layoutWidgetTree(tooltip, tooltip.frame, &nodes);
|
|
1638
|
+
|
|
1639
|
+
var commands: [4]CanvasCommand = undefined;
|
|
1640
|
+
var builder = Builder.init(&commands);
|
|
1641
|
+
try layout.emitDisplayList(&builder, tokens);
|
|
1642
|
+
const display_list = builder.displayList();
|
|
1643
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1644
|
+
switch (display_list.commands[0]) {
|
|
1645
|
+
.shadow => |shadow| {
|
|
1646
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(1, 1)), shadow.id);
|
|
1647
|
+
try expectRect(geometry.RectF.init(10, 12, 140, 28), shadow.rect);
|
|
1648
|
+
},
|
|
1649
|
+
else => return error.TestUnexpectedResult,
|
|
1650
|
+
}
|
|
1651
|
+
switch (display_list.commands[1]) {
|
|
1652
|
+
.fill_rounded_rect => |fill| {
|
|
1653
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(1, 2)), fill.id);
|
|
1654
|
+
try expectFillColor(tokens.colors.accent, fill.fill);
|
|
1655
|
+
},
|
|
1656
|
+
else => return error.TestUnexpectedResult,
|
|
1657
|
+
}
|
|
1658
|
+
switch (display_list.commands[2]) {
|
|
1659
|
+
.draw_text => |text| {
|
|
1660
|
+
try std.testing.expectEqual(@as(ObjectId, widgetPartId(1, 3)), text.id);
|
|
1661
|
+
try std.testing.expectEqualStrings("Saved", text.text);
|
|
1662
|
+
try std.testing.expectEqualDeep(tokens.colors.accent_text, text.color);
|
|
1663
|
+
},
|
|
1664
|
+
else => return error.TestUnexpectedResult,
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
try std.testing.expect(layout.hitTest(geometry.PointF.init(20, 20)) == null);
|
|
1668
|
+
|
|
1669
|
+
var semantics_buffer: [1]WidgetSemanticsNode = undefined;
|
|
1670
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1671
|
+
try std.testing.expectEqual(@as(usize, 1), semantics.len);
|
|
1672
|
+
try std.testing.expectEqual(WidgetRole.tooltip, semantics[0].role);
|
|
1673
|
+
try std.testing.expectEqualStrings("Saved", semantics[0].label);
|
|
1674
|
+
try std.testing.expect(!semantics[0].focusable);
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
test "widget popover emits overlay chrome and routes child events" {
|
|
1678
|
+
const children = [_]Widget{.{
|
|
1679
|
+
.id = 2,
|
|
1680
|
+
.kind = .button,
|
|
1681
|
+
.frame = geometry.RectF.init(0, 0, 100, 32),
|
|
1682
|
+
.text = "Open",
|
|
1683
|
+
}};
|
|
1684
|
+
const popover = Widget{
|
|
1685
|
+
.id = 1,
|
|
1686
|
+
.kind = .popover,
|
|
1687
|
+
.frame = geometry.RectF.init(20, 24, 180, 120),
|
|
1688
|
+
.layout = .{ .padding = geometry.InsetsF.all(10) },
|
|
1689
|
+
.semantics = .{ .label = "Command palette" },
|
|
1690
|
+
.children = &children,
|
|
1691
|
+
};
|
|
1692
|
+
|
|
1693
|
+
var nodes: [3]WidgetLayoutNode = undefined;
|
|
1694
|
+
const layout = try layoutWidgetTree(popover, popover.frame, &nodes);
|
|
1695
|
+
try std.testing.expectEqual(@as(usize, 2), layout.nodeCount());
|
|
1696
|
+
try expectLayoutFrame(layout, 1, geometry.RectF.init(20, 24, 180, 120));
|
|
1697
|
+
try expectLayoutFrame(layout, 2, geometry.RectF.init(30, 34, 100, 32));
|
|
1698
|
+
|
|
1699
|
+
var commands: [8]CanvasCommand = undefined;
|
|
1700
|
+
var builder = Builder.init(&commands);
|
|
1701
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1702
|
+
const display_list = builder.displayList();
|
|
1703
|
+
// Popover shadow + fill + border, then the flat child button's
|
|
1704
|
+
// fill + border + label.
|
|
1705
|
+
try std.testing.expectEqual(@as(usize, 6), display_list.commandCount());
|
|
1706
|
+
try std.testing.expect(display_list.commands[0] == .shadow);
|
|
1707
|
+
try std.testing.expectEqual(@as(?ObjectId, widgetPartId(1, 2)), display_list.commands[1].objectId());
|
|
1708
|
+
try std.testing.expect(display_list.commands[1] == .fill_rounded_rect);
|
|
1709
|
+
try std.testing.expectEqual(@as(?ObjectId, widgetPartId(2, 1)), display_list.commands[3].objectId());
|
|
1710
|
+
try std.testing.expect(display_list.commands[3] == .fill_rounded_rect);
|
|
1711
|
+
|
|
1712
|
+
try std.testing.expectEqual(@as(ObjectId, 2), layout.hitTest(geometry.PointF.init(40, 44)).?.id);
|
|
1713
|
+
const blank_hit = layout.hitTest(geometry.PointF.init(190, 130)).?;
|
|
1714
|
+
try std.testing.expectEqual(@as(ObjectId, 1), blank_hit.id);
|
|
1715
|
+
try std.testing.expectEqual(WidgetKind.popover, blank_hit.kind);
|
|
1716
|
+
try std.testing.expect(layout.hitTest(geometry.PointF.init(10, 10)) == null);
|
|
1717
|
+
|
|
1718
|
+
var route_buffer: [3]WidgetEventRouteEntry = undefined;
|
|
1719
|
+
const route = try layout.routePointerEvent(.{ .phase = .down, .point = geometry.PointF.init(40, 44) }, &route_buffer);
|
|
1720
|
+
try std.testing.expectEqual(@as(usize, 3), route.entries.len);
|
|
1721
|
+
try expectRouteEntry(route.entries[0], .capture, 1);
|
|
1722
|
+
try expectRouteEntry(route.entries[1], .target, 2);
|
|
1723
|
+
try expectRouteEntry(route.entries[2], .bubble, 1);
|
|
1724
|
+
|
|
1725
|
+
var semantics_buffer: [2]WidgetSemanticsNode = undefined;
|
|
1726
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1727
|
+
try std.testing.expectEqual(@as(usize, 2), semantics.len);
|
|
1728
|
+
try std.testing.expectEqual(WidgetRole.dialog, semantics[0].role);
|
|
1729
|
+
try std.testing.expectEqualStrings("Command palette", semantics[0].label);
|
|
1730
|
+
try std.testing.expect(semantics[0].parent_index == null);
|
|
1731
|
+
try std.testing.expectEqual(WidgetRole.button, semantics[1].role);
|
|
1732
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[1].parent_index);
|
|
1733
|
+
try std.testing.expect(semantics[1].focusable);
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
test "widget menu surface groups menu items semantically" {
|
|
1737
|
+
const items = [_]Widget{
|
|
1738
|
+
.{
|
|
1739
|
+
.id = 2,
|
|
1740
|
+
.kind = .menu_item,
|
|
1741
|
+
.text = "Rename",
|
|
1742
|
+
.state = .{ .selected = true },
|
|
1743
|
+
},
|
|
1744
|
+
.{
|
|
1745
|
+
.id = 3,
|
|
1746
|
+
.kind = .menu_item,
|
|
1747
|
+
.text = "Archive",
|
|
1748
|
+
},
|
|
1749
|
+
};
|
|
1750
|
+
const menu = Widget{
|
|
1751
|
+
.id = 1,
|
|
1752
|
+
.kind = .menu_surface,
|
|
1753
|
+
.frame = geometry.RectF.init(20, 24, 180, 90),
|
|
1754
|
+
.layout = .{ .padding = geometry.InsetsF.all(6), .gap = 2 },
|
|
1755
|
+
.semantics = .{ .label = "More actions" },
|
|
1756
|
+
.children = &items,
|
|
1757
|
+
};
|
|
1758
|
+
|
|
1759
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
1760
|
+
const layout = try layoutWidgetTree(menu, menu.frame, &nodes);
|
|
1761
|
+
try std.testing.expectEqual(@as(usize, 3), layout.nodeCount());
|
|
1762
|
+
try expectLayoutFrame(layout, 1, geometry.RectF.init(20, 24, 180, 90));
|
|
1763
|
+
// Menu rows sit on the comfortable 32px band.
|
|
1764
|
+
try expectLayoutFrame(layout, 2, geometry.RectF.init(26, 30, 168, 32));
|
|
1765
|
+
try expectLayoutFrame(layout, 3, geometry.RectF.init(26, 64, 168, 32));
|
|
1766
|
+
|
|
1767
|
+
var commands: [10]CanvasCommand = undefined;
|
|
1768
|
+
var builder = Builder.init(&commands);
|
|
1769
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1770
|
+
const display_list = builder.displayList();
|
|
1771
|
+
// Surface shadow/fill/border, then the committed row's label plus
|
|
1772
|
+
// its trailing checkmark (a transform pair bracketing the stroked
|
|
1773
|
+
// check path — commit paints a marker, not a wash), then the idle
|
|
1774
|
+
// row's label.
|
|
1775
|
+
try std.testing.expectEqual(@as(usize, 8), display_list.commandCount());
|
|
1776
|
+
try std.testing.expect(display_list.commands[0] == .shadow);
|
|
1777
|
+
try std.testing.expectEqual(@as(?ObjectId, widgetPartId(1, 2)), display_list.commands[1].objectId());
|
|
1778
|
+
try std.testing.expectEqual(@as(?ObjectId, widgetPartId(2, 3)), display_list.commands[3].objectId());
|
|
1779
|
+
try std.testing.expectEqual(@as(?ObjectId, widgetPartId(2, 13)), display_list.commands[5].objectId());
|
|
1780
|
+
try std.testing.expect(display_list.commands[5] == .stroke_path);
|
|
1781
|
+
|
|
1782
|
+
try std.testing.expectEqual(@as(ObjectId, 2), layout.focusTarget(null, .forward).?.id);
|
|
1783
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(2, .forward).?.id);
|
|
1784
|
+
try std.testing.expectEqual(@as(ObjectId, 2), layout.hitTest(geometry.PointF.init(34, 38)).?.id);
|
|
1785
|
+
const blank_hit = layout.hitTest(geometry.PointF.init(190, 108)).?;
|
|
1786
|
+
try std.testing.expectEqual(@as(ObjectId, 1), blank_hit.id);
|
|
1787
|
+
try std.testing.expectEqual(WidgetKind.menu_surface, blank_hit.kind);
|
|
1788
|
+
|
|
1789
|
+
var route_buffer: [3]WidgetEventRouteEntry = undefined;
|
|
1790
|
+
const route = try layout.routePointerEvent(.{ .phase = .down, .point = geometry.PointF.init(34, 38) }, &route_buffer);
|
|
1791
|
+
try std.testing.expectEqual(@as(usize, 3), route.entries.len);
|
|
1792
|
+
try expectRouteEntry(route.entries[0], .capture, 1);
|
|
1793
|
+
try expectRouteEntry(route.entries[1], .target, 2);
|
|
1794
|
+
try expectRouteEntry(route.entries[2], .bubble, 1);
|
|
1795
|
+
|
|
1796
|
+
var semantics_buffer: [3]WidgetSemanticsNode = undefined;
|
|
1797
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1798
|
+
try std.testing.expectEqual(@as(usize, 3), semantics.len);
|
|
1799
|
+
try std.testing.expectEqual(WidgetRole.menu, semantics[0].role);
|
|
1800
|
+
try std.testing.expectEqualStrings("More actions", semantics[0].label);
|
|
1801
|
+
try std.testing.expect(semantics[0].parent_index == null);
|
|
1802
|
+
try std.testing.expectEqual(WidgetRole.menuitem, semantics[1].role);
|
|
1803
|
+
try std.testing.expectEqualStrings("Rename", semantics[1].label);
|
|
1804
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[1].parent_index);
|
|
1805
|
+
try std.testing.expectEqual(@as(?f32, 1), semantics[1].value);
|
|
1806
|
+
try std.testing.expect(semantics[1].state.selected);
|
|
1807
|
+
try std.testing.expect(semantics[1].focusable);
|
|
1808
|
+
try std.testing.expect(semantics[1].actions.press);
|
|
1809
|
+
try std.testing.expect(semantics[1].actions.select);
|
|
1810
|
+
try std.testing.expectEqual(WidgetRole.menuitem, semantics[2].role);
|
|
1811
|
+
try std.testing.expectEqualStrings("Archive", semantics[2].label);
|
|
1812
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[2].parent_index);
|
|
1813
|
+
try std.testing.expectEqual(@as(?f32, 0), semantics[2].value);
|
|
1814
|
+
try std.testing.expect(!semantics[2].state.selected);
|
|
1815
|
+
try std.testing.expect(semantics[2].actions.press);
|
|
1816
|
+
try std.testing.expect(semantics[2].actions.select);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
test "widget dropdown menus expose menu semantics with house surface chrome" {
|
|
1820
|
+
const items = [_]Widget{
|
|
1821
|
+
.{
|
|
1822
|
+
.id = 12,
|
|
1823
|
+
.kind = .menu_item,
|
|
1824
|
+
.text = "Profile",
|
|
1825
|
+
},
|
|
1826
|
+
.{
|
|
1827
|
+
.id = 13,
|
|
1828
|
+
.kind = .separator,
|
|
1829
|
+
.frame = geometry.RectF.init(0, 0, 128, 1),
|
|
1830
|
+
},
|
|
1831
|
+
.{
|
|
1832
|
+
.id = 14,
|
|
1833
|
+
.kind = .menu_item,
|
|
1834
|
+
.text = "Sign out",
|
|
1835
|
+
.variant = .destructive,
|
|
1836
|
+
},
|
|
1837
|
+
};
|
|
1838
|
+
const dropdown = Widget{
|
|
1839
|
+
.id = 11,
|
|
1840
|
+
.kind = .dropdown_menu,
|
|
1841
|
+
.frame = geometry.RectF.init(12, 16, 160, 112),
|
|
1842
|
+
.layout = builtinComponentWidget(.dropdown_menu, .{}).layout,
|
|
1843
|
+
.semantics = .{ .label = "Account menu" },
|
|
1844
|
+
.children = &items,
|
|
1845
|
+
};
|
|
1846
|
+
const tokens = DesignTokens{
|
|
1847
|
+
.controls = .{
|
|
1848
|
+
.dropdown_menu = .{
|
|
1849
|
+
.background = Color.rgb8(8, 9, 10),
|
|
1850
|
+
.border = Color.rgb8(60, 70, 80),
|
|
1851
|
+
.stroke_width = 2,
|
|
1852
|
+
},
|
|
1853
|
+
},
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
1857
|
+
const layout = try layoutWidgetTreeWithTokens(dropdown, dropdown.frame, tokens, &nodes);
|
|
1858
|
+
try std.testing.expectEqual(@as(usize, 4), layout.nodeCount());
|
|
1859
|
+
try expectLayoutFrame(layout, 11, geometry.RectF.init(12, 16, 160, 112));
|
|
1860
|
+
try expectLayoutFrame(layout, 12, geometry.RectF.init(16, 20, 152, 32));
|
|
1861
|
+
try expectLayoutFrame(layout, 13, geometry.RectF.init(16, 54, 128, 1));
|
|
1862
|
+
try expectLayoutFrame(layout, 14, geometry.RectF.init(16, 57, 152, 32));
|
|
1863
|
+
try std.testing.expectEqual(@as(ObjectId, 12), layout.focusTarget(null, .forward).?.id);
|
|
1864
|
+
try std.testing.expectEqual(@as(ObjectId, 14), layout.focusTarget(12, .forward).?.id);
|
|
1865
|
+
const blank_hit = layout.hitTest(geometry.PointF.init(168, 124)).?;
|
|
1866
|
+
try std.testing.expectEqual(@as(ObjectId, 11), blank_hit.id);
|
|
1867
|
+
try std.testing.expectEqual(WidgetKind.dropdown_menu, blank_hit.kind);
|
|
1868
|
+
|
|
1869
|
+
var semantics_buffer: [4]WidgetSemanticsNode = undefined;
|
|
1870
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1871
|
+
try std.testing.expectEqual(@as(usize, 3), semantics.len);
|
|
1872
|
+
try std.testing.expectEqual(WidgetRole.menu, semantics[0].role);
|
|
1873
|
+
try std.testing.expectEqualStrings("Account menu", semantics[0].label);
|
|
1874
|
+
try std.testing.expectEqual(@as(?bool, true), semantics[0].state.expanded);
|
|
1875
|
+
try std.testing.expectEqual(WidgetRole.menuitem, semantics[1].role);
|
|
1876
|
+
try std.testing.expectEqualStrings("Profile", semantics[1].label);
|
|
1877
|
+
try std.testing.expect(semantics[1].actions.press);
|
|
1878
|
+
try std.testing.expect(semantics[1].actions.select);
|
|
1879
|
+
try std.testing.expectEqual(WidgetRole.menuitem, semantics[2].role);
|
|
1880
|
+
try std.testing.expectEqualStrings("Sign out", semantics[2].label);
|
|
1881
|
+
|
|
1882
|
+
var commands: [8]CanvasCommand = undefined;
|
|
1883
|
+
var builder = Builder.init(&commands);
|
|
1884
|
+
try layout.emitDisplayList(&builder, tokens);
|
|
1885
|
+
const display_list = builder.displayList();
|
|
1886
|
+
try std.testing.expectEqual(@as(usize, 8), display_list.commandCount());
|
|
1887
|
+
try std.testing.expect(display_list.commands[0] == .shadow);
|
|
1888
|
+
switch (display_list.commands[1]) {
|
|
1889
|
+
.fill_rounded_rect => |fill| try expectFillColor(Color.rgb8(8, 9, 10), fill.fill),
|
|
1890
|
+
else => return error.TestUnexpectedResult,
|
|
1891
|
+
}
|
|
1892
|
+
switch (display_list.commands[2]) {
|
|
1893
|
+
.stroke_rect => |stroke| {
|
|
1894
|
+
try expectFillColor(Color.rgb8(60, 70, 80), stroke.stroke.fill);
|
|
1895
|
+
try std.testing.expectEqual(@as(f32, 2), stroke.stroke.width);
|
|
1896
|
+
},
|
|
1897
|
+
else => return error.TestUnexpectedResult,
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
test "widget list item and segmented controls expose selectable semantics" {
|
|
1902
|
+
const children = [_]Widget{
|
|
1903
|
+
.{
|
|
1904
|
+
.id = 2,
|
|
1905
|
+
.kind = .list_item,
|
|
1906
|
+
.frame = geometry.RectF.init(8, 8, 160, 32),
|
|
1907
|
+
.text = "Inbox",
|
|
1908
|
+
.state = .{ .selected = true },
|
|
1909
|
+
},
|
|
1910
|
+
.{
|
|
1911
|
+
.id = 3,
|
|
1912
|
+
.kind = .segmented_control,
|
|
1913
|
+
.frame = geometry.RectF.init(8, 48, 96, 32),
|
|
1914
|
+
.text = "Open",
|
|
1915
|
+
.value = 1,
|
|
1916
|
+
},
|
|
1917
|
+
};
|
|
1918
|
+
const root = Widget{ .kind = .stack, .children = &children };
|
|
1919
|
+
|
|
1920
|
+
var nodes: [3]WidgetLayoutNode = undefined;
|
|
1921
|
+
const layout = try layoutWidgetTree(root, geometry.RectF.init(0, 0, 200, 100), &nodes);
|
|
1922
|
+
try std.testing.expectEqual(@as(ObjectId, 2), layout.focusTarget(null, .forward).?.id);
|
|
1923
|
+
try std.testing.expectEqual(@as(ObjectId, 3), layout.focusTarget(2, .forward).?.id);
|
|
1924
|
+
try std.testing.expectEqual(WidgetKind.list_item, layout.hitTest(geometry.PointF.init(20, 20)).?.kind);
|
|
1925
|
+
|
|
1926
|
+
var semantics_buffer: [2]WidgetSemanticsNode = undefined;
|
|
1927
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1928
|
+
try std.testing.expectEqual(@as(usize, 2), semantics.len);
|
|
1929
|
+
try std.testing.expectEqual(WidgetRole.listitem, semantics[0].role);
|
|
1930
|
+
try std.testing.expectEqualStrings("Inbox", semantics[0].label);
|
|
1931
|
+
try std.testing.expectEqual(@as(?f32, 1), semantics[0].value);
|
|
1932
|
+
try std.testing.expect(semantics[0].focusable);
|
|
1933
|
+
try std.testing.expectEqual(WidgetRole.tab, semantics[1].role);
|
|
1934
|
+
try std.testing.expectEqualStrings("Open", semantics[1].label);
|
|
1935
|
+
try std.testing.expectEqual(@as(?f32, 1), semantics[1].value);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
test "widget data grids expose row and column semantics" {
|
|
1939
|
+
const header_cells = [_]Widget{
|
|
1940
|
+
.{ .id = 3, .kind = .data_cell, .text = "Project", .layout = .{ .grow = 1 } },
|
|
1941
|
+
.{ .id = 4, .kind = .data_cell, .text = "Status", .layout = .{ .grow = 1 } },
|
|
1942
|
+
};
|
|
1943
|
+
const row_cells = [_]Widget{
|
|
1944
|
+
.{ .id = 6, .kind = .data_cell, .text = "Edge API", .layout = .{ .grow = 1 } },
|
|
1945
|
+
.{ .id = 7, .kind = .data_cell, .text = "Live", .layout = .{ .grow = 1 } },
|
|
1946
|
+
};
|
|
1947
|
+
const rows = [_]Widget{
|
|
1948
|
+
.{ .id = 2, .kind = .data_row, .children = &header_cells },
|
|
1949
|
+
.{ .id = 5, .kind = .data_row, .children = &row_cells },
|
|
1950
|
+
};
|
|
1951
|
+
const grid = Widget{
|
|
1952
|
+
.id = 1,
|
|
1953
|
+
.kind = .data_grid,
|
|
1954
|
+
.text = "Deployments",
|
|
1955
|
+
.layout = .{ .gap = 2 },
|
|
1956
|
+
.children = &rows,
|
|
1957
|
+
};
|
|
1958
|
+
|
|
1959
|
+
var nodes: [8]WidgetLayoutNode = undefined;
|
|
1960
|
+
const layout = try layoutWidgetTree(grid, geometry.RectF.init(0, 0, 320, 180), &nodes);
|
|
1961
|
+
try expectLayoutFrame(layout, 2, geometry.RectF.init(0, 0, 320, 36));
|
|
1962
|
+
try expectLayoutFrame(layout, 3, geometry.RectF.init(0, 0, 160, 36));
|
|
1963
|
+
try expectLayoutFrame(layout, 5, geometry.RectF.init(0, 38, 320, 36));
|
|
1964
|
+
try expectLayoutFrame(layout, 6, geometry.RectF.init(0, 38, 160, 36));
|
|
1965
|
+
var semantics_buffer: [8]WidgetSemanticsNode = undefined;
|
|
1966
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
1967
|
+
|
|
1968
|
+
try std.testing.expectEqual(@as(usize, 7), semantics.len);
|
|
1969
|
+
try std.testing.expectEqual(WidgetRole.grid, semantics[0].role);
|
|
1970
|
+
try std.testing.expect(semantics[0].grid_row_index == null);
|
|
1971
|
+
try std.testing.expect(semantics[0].grid_column_index == null);
|
|
1972
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[0].grid_row_count);
|
|
1973
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[0].grid_column_count);
|
|
1974
|
+
|
|
1975
|
+
try std.testing.expectEqual(WidgetRole.row, semantics[1].role);
|
|
1976
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[1].grid_row_index);
|
|
1977
|
+
try std.testing.expect(semantics[1].grid_column_index == null);
|
|
1978
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[1].grid_row_count);
|
|
1979
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[1].grid_column_count);
|
|
1980
|
+
|
|
1981
|
+
try std.testing.expectEqual(WidgetRole.gridcell, semantics[2].role);
|
|
1982
|
+
try std.testing.expectEqualStrings("Project", semantics[2].label);
|
|
1983
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[2].grid_row_index);
|
|
1984
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[2].grid_column_index);
|
|
1985
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[2].grid_row_count);
|
|
1986
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[2].grid_column_count);
|
|
1987
|
+
|
|
1988
|
+
try std.testing.expectEqual(WidgetRole.gridcell, semantics[5].role);
|
|
1989
|
+
try std.testing.expectEqualStrings("Edge API", semantics[5].label);
|
|
1990
|
+
try std.testing.expectEqual(@as(?usize, 1), semantics[5].grid_row_index);
|
|
1991
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[5].grid_column_index);
|
|
1992
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[5].grid_row_count);
|
|
1993
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[5].grid_column_count);
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
test "widget tables expose grid semantics and scroll intents" {
|
|
1997
|
+
const header_cells = [_]Widget{
|
|
1998
|
+
.{ .id = 23, .kind = .data_cell, .text = "Component", .layout = .{ .grow = 1 } },
|
|
1999
|
+
.{ .id = 24, .kind = .data_cell, .text = "State", .layout = .{ .grow = 1 } },
|
|
2000
|
+
};
|
|
2001
|
+
const row_cells = [_]Widget{
|
|
2002
|
+
.{ .id = 26, .kind = .data_cell, .text = "Dropdown Menu", .layout = .{ .grow = 1 } },
|
|
2003
|
+
.{ .id = 27, .kind = .data_cell, .text = "Finished", .layout = .{ .grow = 1 } },
|
|
2004
|
+
};
|
|
2005
|
+
const rows = [_]Widget{
|
|
2006
|
+
.{ .id = 22, .kind = .data_row, .children = &header_cells },
|
|
2007
|
+
.{ .id = 25, .kind = .data_row, .children = &row_cells },
|
|
2008
|
+
};
|
|
2009
|
+
const table = Widget{
|
|
2010
|
+
.id = 21,
|
|
2011
|
+
.kind = .table,
|
|
2012
|
+
.frame = geometry.RectF.init(0, 0, 320, 72),
|
|
2013
|
+
.text = "Built-in components",
|
|
2014
|
+
.layout = .{ .gap = 2 },
|
|
2015
|
+
.children = &rows,
|
|
2016
|
+
};
|
|
2017
|
+
|
|
2018
|
+
var nodes: [8]WidgetLayoutNode = undefined;
|
|
2019
|
+
const layout = try layoutWidgetTree(table, table.frame, &nodes);
|
|
2020
|
+
try expectLayoutFrame(layout, 22, geometry.RectF.init(0, 0, 320, 36));
|
|
2021
|
+
try expectLayoutFrame(layout, 23, geometry.RectF.init(0, 0, 160, 36));
|
|
2022
|
+
try expectLayoutFrame(layout, 25, geometry.RectF.init(0, 38, 320, 36));
|
|
2023
|
+
try expectLayoutFrame(layout, 26, geometry.RectF.init(0, 38, 160, 36));
|
|
2024
|
+
|
|
2025
|
+
var semantics_buffer: [8]WidgetSemanticsNode = undefined;
|
|
2026
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
2027
|
+
try std.testing.expectEqual(@as(usize, 7), semantics.len);
|
|
2028
|
+
try std.testing.expectEqual(WidgetRole.grid, semantics[0].role);
|
|
2029
|
+
try std.testing.expectEqualStrings("Built-in components", semantics[0].label);
|
|
2030
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[0].grid_row_count);
|
|
2031
|
+
try std.testing.expectEqual(@as(?usize, 2), semantics[0].grid_column_count);
|
|
2032
|
+
try std.testing.expectEqual(WidgetRole.row, semantics[1].role);
|
|
2033
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[1].grid_row_index);
|
|
2034
|
+
try std.testing.expectEqual(WidgetRole.gridcell, semantics[2].role);
|
|
2035
|
+
try std.testing.expectEqualStrings("Component", semantics[2].label);
|
|
2036
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[2].grid_column_index);
|
|
2037
|
+
try std.testing.expectEqual(WidgetRole.gridcell, semantics[5].role);
|
|
2038
|
+
try std.testing.expectEqualStrings("Dropdown Menu", semantics[5].label);
|
|
2039
|
+
try std.testing.expectEqual(@as(?usize, 1), semantics[5].grid_row_index);
|
|
2040
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[5].grid_column_index);
|
|
2041
|
+
|
|
2042
|
+
const virtual_table = Widget{
|
|
2043
|
+
.id = 31,
|
|
2044
|
+
.kind = .table,
|
|
2045
|
+
.frame = geometry.RectF.init(0, 0, 320, 64),
|
|
2046
|
+
.value = 28,
|
|
2047
|
+
.layout = .{ .virtualized = true, .virtual_item_extent = 28, .virtual_overscan = 0 },
|
|
2048
|
+
.semantics = .{ .label = "Virtual table" },
|
|
2049
|
+
.children = &rows,
|
|
2050
|
+
};
|
|
2051
|
+
try std.testing.expectEqual(@as(f32, 56), virtualWidgetScrollContentExtent(virtual_table, 64));
|
|
2052
|
+
const page_down = WidgetKeyboardEvent{ .phase = .key_down, .key = "pagedown" };
|
|
2053
|
+
const keyboard_intent = widgetKeyboardControlIntent(virtual_table, page_down).?;
|
|
2054
|
+
try std.testing.expectEqual(WidgetControlIntentKind.scroll_by, keyboard_intent.kind);
|
|
2055
|
+
try std.testing.expect(keyboard_intent.actions.increment);
|
|
2056
|
+
const semantic_intent = widgetSemanticControlIntentWithActions(virtual_table, .increment, .{ .increment = true }).?;
|
|
2057
|
+
try std.testing.expectEqual(WidgetControlIntentKind.scroll_by, semantic_intent.kind);
|
|
2058
|
+
try std.testing.expect(semantic_intent.actions.increment);
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
test "widget list layout groups list items semantically" {
|
|
2062
|
+
const children = [_]Widget{
|
|
2063
|
+
.{
|
|
2064
|
+
.id = 2,
|
|
2065
|
+
.kind = .list_item,
|
|
2066
|
+
.text = "Inbox",
|
|
2067
|
+
.state = .{ .selected = true },
|
|
2068
|
+
},
|
|
2069
|
+
.{
|
|
2070
|
+
.id = 3,
|
|
2071
|
+
.kind = .list_item,
|
|
2072
|
+
.text = "Archive",
|
|
2073
|
+
},
|
|
2074
|
+
};
|
|
2075
|
+
const list = Widget{
|
|
2076
|
+
.id = 1,
|
|
2077
|
+
.kind = .list,
|
|
2078
|
+
.text = "Mailboxes",
|
|
2079
|
+
.layout = .{ .padding = geometry.InsetsF.all(8), .gap = 4 },
|
|
2080
|
+
.children = &children,
|
|
2081
|
+
};
|
|
2082
|
+
|
|
2083
|
+
var nodes: [4]WidgetLayoutNode = undefined;
|
|
2084
|
+
const layout = try layoutWidgetTree(list, geometry.RectF.init(0, 0, 220, 88), &nodes);
|
|
2085
|
+
try std.testing.expectEqual(@as(usize, 3), layout.nodeCount());
|
|
2086
|
+
try expectLayoutFrame(layout, 1, geometry.RectF.init(0, 0, 220, 88));
|
|
2087
|
+
try expectLayoutFrame(layout, 2, geometry.RectF.init(8, 8, 204, 28));
|
|
2088
|
+
try expectLayoutFrame(layout, 3, geometry.RectF.init(8, 40, 204, 28));
|
|
2089
|
+
|
|
2090
|
+
var commands: [4]CanvasCommand = undefined;
|
|
2091
|
+
var builder = Builder.init(&commands);
|
|
2092
|
+
try layout.emitDisplayList(&builder, .{});
|
|
2093
|
+
try std.testing.expectEqual(@as(usize, 3), builder.displayList().commandCount());
|
|
2094
|
+
|
|
2095
|
+
const hit = layout.hitTest(geometry.PointF.init(16, 16)).?;
|
|
2096
|
+
try std.testing.expectEqual(@as(ObjectId, 2), hit.id);
|
|
2097
|
+
try std.testing.expectEqual(WidgetKind.list_item, hit.kind);
|
|
2098
|
+
try std.testing.expect(layout.hitTest(geometry.PointF.init(16, 82)) == null);
|
|
2099
|
+
|
|
2100
|
+
var route_buffer: [3]WidgetEventRouteEntry = undefined;
|
|
2101
|
+
const route = try layout.routePointerEvent(.{ .phase = .down, .point = geometry.PointF.init(16, 16) }, &route_buffer);
|
|
2102
|
+
try std.testing.expectEqual(@as(usize, 3), route.entries.len);
|
|
2103
|
+
try std.testing.expectEqual(@as(ObjectId, 1), route.entries[0].id);
|
|
2104
|
+
try std.testing.expectEqual(WidgetEventPhase.capture, route.entries[0].phase);
|
|
2105
|
+
try std.testing.expectEqual(@as(ObjectId, 2), route.entries[1].id);
|
|
2106
|
+
try std.testing.expectEqual(WidgetEventPhase.target, route.entries[1].phase);
|
|
2107
|
+
try std.testing.expectEqual(@as(ObjectId, 1), route.entries[2].id);
|
|
2108
|
+
try std.testing.expectEqual(WidgetEventPhase.bubble, route.entries[2].phase);
|
|
2109
|
+
|
|
2110
|
+
var semantics_buffer: [3]WidgetSemanticsNode = undefined;
|
|
2111
|
+
const semantics = try layout.collectSemantics(&semantics_buffer);
|
|
2112
|
+
try std.testing.expectEqual(@as(usize, 3), semantics.len);
|
|
2113
|
+
try std.testing.expectEqual(WidgetRole.list, semantics[0].role);
|
|
2114
|
+
try std.testing.expectEqualStrings("Mailboxes", semantics[0].label);
|
|
2115
|
+
try std.testing.expect(semantics[0].parent_index == null);
|
|
2116
|
+
try std.testing.expect(!semantics[0].list.present);
|
|
2117
|
+
try std.testing.expectEqual(WidgetRole.listitem, semantics[1].role);
|
|
2118
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[1].parent_index);
|
|
2119
|
+
try std.testing.expectEqual(@as(?f32, 1), semantics[1].value);
|
|
2120
|
+
try std.testing.expect(semantics[1].list.present);
|
|
2121
|
+
try std.testing.expectEqual(@as(u32, 0), semantics[1].list.item_index);
|
|
2122
|
+
try std.testing.expectEqual(@as(u32, 2), semantics[1].list.item_count);
|
|
2123
|
+
try std.testing.expectEqual(WidgetRole.listitem, semantics[2].role);
|
|
2124
|
+
try std.testing.expectEqual(@as(?usize, 0), semantics[2].parent_index);
|
|
2125
|
+
try std.testing.expectEqual(@as(?f32, 0), semantics[2].value);
|
|
2126
|
+
try std.testing.expect(semantics[2].list.present);
|
|
2127
|
+
try std.testing.expectEqual(@as(u32, 1), semantics[2].list.item_index);
|
|
2128
|
+
try std.testing.expectEqual(@as(u32, 2), semantics[2].list.item_count);
|
|
2129
|
+
}
|