@native-sdk/cli 0.10.1 → 0.11.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/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +393 -97
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +2030 -83
- package/native-sdk.d.ts +5 -1
- package/package.json +20 -14
- package/packages/core/compile-surface/core.ts +164 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +68 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +332 -5
- package/packages/core/sdk/core.ts +371 -85
- package/packages/core/sdk/events.d.ts +252 -0
- package/packages/core/sdk/events.ts +240 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +186 -19
- package/packages/core/src/cli.ts +2 -11
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/context_menus.ts +76 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/diagnostics.ts +7 -0
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/extent_program.ts +53 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/frontend.ts +12 -10
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_canonical.ts +140 -0
- package/packages/core/src/markup_construction.ts +189 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/markup_display.ts +43 -0
- package/packages/core/src/markup_document.ts +226 -0
- package/packages/core/src/markup_elements.ts +225 -0
- package/packages/core/src/markup_expressions.ts +79 -0
- package/packages/core/src/markup_imports.ts +146 -0
- package/packages/core/src/markup_parser.ts +228 -0
- package/packages/core/src/markup_runtime.ts +93 -0
- package/packages/core/src/markup_scalars.ts +143 -0
- package/packages/core/src/markup_shapes.ts +243 -0
- package/packages/core/src/markup_specialized.ts +242 -0
- package/packages/core/src/markup_text.ts +86 -0
- package/packages/core/src/markup_values.ts +336 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +98 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +92 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3954 -0
- package/packages/core/src/scalar_text.ts +82 -0
- package/packages/core/src/scroll_mutation.ts +86 -0
- package/packages/core/src/scroll_tree.ts +86 -0
- package/packages/core/src/service_contract.ts +55 -3
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +14 -46
- package/packages/core/src/sqlite_codegen.ts +84 -0
- package/packages/core/src/staged_rebuild.ts +60 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_bridge.ts +161 -0
- package/packages/core/src/view_check.ts +145 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_evaluator.ts +823 -0
- package/packages/core/src/view_frontend.ts +1102 -0
- package/packages/core/src/view_program.ts +221 -0
- package/packages/core/src/view_reload.ts +166 -0
- package/packages/core/src/view_reload_watch.ts +98 -0
- package/packages/core/src/view_sources.ts +34 -0
- package/packages/core/src/virtual_windows.ts +88 -0
- package/packages/core/src/web_panes.ts +67 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_continuity.ts +37 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_reconcile.ts +63 -0
- package/packages/core/src/widget_retention.ts +62 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/native-ui/SKILL.md +77 -18
- package/skill-data/ts-core/SKILL.md +117 -11
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +288 -144
- package/src/app_runner/root.zig +39 -12
- package/src/app_runner/ts_compiled_view.zig +1702 -0
- package/src/app_runner/ts_core_main.zig +185 -14
- package/src/app_runner/ts_core_mobile.zig +25 -13
- package/src/automation/server.zig +57 -6
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/embed/host.zig +2 -0
- package/src/embed/tests.zig +2 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/keyboard_input.zig +32 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +4 -0
- package/src/platform/macos/appkit_host.h +7 -2
- package/src/platform/macos/appkit_host.m +219 -39
- package/src/platform/macos/cef_host.mm +15 -1
- package/src/platform/macos/global_shortcuts.zig +138 -0
- package/src/platform/macos/key_codes.zig +102 -0
- package/src/platform/macos/keyboard_input.zig +81 -0
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/root.zig +25 -3
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/webview_inspection_test.m +106 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +130 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +15 -0
- package/src/platform/types.zig +115 -0
- package/src/platform/windows/global_shortcuts.zig +157 -0
- package/src/platform/windows/key_codes.zig +63 -0
- package/src/platform/windows/keyboard_input.zig +136 -0
- package/src/platform/windows/root.zig +17 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/decision_reuse.zig +133 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/font_ttf.zig +27 -3
- package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
- package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
- package/src/primitives/canvas/fonts/OFL.txt +93 -0
- package/src/primitives/canvas/fonts/README.md +15 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +131 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/markdown_tests.zig +3 -3
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +15 -11
- package/src/primitives/canvas/reference_tests.zig +58 -0
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +107 -4
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +53 -37
- package/src/primitives/canvas/text_metrics_tests.zig +52 -7
- package/src/primitives/canvas/text_query_policy.zig +295 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +234 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +47 -0
- package/src/primitives/canvas/ui.zig +251 -83
- package/src/primitives/canvas/ui_markup.zig +207 -46
- package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +1724 -80
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
- package/src/primitives/canvas/ui_markup_construction.zig +146 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_display.zig +82 -0
- package/src/primitives/canvas/ui_markup_document.zig +196 -0
- package/src/primitives/canvas/ui_markup_elements.zig +163 -0
- package/src/primitives/canvas/ui_markup_expr.zig +192 -2
- package/src/primitives/canvas/ui_markup_imports.zig +262 -0
- package/src/primitives/canvas/ui_markup_parser.zig +117 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
- package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
- package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
- package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_text.zig +128 -0
- package/src/primitives/canvas/ui_markup_values.zig +368 -0
- package/src/primitives/canvas/ui_markup_view.zig +3026 -57
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +350 -0
- package/src/primitives/canvas/virtual_extents.zig +113 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +129 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +21 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +26 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +29 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +183 -4
- package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +720 -150
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/context_menu_policy.zig +112 -0
- package/src/runtime/core.zig +170 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +638 -33
- package/src/runtime/effects_host_tests.zig +25 -0
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +419 -341
- package/src/runtime/flow_reference.zig +1427 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/global_shortcuts.zig +75 -0
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/keyboard_input.zig +86 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +16 -0
- package/src/runtime/scroll_mutation_policy.zig +130 -0
- package/src/runtime/scroll_mutation_runtime.zig +158 -0
- package/src/runtime/scroll_tree_policy.zig +99 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +231 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/staged_rebuild_policy.zig +83 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +65 -36
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2451 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1111 -45
- package/src/runtime/ui_app.zig +1381 -650
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +667 -188
- package/src/runtime/ui_app_window_tests.zig +222 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_reload.zig +226 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +46 -26
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +503 -69
- package/src/runtime/virtual_window_policy.zig +128 -0
- package/src/runtime/web_pane_policy.zig +111 -0
- package/src/runtime/web_pane_test_cases.zig +204 -0
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_continuity_policy.zig +73 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/widget_reconcile_policy.zig +81 -0
- package/src/runtime/widget_retention_policy.zig +75 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +179 -11
- package/src/security/root.zig +1 -0
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +23 -3
- package/src/tooling/ts_core.zig +97 -4
- package/src/tooling/verbs.zig +87 -1
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +188 -0
- package/tools/corewire/core_abi.zig +55 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +361 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +300 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +39 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +28 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +59 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +204 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +269 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -5,6 +5,7 @@ const drawing_model = @import("drawing.zig");
|
|
|
5
5
|
const text_model = @import("text.zig");
|
|
6
6
|
const text_spans_model = @import("text_spans.zig");
|
|
7
7
|
const code_model = @import("code.zig");
|
|
8
|
+
const code_content = @import("code_content_policy.zig");
|
|
8
9
|
const token_model = @import("tokens.zig");
|
|
9
10
|
const widget_model = @import("widgets.zig");
|
|
10
11
|
const event_model = @import("events.zig");
|
|
@@ -22,6 +23,13 @@ const widget_render_surfaces = @import("widget_render_surfaces.zig");
|
|
|
22
23
|
const widget_render_controls = @import("widget_render_controls.zig");
|
|
23
24
|
const icon_model = @import("icons.zig");
|
|
24
25
|
const chart_model = @import("chart.zig");
|
|
26
|
+
const presentation_policy = @import("widget_presentation_policy.zig");
|
|
27
|
+
const paint_walk_policy = @import("widget_paint_walk_policy.zig");
|
|
28
|
+
const leaves = @import("leaf_plan_policy.zig");
|
|
29
|
+
const chart_plans = @import("chart_plan_policy.zig");
|
|
30
|
+
const indicator_plans = @import("indicator_plan_policy.zig");
|
|
31
|
+
const effect_plans = @import("effect_plan_policy.zig");
|
|
32
|
+
const emission = @import("render_coordination_policy.zig");
|
|
25
33
|
|
|
26
34
|
const Error = canvas.Error;
|
|
27
35
|
const ObjectId = canvas.ObjectId;
|
|
@@ -55,8 +63,8 @@ const widgetTextInputInset = widget_text_input.widgetTextInputInset;
|
|
|
55
63
|
const widgetButtonTextSize = widget_metrics.widgetButtonTextSize;
|
|
56
64
|
const widgetBodyTextSize = widget_metrics.widgetBodyTextSize;
|
|
57
65
|
const widgetLabelTextSize = widget_metrics.widgetLabelTextSize;
|
|
58
|
-
const
|
|
59
|
-
const
|
|
66
|
+
const widgetLineHeightWithTokens = widget_metrics.widgetLineHeightWithTokens;
|
|
67
|
+
const widgetTypographySizeWithTokens = widget_metrics.widgetTypographySizeWithTokens;
|
|
60
68
|
const widgetButtonInset = widget_metrics.widgetButtonInset;
|
|
61
69
|
const widgetControlInset = widget_metrics.widgetControlInset;
|
|
62
70
|
const widgetSizedDensityValue = widget_metrics.widgetSizedDensityValue;
|
|
@@ -69,7 +77,7 @@ const WidgetRenderState = widget_model.WidgetRenderState;
|
|
|
69
77
|
const WidgetSize = widget_model.WidgetSize;
|
|
70
78
|
const Widget = widget_model.Widget;
|
|
71
79
|
const estimateTextWidth = text_model.estimateTextWidth;
|
|
72
|
-
const
|
|
80
|
+
const measureTextWidthForFontWithPolicy = text_model.measureTextWidthForFontWithPolicy;
|
|
73
81
|
const affinesEqual = equality_model.affinesEqual;
|
|
74
82
|
pub const textSelectionFillColor = widget_render_style.textSelectionFillColor;
|
|
75
83
|
pub const textSelectionTextColor = widget_render_style.textSelectionTextColor;
|
|
@@ -91,11 +99,6 @@ pub const controlStrokeWidth = widget_render_style.controlStrokeWidth;
|
|
|
91
99
|
const snapHairlineStrokeRect = widget_render_style.snapHairlineStrokeRect;
|
|
92
100
|
pub const selectControlVisualTokens = widget_render_style.selectControlVisualTokens;
|
|
93
101
|
pub const textInputControlVisualTokens = widget_render_style.textInputControlVisualTokens;
|
|
94
|
-
const alertControlVisualTokens = widget_render_style.alertControlVisualTokens;
|
|
95
|
-
const cardControlVisualTokens = widget_render_style.cardControlVisualTokens;
|
|
96
|
-
const dialogControlVisualTokens = widget_render_style.dialogControlVisualTokens;
|
|
97
|
-
const drawerControlVisualTokens = widget_render_style.drawerControlVisualTokens;
|
|
98
|
-
const sheetControlVisualTokens = widget_render_style.sheetControlVisualTokens;
|
|
99
102
|
pub const listItemControlVisualTokens = widget_render_style.listItemControlVisualTokens;
|
|
100
103
|
pub const selectionControlVisualTokens = widget_render_style.selectionControlVisualTokens;
|
|
101
104
|
pub const surfaceControlVisualTokens = widget_render_style.surfaceControlVisualTokens;
|
|
@@ -144,6 +147,25 @@ const widget_render_scratch = @import("lazy_tls.zig").LazyTls(WidgetRenderScratc
|
|
|
144
147
|
/// the entry points record it here.
|
|
145
148
|
threadlocal var scrim_viewport: ?geometry.RectF = null;
|
|
146
149
|
|
|
150
|
+
// Results are copied out of the compiler arena and scoped to one retained
|
|
151
|
+
// emission. Save/restore permits nested emissions on the same thread.
|
|
152
|
+
threadlocal var presentation_plan: ?presentation_policy.Plan = null;
|
|
153
|
+
fn activePresentation(layout: anytype) ?presentation_policy.Plan {
|
|
154
|
+
if (presentation_policy.owner(layout) == null) return null;
|
|
155
|
+
const plan = presentation_plan orelse @panic("missing compiled presentation plan");
|
|
156
|
+
if (!plan.matches(layout)) @panic("mismatched compiled presentation layout");
|
|
157
|
+
return plan;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
threadlocal var painting_drag_copy: bool = false;
|
|
161
|
+
threadlocal var paint_walk_plan: ?paint_walk_policy.Plan = null;
|
|
162
|
+
fn activePaintWalk(layout: anytype) ?paint_walk_policy.Plan {
|
|
163
|
+
if (paint_walk_policy.owner(layout) == null) return null;
|
|
164
|
+
const plan = paint_walk_plan orelse @panic("missing compiled paint walk plan");
|
|
165
|
+
if (!plan.matches(layout)) @panic("mismatched compiled paint walk layout");
|
|
166
|
+
return plan;
|
|
167
|
+
}
|
|
168
|
+
|
|
147
169
|
/// Visible bounds for the direct widget-tree walk, in the coordinate
|
|
148
170
|
/// space active at the current recursion depth. The layout walk derives
|
|
149
171
|
/// the same value from retained parent links; the direct walk carries it
|
|
@@ -152,6 +174,9 @@ threadlocal var scrim_viewport: ?geometry.RectF = null;
|
|
|
152
174
|
threadlocal var tree_visible_bounds: ?geometry.RectF = null;
|
|
153
175
|
|
|
154
176
|
pub fn emitWidgetTree(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
177
|
+
const saved_policy = builder.text_run_policy;
|
|
178
|
+
builder.text_run_policy = tokens.text_run_policy;
|
|
179
|
+
defer builder.text_run_policy = saved_policy;
|
|
155
180
|
scrim_viewport = widget.frame.normalized();
|
|
156
181
|
tree_visible_bounds = widget.frame.normalized();
|
|
157
182
|
defer tree_visible_bounds = null;
|
|
@@ -163,6 +188,34 @@ pub fn emitWidgetLayout(builder: *Builder, layout: anytype, tokens: DesignTokens
|
|
|
163
188
|
}
|
|
164
189
|
|
|
165
190
|
pub fn emitWidgetLayoutWithState(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
|
|
191
|
+
const saved_policy = builder.text_run_policy;
|
|
192
|
+
builder.text_run_policy = tokens.text_run_policy;
|
|
193
|
+
defer builder.text_run_policy = saved_policy;
|
|
194
|
+
const saved_copy = painting_drag_copy;
|
|
195
|
+
painting_drag_copy = false;
|
|
196
|
+
defer painting_drag_copy = saved_copy;
|
|
197
|
+
const saved_walk = paint_walk_plan;
|
|
198
|
+
const walk = if (paint_walk_policy.owner(layout)) |policy|
|
|
199
|
+
paint_walk_policy.Plan.init(std.heap.page_allocator, policy, layout, tokens, state) catch @panic("paint walk allocation failed")
|
|
200
|
+
else
|
|
201
|
+
null;
|
|
202
|
+
paint_walk_plan = walk;
|
|
203
|
+
defer {
|
|
204
|
+
paint_walk_plan = saved_walk;
|
|
205
|
+
if (walk) |owned| owned.deinit();
|
|
206
|
+
}
|
|
207
|
+
const saved_plan = presentation_plan;
|
|
208
|
+
const saved_viewport = scrim_viewport;
|
|
209
|
+
const plan = if (presentation_policy.owner(layout)) |policy|
|
|
210
|
+
presentation_policy.Plan.init(std.heap.page_allocator, policy, layout, tokens, state) catch @panic("presentation plan allocation failed")
|
|
211
|
+
else
|
|
212
|
+
null;
|
|
213
|
+
presentation_plan = plan;
|
|
214
|
+
defer {
|
|
215
|
+
presentation_plan = saved_plan;
|
|
216
|
+
scrim_viewport = saved_viewport;
|
|
217
|
+
if (plan) |owned| owned.deinit();
|
|
218
|
+
}
|
|
166
219
|
scrim_viewport = widgetLayoutRootBounds(layout);
|
|
167
220
|
try emitWidgetLayoutChildren(builder, layout, null, tokens, state);
|
|
168
221
|
try emitWidgetLayoutClipEscapingMotions(builder, layout, tokens, state);
|
|
@@ -177,33 +230,44 @@ pub fn emitWidgetLayoutWithState(builder: *Builder, layout: anytype, tokens: Des
|
|
|
177
230
|
/// the card at the destination lane's bounds. Other layout motions stay in the
|
|
178
231
|
/// ordinary tree walk and retain their scroll clipping.
|
|
179
232
|
fn emitWidgetLayoutClipEscapingMotions(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
|
|
233
|
+
if (activePaintWalk(layout)) |plan| {
|
|
234
|
+
var current = plan.firstEscaping();
|
|
235
|
+
while (current) |index| {
|
|
236
|
+
try emitWidgetLayoutEscapingMotion(builder, layout, index, tokens, state);
|
|
237
|
+
current = plan.facts(index).next_escaping;
|
|
238
|
+
}
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
180
241
|
for (layout.nodes, 0..) |node, index| {
|
|
181
242
|
if (widget_tree.widgetEscapesAncestorClips(node.widget)) continue;
|
|
182
243
|
if (!state.layoutMotionEscapesAncestorClips(node.widget.id)) continue;
|
|
183
244
|
if (widget_tree.isWidgetHiddenInAncestors(layout, index)) continue;
|
|
184
245
|
if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) continue;
|
|
185
|
-
|
|
186
|
-
const ancestor_transform = widgetLayoutNodeAncestorEmissionTransform(layout, index) orelse return error.InvalidTransform;
|
|
187
|
-
const wrap_ancestor_transform = !affinesEqual(ancestor_transform, Affine.identity());
|
|
188
|
-
const inverse_ancestor_transform = if (wrap_ancestor_transform) ancestor_transform.inverse() orelse return error.InvalidTransform else Affine.identity();
|
|
189
|
-
if (wrap_ancestor_transform) try builder.transform(ancestor_transform);
|
|
190
|
-
try emitWidgetLayoutNode(builder, layout, index, tokens, state, .none);
|
|
191
|
-
if (wrap_ancestor_transform) try builder.transform(inverse_ancestor_transform);
|
|
246
|
+
try emitWidgetLayoutEscapingMotion(builder, layout, index, tokens, state);
|
|
192
247
|
}
|
|
193
248
|
}
|
|
249
|
+
fn emitWidgetLayoutEscapingMotion(builder: *Builder, layout: anytype, index: usize, tokens: DesignTokens, state: WidgetRenderState) Error!void {
|
|
250
|
+
const ancestor_transform = widgetLayoutNodeAncestorEmissionTransform(layout, index) orelse return error.InvalidTransform;
|
|
251
|
+
const wrap_ancestor_transform = !affinesEqual(ancestor_transform, Affine.identity());
|
|
252
|
+
const inverse_ancestor_transform = if (wrap_ancestor_transform) ancestor_transform.inverse() orelse return error.InvalidTransform else Affine.identity();
|
|
253
|
+
if (wrap_ancestor_transform) try builder.transform(ancestor_transform);
|
|
254
|
+
try emitWidgetLayoutNode(builder, layout, index, tokens, state, .none);
|
|
255
|
+
if (wrap_ancestor_transform) try builder.transform(inverse_ancestor_transform);
|
|
256
|
+
}
|
|
194
257
|
|
|
195
258
|
/// Paint the active drag source in a late, window-level pass so the card under
|
|
196
259
|
/// the pointer escapes its column's clip. Normal emission suppresses this
|
|
197
260
|
/// subtree, leaving its one current layout slot blank.
|
|
198
261
|
fn emitWidgetLayoutDragPreview(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
|
|
199
262
|
const source_id = state.drag_preview_id orelse return;
|
|
200
|
-
const source_index =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
263
|
+
const source_index = if (activePaintWalk(layout)) |plan| plan.previewIndex() orelse return else blk: {
|
|
264
|
+
const index = widget_tree.widgetIndexById(layout, source_id) orelse return;
|
|
265
|
+
// Geometry controls already follow the pointer in retained layout.
|
|
266
|
+
if (!widgetKindUsesFloatingDragPreview(layout.nodes[index].widget.kind)) return;
|
|
267
|
+
if (widget_tree.isWidgetHiddenInAncestors(layout, index)) return;
|
|
268
|
+
if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) return;
|
|
269
|
+
break :blk index;
|
|
270
|
+
};
|
|
207
271
|
|
|
208
272
|
var preview_state = WidgetRenderState{
|
|
209
273
|
.rendering_drag_preview = true,
|
|
@@ -222,6 +286,9 @@ fn emitWidgetLayoutDragPreview(builder: *Builder, layout: anytype, tokens: Desig
|
|
|
222
286
|
const translation = widgetLayoutDragPreviewTranslation(layout, source_index, state, ancestor_transform);
|
|
223
287
|
try builder.transform(translation);
|
|
224
288
|
if (wrap_ancestor_transform) try builder.transform(ancestor_transform);
|
|
289
|
+
const saved_copy = painting_drag_copy;
|
|
290
|
+
painting_drag_copy = true;
|
|
291
|
+
defer painting_drag_copy = saved_copy;
|
|
225
292
|
try emitWidgetLayoutNode(builder, layout, source_index, tokens, preview_state, .none);
|
|
226
293
|
if (wrap_ancestor_transform) try builder.transform(inverse_ancestor_transform);
|
|
227
294
|
try builder.transform(Affine.translate(-translation.tx, -translation.ty));
|
|
@@ -230,12 +297,13 @@ fn emitWidgetLayoutDragPreview(builder: *Builder, layout: anytype, tokens: Desig
|
|
|
230
297
|
/// The window-space translation around a floating drag preview. The same
|
|
231
298
|
/// value drives both the builder stack and span visibility below, so a rich
|
|
232
299
|
/// text child is culled at its lifted pose rather than its standing slot.
|
|
233
|
-
fn widgetLayoutDragPreviewTranslation(
|
|
300
|
+
pub fn widgetLayoutDragPreviewTranslation(
|
|
234
301
|
layout: anytype,
|
|
235
302
|
source_index: usize,
|
|
236
303
|
state: WidgetRenderState,
|
|
237
304
|
ancestor_transform: Affine,
|
|
238
305
|
) Affine {
|
|
306
|
+
if (activePresentation(layout)) |plan| return plan.drag() orelse @panic("missing compiled drag translation");
|
|
239
307
|
const current_frame = layout.nodes[source_index].frame.normalized();
|
|
240
308
|
const current_origin = ancestor_transform.transformPoint(geometry.PointF.init(current_frame.x, current_frame.y));
|
|
241
309
|
const source_layout_origin = state.drag_preview_origin orelse geometry.PointF.init(current_frame.x, current_frame.y);
|
|
@@ -251,6 +319,10 @@ fn widgetLayoutDragPreviewTranslation(
|
|
|
251
319
|
/// retain those bounds separately from their resolved frame so a root
|
|
252
320
|
/// dialog can be centered without shrinking its own scrim to the dialog.
|
|
253
321
|
pub fn widgetLayoutRootBounds(layout: anytype) ?geometry.RectF {
|
|
322
|
+
if (presentation_policy.owner(layout)) |policy| {
|
|
323
|
+
if (presentation_plan) |plan| if (plan.matches(layout)) return plan.root();
|
|
324
|
+
return presentation_policy.rootBounds(policy, layout);
|
|
325
|
+
}
|
|
254
326
|
if (@hasField(@TypeOf(layout), "root_bounds")) {
|
|
255
327
|
if (layout.root_bounds) |root_bounds| return root_bounds.normalized();
|
|
256
328
|
}
|
|
@@ -266,7 +338,7 @@ pub fn widgetLayoutRootBounds(layout: anytype) ?geometry.RectF {
|
|
|
266
338
|
/// Accumulated transform active while `node_index` emits. Window-level
|
|
267
339
|
/// surfaces are hoisted into the late top-level pass, so their original
|
|
268
340
|
/// ancestors do not contribute transforms there.
|
|
269
|
-
fn widgetLayoutNodeEmissionTransform(layout: anytype, node_index: usize) ?Affine {
|
|
341
|
+
pub fn widgetLayoutNodeEmissionTransform(layout: anytype, node_index: usize) ?Affine {
|
|
270
342
|
if (node_index >= layout.nodes.len) return null;
|
|
271
343
|
var indices: [widget_layout.max_widget_depth]usize = undefined;
|
|
272
344
|
var len: usize = 0;
|
|
@@ -290,7 +362,7 @@ fn widgetLayoutNodeEmissionTransform(layout: anytype, node_index: usize) ?Affine
|
|
|
290
362
|
/// The transform active while `node_index` paints in this frame. Unlike the
|
|
291
363
|
/// standing emission transform above, this includes presentation-only layout
|
|
292
364
|
/// motion and the window-level translation around a floating drag preview.
|
|
293
|
-
fn widgetLayoutNodePresentationTransform(
|
|
365
|
+
pub fn widgetLayoutNodePresentationTransform(
|
|
294
366
|
layout: anytype,
|
|
295
367
|
node_index: usize,
|
|
296
368
|
state: WidgetRenderState,
|
|
@@ -332,7 +404,8 @@ fn widgetLayoutNodePresentationTransform(
|
|
|
332
404
|
/// so it must explicitly restore this stack before painting the source.
|
|
333
405
|
/// Window-level nodes were already hoisted and therefore inherit no
|
|
334
406
|
/// original ancestors there.
|
|
335
|
-
fn widgetLayoutNodeAncestorEmissionTransform(layout: anytype, node_index: usize) ?Affine {
|
|
407
|
+
pub fn widgetLayoutNodeAncestorEmissionTransform(layout: anytype, node_index: usize) ?Affine {
|
|
408
|
+
if (activePresentation(layout)) |plan| return if (node_index < layout.nodes.len) plan.facts(node_index).ancestor else null;
|
|
336
409
|
if (node_index >= layout.nodes.len) return null;
|
|
337
410
|
if (widget_tree.widgetEscapesAncestorClips(layout.nodes[node_index].widget)) return Affine.identity();
|
|
338
411
|
const parent_index = layout.nodes[node_index].parent_index orelse return Affine.identity();
|
|
@@ -345,12 +418,17 @@ fn widgetLayoutNodeAncestorEmissionTransform(layout: anytype, node_index: usize)
|
|
|
345
418
|
/// mapped back through the exact PRESENTATION transform stack. Floating
|
|
346
419
|
/// drag previews and clip-escaping landing motions stop at their lifted
|
|
347
420
|
/// subtree root, so the culling policy matches the late unclipped paint pass.
|
|
348
|
-
fn widgetLayoutNodeVisibleBounds(
|
|
421
|
+
pub fn widgetLayoutNodeVisibleBounds(
|
|
349
422
|
layout: anytype,
|
|
350
423
|
node_index: usize,
|
|
351
424
|
bounds: geometry.RectF,
|
|
352
425
|
state: WidgetRenderState,
|
|
353
426
|
) ?geometry.RectF {
|
|
427
|
+
if (activePresentation(layout)) |plan| {
|
|
428
|
+
if (node_index >= layout.nodes.len) return null;
|
|
429
|
+
const facts = plan.facts(node_index);
|
|
430
|
+
return if (state.rendering_drag_preview) facts.preview_visible else facts.visible;
|
|
431
|
+
}
|
|
354
432
|
if (node_index >= layout.nodes.len) return null;
|
|
355
433
|
var device_visible = (widgetLayoutRootBounds(layout) orelse return null).normalized();
|
|
356
434
|
const has_layout_motion = state.layout_motions.len > 0;
|
|
@@ -401,6 +479,14 @@ fn widgetLayoutNodeVisibleBounds(
|
|
|
401
479
|
/// floating surfaces preserve their structural z-order.
|
|
402
480
|
/// Ancestor hiding still applies.
|
|
403
481
|
fn emitWidgetLayoutWindowSurfaces(builder: *Builder, layout: anytype, tokens: DesignTokens, state: WidgetRenderState) Error!void {
|
|
482
|
+
if (activePaintWalk(layout)) |plan| {
|
|
483
|
+
var current = plan.firstSurface();
|
|
484
|
+
while (current) |index| {
|
|
485
|
+
try emitWidgetLayoutNode(builder, layout, index, tokens, state, .none);
|
|
486
|
+
current = plan.facts(index).next_surface;
|
|
487
|
+
}
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
404
490
|
const surface_count = widget_tree.widgetLayoutWindowSurfaceCount(layout);
|
|
405
491
|
var emitted: usize = 0;
|
|
406
492
|
var previous: ?widget_tree.WidgetPaintOrder = null;
|
|
@@ -417,8 +503,20 @@ fn emitWidgetLayoutWindowSurfaces(builder: *Builder, layout: anytype, tokens: De
|
|
|
417
503
|
}
|
|
418
504
|
|
|
419
505
|
fn emitWidgetDepth(builder: *Builder, widget: Widget, tokens: DesignTokens, depth: usize) Error!void {
|
|
420
|
-
if (
|
|
421
|
-
|
|
506
|
+
const recipe = if (tokens.render_coordination_policy) |policy|
|
|
507
|
+
emission.Recipe.init(policy, .tree, widget, tokens, depth, 0, isSyntaxCodeParagraph(widget))
|
|
508
|
+
else
|
|
509
|
+
null;
|
|
510
|
+
if (recipe) |plan| {
|
|
511
|
+
switch (plan.status) {
|
|
512
|
+
.depth => return error.WidgetDepthExceeded,
|
|
513
|
+
.hidden => return,
|
|
514
|
+
.ready => {},
|
|
515
|
+
}
|
|
516
|
+
} else {
|
|
517
|
+
if (depth >= max_widget_depth) return error.WidgetDepthExceeded;
|
|
518
|
+
if (widget.semantics.hidden) return;
|
|
519
|
+
}
|
|
422
520
|
|
|
423
521
|
const opacity = widgetOpacity(widget);
|
|
424
522
|
if (opacity <= 0) return;
|
|
@@ -435,16 +533,17 @@ fn emitWidgetDepth(builder: *Builder, widget: Widget, tokens: DesignTokens, dept
|
|
|
435
533
|
else
|
|
436
534
|
null;
|
|
437
535
|
try builder.transform(transform);
|
|
438
|
-
try emitWidgetDepthContent(builder, widget, tokens, depth);
|
|
536
|
+
try emitWidgetDepthContent(builder, widget, tokens, depth, recipe);
|
|
439
537
|
try builder.transform(inverse_transform);
|
|
440
538
|
} else {
|
|
441
|
-
try emitWidgetDepthContent(builder, widget, tokens, depth);
|
|
539
|
+
try emitWidgetDepthContent(builder, widget, tokens, depth, recipe);
|
|
442
540
|
}
|
|
443
541
|
if (wrap_opacity) try builder.popOpacity();
|
|
444
542
|
}
|
|
445
543
|
|
|
446
|
-
fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignTokens, depth: usize) Error!void {
|
|
544
|
+
fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignTokens, depth: usize, recipe: ?emission.Recipe) Error!void {
|
|
447
545
|
const paint_widget = widgetWithFrame(widget, pixelSnapGeometryRect(tokens, widget.frame));
|
|
546
|
+
if (recipe) |plan| return emitTreeRecipe(builder, paint_widget, tokens, depth, plan);
|
|
448
547
|
try emitWidgetBackdropBlur(builder, paint_widget, tokens);
|
|
449
548
|
switch (paint_widget.kind) {
|
|
450
549
|
.stack, .row, .column => {
|
|
@@ -499,7 +598,7 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
499
598
|
}
|
|
500
599
|
},
|
|
501
600
|
.icon => try emitIconWidget(builder, paint_widget, tokens),
|
|
502
|
-
.image => try emitImageWidget(builder, paint_widget),
|
|
601
|
+
.image => try emitImageWidget(builder, paint_widget, tokens),
|
|
503
602
|
.media_surface => try emitMediaSurfaceWidget(builder, paint_widget),
|
|
504
603
|
.terminal => try emitTerminalWidget(builder, paint_widget, tokens, paint_widget.state.focused),
|
|
505
604
|
.avatar => try emitAvatarWidget(builder, paint_widget, tokens),
|
|
@@ -606,6 +705,7 @@ fn emitDataCellContent(builder: *Builder, widget: Widget, tokens: DesignTokens)
|
|
|
606
705
|
}
|
|
607
706
|
|
|
608
707
|
fn emitWidgetChildren(builder: *Builder, children: []const Widget, tokens: DesignTokens, depth: usize) Error!void {
|
|
708
|
+
if (tokens.render_coordination_policy) |policy| return emitCompiledChildren(builder, children, tokens, depth, policy, false);
|
|
609
709
|
var emitted: usize = 0;
|
|
610
710
|
var previous: ?WidgetPaintOrder = null;
|
|
611
711
|
while (emitted < children.len) : (emitted += 1) {
|
|
@@ -691,6 +791,16 @@ fn emitWidgetLayoutChildren(
|
|
|
691
791
|
tokens: DesignTokens,
|
|
692
792
|
state: WidgetRenderState,
|
|
693
793
|
) Error!void {
|
|
794
|
+
if (activePaintWalk(layout)) |plan| {
|
|
795
|
+
var current = if (parent_index) |index| plan.facts(index).first_child else plan.firstRoot();
|
|
796
|
+
while (current) |index| {
|
|
797
|
+
const facts = plan.facts(index);
|
|
798
|
+
if (!plan.activeLane(index, painting_drag_copy).suppress_flow)
|
|
799
|
+
try emitWidgetLayoutNode(builder, layout, index, tokens, state, facts.segment);
|
|
800
|
+
current = facts.next_sibling;
|
|
801
|
+
}
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
694
804
|
const child_count = widgetLayoutDirectChildCount(layout, parent_index);
|
|
695
805
|
// The layout walk's flush button-group stamp (the tree walk's twin
|
|
696
806
|
// lives in `emitButtonGroupWidget`): children of a gap-0 group get
|
|
@@ -742,25 +852,30 @@ fn emitWidgetLayoutNode(
|
|
|
742
852
|
segment: widget_model.WidgetGroupSegment,
|
|
743
853
|
) Error!void {
|
|
744
854
|
const node = layout.nodes[node_index];
|
|
745
|
-
if (
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
state.drag_preview_id != null and
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
855
|
+
const planned: ?paint_walk_policy.Lane = if (activePaintWalk(layout)) |plan| plan.activeLane(node_index, painting_drag_copy) else null;
|
|
856
|
+
if (planned) |facts| {
|
|
857
|
+
if (facts.skip) return;
|
|
858
|
+
} else {
|
|
859
|
+
if (node.widget.semantics.hidden) return;
|
|
860
|
+
if (!state.rendering_drag_preview and state.drag_preview_id != null and
|
|
861
|
+
state.drag_preview_id.? == node.widget.id and widgetKindUsesFloatingDragPreview(node.widget.kind)) return;
|
|
862
|
+
}
|
|
863
|
+
var widget = widgetWithFrame(node.widget, node.frame);
|
|
864
|
+
if (planned) |facts| {
|
|
865
|
+
widget.state.focused = facts.focused;
|
|
866
|
+
widget.state.hovered = facts.hovered;
|
|
867
|
+
widget.state.pressed = facts.pressed;
|
|
868
|
+
if (state.rendering_drag_preview and widget.id != 0) widget.id = dragPreviewWidgetId(widget.id);
|
|
869
|
+
} else widget = widgetWithRenderState(widget, state);
|
|
755
870
|
widget.group_segment = segment;
|
|
756
|
-
const opacity = widgetOpacity(widget);
|
|
871
|
+
const opacity = if (planned) |facts| facts.opacity else widgetOpacity(widget);
|
|
757
872
|
if (opacity <= 0) return;
|
|
758
|
-
const layout_motion = state.layoutMotionOffset(widget.id);
|
|
759
|
-
const wrap_layout_motion = layout_motion.dx != 0 or layout_motion.dy != 0;
|
|
760
|
-
const wrap_opacity = opacity < 1;
|
|
873
|
+
const layout_motion = if (planned) |facts| facts.motion else state.layoutMotionOffset(widget.id);
|
|
874
|
+
const wrap_layout_motion = if (planned) |facts| facts.wrap_motion else layout_motion.dx != 0 or layout_motion.dy != 0;
|
|
875
|
+
const wrap_opacity = if (planned) |facts| facts.wrap_opacity else opacity < 1;
|
|
761
876
|
const transform = widgetTransform(widget);
|
|
762
|
-
const wrap_transform = !affinesEqual(transform, Affine.identity());
|
|
763
|
-
const inverse_transform = if (
|
|
877
|
+
const wrap_transform = if (planned) |facts| facts.wrap_transform else !affinesEqual(transform, Affine.identity());
|
|
878
|
+
const inverse_transform = if (planned) |facts| facts.inverse orelse return error.InvalidTransform else if (wrap_transform) inversePaintTransform(transform) orelse return error.InvalidTransform else Affine.identity();
|
|
764
879
|
if (wrap_opacity) try builder.pushOpacity(opacity);
|
|
765
880
|
if (wrap_layout_motion) try builder.transform(Affine.translate(layout_motion.dx, layout_motion.dy));
|
|
766
881
|
if (wrap_transform) try builder.transform(transform);
|
|
@@ -786,6 +901,12 @@ fn emitWidgetLayoutNodeContent(
|
|
|
786
901
|
widget: Widget,
|
|
787
902
|
) Error!void {
|
|
788
903
|
const paint_widget = widgetWithFrame(widget, pixelSnapGeometryRect(tokens, widget.frame));
|
|
904
|
+
if (tokens.render_coordination_policy) |policy| {
|
|
905
|
+
const disclosure: u8 = if (widget.kind == .accordion) @intFromEnum(accordionLayoutDisclosure(layout, node_index, paint_widget, state)) else 0;
|
|
906
|
+
const recipe = emission.Recipe.init(policy, .retained, paint_widget, tokens, 0, disclosure, isSyntaxCodeParagraph(paint_widget));
|
|
907
|
+
if (recipe.status != .ready) @panic("inactive retained render recipe");
|
|
908
|
+
return emitRetainedRecipe(builder, layout, node_index, tokens, state, paint_widget, recipe);
|
|
909
|
+
}
|
|
789
910
|
try emitWidgetBackdropBlur(builder, paint_widget, tokens);
|
|
790
911
|
switch (paint_widget.kind) {
|
|
791
912
|
.stack, .row, .column => try emitLayoutContainerBackground(builder, paint_widget, tokens),
|
|
@@ -889,9 +1010,9 @@ fn emitWidgetLayoutNodeContent(
|
|
|
889
1010
|
}
|
|
890
1011
|
},
|
|
891
1012
|
.icon => try emitIconWidget(builder, paint_widget, tokens),
|
|
892
|
-
.image => try emitImageWidget(builder, paint_widget),
|
|
1013
|
+
.image => try emitImageWidget(builder, paint_widget, tokens),
|
|
893
1014
|
.media_surface => try emitMediaSurfaceWidget(builder, paint_widget),
|
|
894
|
-
.terminal => try emitTerminalWidget(builder, paint_widget, tokens, widgetHasLogicalFocus(paint_widget, state)),
|
|
1015
|
+
.terminal => try emitTerminalWidget(builder, paint_widget, tokens, if (activePaintWalk(layout)) |plan| plan.activeLane(node_index, painting_drag_copy).logical_focus else widgetHasLogicalFocus(paint_widget, state)),
|
|
895
1016
|
.avatar => try emitAvatarWidget(builder, paint_widget, tokens),
|
|
896
1017
|
.badge => try emitBadgeWidget(builder, paint_widget, tokens),
|
|
897
1018
|
.button, .toggle_button, .toggle => try widget_render_controls.emitButtonWidget(builder, paint_widget, tokens),
|
|
@@ -927,7 +1048,9 @@ fn emitWidgetLayoutNodeContent(
|
|
|
927
1048
|
// trees, docs scenes) the baked child state is truth — the
|
|
928
1049
|
// same override-vs-baked split `widgetWithRenderState` makes.
|
|
929
1050
|
var group = paint_widget;
|
|
930
|
-
if (
|
|
1051
|
+
if (activePaintWalk(layout)) |plan| {
|
|
1052
|
+
group.state.focused = plan.activeLane(node_index, painting_drag_copy).group_focus;
|
|
1053
|
+
} else if (!group.state.focused) {
|
|
931
1054
|
group.state.focused = if (state.focused_id != null or state.focus_visible_id != null)
|
|
932
1055
|
layoutSubtreeHasFocusVisible(layout, node_index, state)
|
|
933
1056
|
else
|
|
@@ -940,11 +1063,157 @@ fn emitWidgetLayoutNodeContent(
|
|
|
940
1063
|
try emitWidgetLayoutClippedChildren(builder, layout, node_index, tokens, state, paint_widget);
|
|
941
1064
|
}
|
|
942
1065
|
|
|
1066
|
+
// These executors provide explicit drawing capabilities. Kind routing,
|
|
1067
|
+
// ordered composition, clip selection and scrollbar admission live in the
|
|
1068
|
+
// copied program; the independent native reference above remains selectable.
|
|
1069
|
+
fn emitPlannedDraw(builder: *Builder, widget: Widget, tokens: DesignTokens, draw: emission.Draw, visible: ?geometry.RectF, logical_focus: bool, group_focus: bool) Error!void {
|
|
1070
|
+
switch (draw) {
|
|
1071
|
+
.container => try emitLayoutContainerBackground(builder, widget, tokens),
|
|
1072
|
+
.data_row => try emitDataRowWidgetWash(builder, widget, tokens),
|
|
1073
|
+
.tabs => try widget_render_surfaces.emitTabsListWidgetChrome(builder, widget, tokens),
|
|
1074
|
+
.alert => try widget_render_surfaces.emitAlertWidgetChrome(builder, widget, tokens),
|
|
1075
|
+
.card => try widget_render_surfaces.emitCardWidgetChrome(builder, widget, tokens),
|
|
1076
|
+
.dialog => try widget_render_surfaces.emitDialogSurfaceWidgetChrome(builder, widget, tokens),
|
|
1077
|
+
.drawer => try widget_render_surfaces.emitDrawerSurfaceWidgetChrome(builder, widget, tokens),
|
|
1078
|
+
.sheet => try widget_render_surfaces.emitSheetSurfaceWidgetChrome(builder, widget, tokens),
|
|
1079
|
+
.accordion => try widget_render_surfaces.emitAccordionWidgetChrome(builder, widget, tokens),
|
|
1080
|
+
.bubble => try widget_render_surfaces.emitBubbleWidgetChrome(builder, widget, tokens),
|
|
1081
|
+
.panel => try widget_render_surfaces.emitPanelWidgetChrome(builder, widget, tokens),
|
|
1082
|
+
.popover => try widget_render_surfaces.emitPopoverWidgetChrome(builder, widget, tokens),
|
|
1083
|
+
.menu => try widget_render_surfaces.emitMenuSurfaceWidgetChrome(builder, widget, tokens),
|
|
1084
|
+
.text => try emitTextWidget(builder, widget, tokens),
|
|
1085
|
+
.code_paragraph => if (visible) |bounds| {
|
|
1086
|
+
try emitVisibleCodeTextSpansWidget(builder, widget, tokens, bounds, .{});
|
|
1087
|
+
},
|
|
1088
|
+
.spans => if (visible) |bounds| {
|
|
1089
|
+
try emitVisibleTextSpansWidget(builder, widget, tokens, bounds);
|
|
1090
|
+
},
|
|
1091
|
+
.icon => try emitIconWidget(builder, widget, tokens),
|
|
1092
|
+
.image => try emitImageWidget(builder, widget, tokens),
|
|
1093
|
+
.media => try emitMediaSurfaceWidget(builder, widget),
|
|
1094
|
+
.terminal => try emitTerminalWidget(builder, widget, tokens, logical_focus),
|
|
1095
|
+
.avatar => try emitAvatarWidget(builder, widget, tokens),
|
|
1096
|
+
.badge => try emitBadgeWidget(builder, widget, tokens),
|
|
1097
|
+
.button => try widget_render_controls.emitButtonWidget(builder, widget, tokens),
|
|
1098
|
+
.icon_button => try widget_render_controls.emitIconButtonWidget(builder, widget, tokens),
|
|
1099
|
+
.select => try widget_render_controls.emitSelectWidget(builder, widget, tokens),
|
|
1100
|
+
.text_field => try widget_render_controls.emitTextFieldWidget(builder, widget, tokens),
|
|
1101
|
+
.code_editor => try emitCodeEditorWidget(builder, widget, tokens),
|
|
1102
|
+
.search => try widget_render_controls.emitSearchFieldWidget(builder, widget, tokens),
|
|
1103
|
+
.tooltip => try widget_render_controls.emitTooltipWidget(builder, widget, tokens),
|
|
1104
|
+
.menu_item => try widget_render_controls.emitMenuItemWidget(builder, widget, tokens),
|
|
1105
|
+
.list_item => try widget_render_controls.emitListItemWidget(builder, widget, tokens),
|
|
1106
|
+
.data_cell => try emitDataCellContent(builder, widget, tokens),
|
|
1107
|
+
.status => try emitStatusBarWidget(builder, widget, tokens),
|
|
1108
|
+
.segmented => try widget_render_controls.emitSegmentedControlWidget(builder, widget, tokens),
|
|
1109
|
+
.checkbox => try widget_render_controls.emitCheckboxWidget(builder, widget, tokens),
|
|
1110
|
+
.radio => try widget_render_controls.emitRadioWidget(builder, widget, tokens),
|
|
1111
|
+
.toggle => try widget_render_controls.emitToggleWidget(builder, widget, tokens),
|
|
1112
|
+
.slider => try widget_render_controls.emitSliderWidget(builder, widget, tokens),
|
|
1113
|
+
.progress => try widget_render_controls.emitProgressWidget(builder, widget, tokens),
|
|
1114
|
+
.separator => try emitSeparatorWidget(builder, widget, tokens),
|
|
1115
|
+
.split_divider => try emitSplitDividerWidget(builder, widget, tokens),
|
|
1116
|
+
.skeleton => try emitSkeletonWidget(builder, widget, tokens),
|
|
1117
|
+
.spinner => try emitSpinnerWidget(builder, widget, tokens),
|
|
1118
|
+
.chart => try emitChartWidget(builder, widget, tokens),
|
|
1119
|
+
.input_group => {
|
|
1120
|
+
var group = widget;
|
|
1121
|
+
group.state.focused = group_focus;
|
|
1122
|
+
try widget_render_controls.emitInputGroupWidget(builder, group, tokens);
|
|
1123
|
+
},
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
fn plannedClip(widget: Widget, tokens: DesignTokens, arg: u32) ?Clip {
|
|
1128
|
+
return switch (arg & 3) {
|
|
1129
|
+
0 => null,
|
|
1130
|
+
1 => widgetContentClip(widget, tokens),
|
|
1131
|
+
2 => .{ .id = widgetPartId(widget.id, 1), .rect = widget.frame },
|
|
1132
|
+
3 => .{ .id = widgetPartId(widget.id, 9), .rect = widget.frame },
|
|
1133
|
+
else => unreachable,
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
fn emitCompiledChildren(builder: *Builder, children: []const Widget, tokens: DesignTokens, depth: usize, policy: emission.Policy, stamp: bool) Error!void {
|
|
1137
|
+
const plan = emission.ChildPlan.init(std.heap.page_allocator, policy, children, tokens, stamp) catch @panic("render child allocation failed");
|
|
1138
|
+
defer plan.deinit();
|
|
1139
|
+
for (0..plan.count) |i| {
|
|
1140
|
+
var child = children[plan.index(i)];
|
|
1141
|
+
if (stamp) child.group_segment = plan.segment(i);
|
|
1142
|
+
try emitWidgetDepth(builder, child, tokens, depth + 1);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
fn emitTreeRecipe(builder: *Builder, widget: Widget, tokens: DesignTokens, depth: usize, recipe: emission.Recipe) Error!void {
|
|
1146
|
+
for (recipe.commands[0..recipe.count]) |command| switch (command.opcode) {
|
|
1147
|
+
.backdrop => try emitWidgetBackdropBlur(builder, widget, tokens),
|
|
1148
|
+
.scrim => try emitModalSurfaceScrim(builder, widget, tokens),
|
|
1149
|
+
.draw => {
|
|
1150
|
+
const draw: emission.Draw = @enumFromInt(command.arg);
|
|
1151
|
+
const visible = if (draw == .spans or draw == .code_paragraph) visibleBoundsInsideClip(tree_visible_bounds, widget.frame) else null;
|
|
1152
|
+
const group_focus = if (draw == .input_group) widget.state.focused or widgetSubtreeHasFocusedState(widget) else widget.state.focused;
|
|
1153
|
+
try emitPlannedDraw(builder, widget, tokens, draw, visible, widget.state.focused, group_focus);
|
|
1154
|
+
},
|
|
1155
|
+
.children => {
|
|
1156
|
+
const child_tokens = if (command.arg & 256 != 0) widget_render_surfaces.bubbleContentTokens(widget, tokens) else tokens;
|
|
1157
|
+
const saved_visible = tree_visible_bounds;
|
|
1158
|
+
defer tree_visible_bounds = saved_visible;
|
|
1159
|
+
const clip = plannedClip(widget, child_tokens, command.arg);
|
|
1160
|
+
if (clip) |value| {
|
|
1161
|
+
tree_visible_bounds = visibleBoundsInsideClip(saved_visible, value.rect);
|
|
1162
|
+
try builder.pushClip(value);
|
|
1163
|
+
}
|
|
1164
|
+
try emitCompiledChildren(builder, widget.children, child_tokens, depth, tokens.render_coordination_policy.?, command.arg & 512 != 0);
|
|
1165
|
+
if (clip != null) try builder.popClip();
|
|
1166
|
+
},
|
|
1167
|
+
.separators => try emitTableRowSeparators(builder, widget.children, tokens),
|
|
1168
|
+
.scrollbars => try widget_render_scroll.emitScrollViewScrollbars(builder, widget.frame, widget_render_scroll.widgetScrollAxisMetricsForWidget(widget, tokens, .vertical), if (command.arg == 1) widget_render_scroll.widgetScrollAxisMetricsForWidget(widget, tokens, .horizontal) else .{}, tokens, widget.id),
|
|
1169
|
+
.reactions => try widget_render_surfaces.emitBubbleWidgetReactions(builder, widget, tokens),
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
fn emitRetainedRecipe(builder: *Builder, layout: anytype, node_index: usize, tokens: DesignTokens, state: WidgetRenderState, widget: Widget, recipe: emission.Recipe) Error!void {
|
|
1173
|
+
for (recipe.commands[0..recipe.count]) |command| switch (command.opcode) {
|
|
1174
|
+
.backdrop => try emitWidgetBackdropBlur(builder, widget, tokens),
|
|
1175
|
+
.scrim => try emitModalSurfaceScrim(builder, widget, tokens),
|
|
1176
|
+
.draw => {
|
|
1177
|
+
const draw: emission.Draw = @enumFromInt(command.arg);
|
|
1178
|
+
const visible = if (draw == .spans or draw == .code_paragraph) widgetLayoutNodeVisibleBounds(layout, node_index, widget.frame, state) else null;
|
|
1179
|
+
const logical_focus = if (draw == .terminal) if (activePaintWalk(layout)) |plan| plan.activeLane(node_index, painting_drag_copy).logical_focus else widgetHasLogicalFocus(widget, state) else widget.state.focused;
|
|
1180
|
+
var group_focus = widget.state.focused;
|
|
1181
|
+
if (draw == .input_group) {
|
|
1182
|
+
if (activePaintWalk(layout)) |plan| group_focus = plan.activeLane(node_index, painting_drag_copy).group_focus else if (!group_focus) group_focus = if (state.focused_id != null or state.focus_visible_id != null)
|
|
1183
|
+
layoutSubtreeHasFocusVisible(layout, node_index, state)
|
|
1184
|
+
else
|
|
1185
|
+
layoutSubtreeHasBakedFocus(layout, node_index);
|
|
1186
|
+
}
|
|
1187
|
+
try emitPlannedDraw(builder, widget, tokens, draw, visible, logical_focus, group_focus);
|
|
1188
|
+
},
|
|
1189
|
+
.children => {
|
|
1190
|
+
const child_tokens = if (command.arg & 256 != 0) widget_render_surfaces.bubbleContentTokens(widget, tokens) else tokens;
|
|
1191
|
+
const clip = plannedClip(widget, child_tokens, command.arg);
|
|
1192
|
+
if (clip) |value| try builder.pushClip(value);
|
|
1193
|
+
try emitWidgetLayoutChildren(builder, layout, node_index, child_tokens, state);
|
|
1194
|
+
if (clip != null) try builder.popClip();
|
|
1195
|
+
},
|
|
1196
|
+
.separators => try emitTableRowSeparatorsLayout(builder, layout, node_index, tokens, widget, command.arg == 1),
|
|
1197
|
+
.scrollbars => try widget_render_scroll.emitScrollViewScrollbars(builder, widget.frame, widgetScrollAxisMetrics(layout, node_index, .vertical), if (command.arg == 1) widgetScrollAxisMetrics(layout, node_index, .horizontal) else .{}, tokens, widget.id),
|
|
1198
|
+
.reactions => try widget_render_surfaces.emitBubbleWidgetReactions(builder, widget, tokens),
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
|
|
943
1202
|
/// Flow and stacking containers have no implicit surface treatment. An
|
|
944
1203
|
/// actionable container, however, wears the same neutral hover/pressed
|
|
945
1204
|
/// ladder as a list row over its full hit frame; an authored background is
|
|
946
1205
|
/// its rest fill. Non-actionable containers paint only that authored fill.
|
|
947
1206
|
fn emitLayoutContainerBackground(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
1207
|
+
if (tokens.control_command_policy != null) {
|
|
1208
|
+
var plan = effect_plans.Plan.init(.container, widget, tokens, null);
|
|
1209
|
+
plan.run();
|
|
1210
|
+
if (plan.wantsListFill()) {
|
|
1211
|
+
plan.reply(listItemFillColor(widget, tokens, widget.state));
|
|
1212
|
+
plan.run();
|
|
1213
|
+
if (plan.wantsListFill()) @panic("effect plan repeated its appearance query");
|
|
1214
|
+
}
|
|
1215
|
+
return executeEffectPlan(builder, plan);
|
|
1216
|
+
}
|
|
948
1217
|
const actions = widget.semantics.actions;
|
|
949
1218
|
const actionable = widget.id != 0 and !widget.state.disabled and
|
|
950
1219
|
(actions.press or actions.toggle or actions.drag);
|
|
@@ -1017,7 +1286,7 @@ fn pixelSnapValueWithScale(value: f32, scale: f32) f32 {
|
|
|
1017
1286
|
return @round(value * scale) / scale;
|
|
1018
1287
|
}
|
|
1019
1288
|
|
|
1020
|
-
fn pixelSnapGeometryRect(tokens: DesignTokens, rect: geometry.RectF) geometry.RectF {
|
|
1289
|
+
pub fn pixelSnapGeometryRect(tokens: DesignTokens, rect: geometry.RectF) geometry.RectF {
|
|
1021
1290
|
if (!tokens.pixel_snap.geometry) return rect;
|
|
1022
1291
|
const scale = pixelSnapScale(tokens) orelse return rect;
|
|
1023
1292
|
const normalized = rect.normalized();
|
|
@@ -1047,6 +1316,11 @@ fn pixelSnapTextPoint(tokens: DesignTokens, point: geometry.PointF) geometry.Poi
|
|
|
1047
1316
|
}
|
|
1048
1317
|
|
|
1049
1318
|
fn emitWidgetBackdropBlur(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
1319
|
+
if (tokens.control_command_policy != null) {
|
|
1320
|
+
var plan = effect_plans.Plan.init(.backdrop, widget, tokens, null);
|
|
1321
|
+
plan.run();
|
|
1322
|
+
return executeEffectPlan(builder, plan);
|
|
1323
|
+
}
|
|
1050
1324
|
const radius = widgetBackdropBlur(widget, tokens);
|
|
1051
1325
|
if (radius <= 0 or widget.frame.normalized().isEmpty()) return;
|
|
1052
1326
|
try builder.blur(.{
|
|
@@ -1057,6 +1331,11 @@ fn emitWidgetBackdropBlur(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
1057
1331
|
}
|
|
1058
1332
|
|
|
1059
1333
|
pub fn widgetBackdropBlur(widget: Widget, tokens: DesignTokens) f32 {
|
|
1334
|
+
if (tokens.control_command_policy != null) {
|
|
1335
|
+
var plan = effect_plans.Plan.init(.backdrop, widget, tokens, null);
|
|
1336
|
+
plan.run();
|
|
1337
|
+
return plan.scalar();
|
|
1338
|
+
}
|
|
1060
1339
|
const explicit = nonNegative(widget.backdrop_blur);
|
|
1061
1340
|
if (explicit > 0) return explicit;
|
|
1062
1341
|
if (widget.backdrop_blur_token) |token| return nonNegative(tokens.blur.value(token));
|
|
@@ -1069,6 +1348,11 @@ pub fn widgetBackdropBlur(widget: Widget, tokens: DesignTokens) f32 {
|
|
|
1069
1348
|
/// blur + dim treatment. Anchored surfaces (popover, menus, tooltips)
|
|
1070
1349
|
/// are NOT modal and never scrim.
|
|
1071
1350
|
pub fn widgetEmitsModalScrim(widget: Widget, tokens: DesignTokens) bool {
|
|
1351
|
+
if (tokens.control_command_policy != null) {
|
|
1352
|
+
var plan = effect_plans.Plan.init(.scrim, widget, tokens, null);
|
|
1353
|
+
plan.run();
|
|
1354
|
+
return plan.flag();
|
|
1355
|
+
}
|
|
1072
1356
|
if (!widget.scrim) return false;
|
|
1073
1357
|
return switch (widget.kind) {
|
|
1074
1358
|
.dialog, .drawer, .sheet => tokens.colors.scrim.a > 0 or nonNegative(tokens.blur.scrim) > 0,
|
|
@@ -1088,6 +1372,11 @@ pub fn widgetEmitsModalScrim(widget: Widget, tokens: DesignTokens) bool {
|
|
|
1088
1372
|
/// wrappers, and honoring reduced motion costs nothing because nothing
|
|
1089
1373
|
/// here moves.
|
|
1090
1374
|
fn emitModalSurfaceScrim(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
1375
|
+
if (tokens.control_command_policy != null) {
|
|
1376
|
+
var plan = effect_plans.Plan.init(.scrim, widget, tokens, scrim_viewport);
|
|
1377
|
+
plan.run();
|
|
1378
|
+
return executeEffectPlan(builder, plan);
|
|
1379
|
+
}
|
|
1091
1380
|
if (!widgetEmitsModalScrim(widget, tokens)) return;
|
|
1092
1381
|
const viewport = (scrim_viewport orelse widget.frame.normalized());
|
|
1093
1382
|
if (viewport.isEmpty()) return;
|
|
@@ -1108,6 +1397,18 @@ fn emitModalSurfaceScrim(builder: *Builder, widget: Widget, tokens: DesignTokens
|
|
|
1108
1397
|
}
|
|
1109
1398
|
}
|
|
1110
1399
|
|
|
1400
|
+
/// Draw copied surface effect commands through native capabilities.
|
|
1401
|
+
fn executeEffectPlan(builder: *Builder, plan: effect_plans.Plan) Error!void {
|
|
1402
|
+
for (0..plan.count()) |index| {
|
|
1403
|
+
const command = plan.command(index);
|
|
1404
|
+
switch (command.op) {
|
|
1405
|
+
.fill_round => try builder.fillRoundedRect(.{ .id = command.id, .rect = command.rect, .radius = Radius.all(command.radius), .fill = colorFill(command.color) }),
|
|
1406
|
+
.blur => try builder.blur(.{ .id = command.id, .rect = command.rect, .radius = command.radius }),
|
|
1407
|
+
.fill_rect => try builder.fillRect(.{ .id = command.id, .rect = command.rect, .fill = colorFill(command.color) }),
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1111
1412
|
fn widgetContentClip(widget: Widget, tokens: DesignTokens) Clip {
|
|
1112
1413
|
return .{
|
|
1113
1414
|
.id = widgetPartId(widget.id, 9),
|
|
@@ -1117,17 +1418,35 @@ fn widgetContentClip(widget: Widget, tokens: DesignTokens) Clip {
|
|
|
1117
1418
|
}
|
|
1118
1419
|
|
|
1119
1420
|
fn widgetContentClipRadius(widget: Widget, tokens: DesignTokens) Radius {
|
|
1421
|
+
if (tokens.control_command_policy != null) {
|
|
1422
|
+
var plan = effect_plans.Plan.init(.clip, widget, tokens, null);
|
|
1423
|
+
plan.run();
|
|
1424
|
+
return switch (plan.clipSource()) {
|
|
1425
|
+
.none => .{},
|
|
1426
|
+
.bubble => widget_render_surfaces.bubbleWidgetRadius(widget, tokens),
|
|
1427
|
+
.large => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg),
|
|
1428
|
+
.extra_large => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.xl),
|
|
1429
|
+
.medium => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.md),
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1120
1432
|
if (!widget.layout.clip_content) return .{};
|
|
1121
1433
|
return switch (widget.kind) {
|
|
1122
1434
|
// The bubble clips at its own capsule arc so wide content (an
|
|
1123
1435
|
// image child, a full-bleed row) shears along the chrome's
|
|
1124
1436
|
// corners instead of the generic surface radius.
|
|
1125
1437
|
.bubble => widget_render_surfaces.bubbleWidgetRadius(widget, tokens),
|
|
1126
|
-
|
|
1438
|
+
// Keep a surface's child clip exactly in step with its chrome.
|
|
1439
|
+
// In particular, an explicit `radius="none"` must not round a
|
|
1440
|
+
// full-bleed child after the surface itself has become square.
|
|
1441
|
+
.alert => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg),
|
|
1442
|
+
.card => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg),
|
|
1443
|
+
.resizable, .panel, .menu_surface, .dropdown_menu => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg),
|
|
1127
1444
|
.accordion => .{},
|
|
1128
|
-
.dialog
|
|
1129
|
-
.drawer
|
|
1130
|
-
.
|
|
1445
|
+
.dialog => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.xl),
|
|
1446
|
+
.drawer => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.xl),
|
|
1447
|
+
.sheet => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.lg),
|
|
1448
|
+
.popover => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.xl),
|
|
1449
|
+
.tooltip => controlRadius(widget, surfaceControlVisualTokens(widget, tokens), tokens.radius.md),
|
|
1131
1450
|
else => .{},
|
|
1132
1451
|
};
|
|
1133
1452
|
}
|
|
@@ -1205,6 +1524,7 @@ fn emitAccordionWidget(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
1205
1524
|
const AccordionLayoutDisclosure = enum { closed, revealing, open };
|
|
1206
1525
|
|
|
1207
1526
|
fn accordionLayoutDisclosure(layout: anytype, node_index: usize, widget: Widget, state: WidgetRenderState) AccordionLayoutDisclosure {
|
|
1527
|
+
if (activePaintWalk(layout)) |plan| return @enumFromInt(@intFromEnum(plan.activeLane(node_index, painting_drag_copy).disclosure));
|
|
1208
1528
|
if (accordionChildrenVisible(widget)) {
|
|
1209
1529
|
return if (widget_tree.disclosureSettledOpen(layout, node_index)) .open else .revealing;
|
|
1210
1530
|
}
|
|
@@ -1966,7 +2286,8 @@ fn emitVisibleWrappedEditableCodeLines(
|
|
|
1966
2286
|
.color = .syntax_plain,
|
|
1967
2287
|
};
|
|
1968
2288
|
break :blk span_storage[0..1];
|
|
1969
|
-
} else
|
|
2289
|
+
} else code_content.highlight(
|
|
2290
|
+
tokens.code_content_policy,
|
|
1970
2291
|
line_source,
|
|
1971
2292
|
widget.code_language,
|
|
1972
2293
|
&span_storage,
|
|
@@ -2113,7 +2434,8 @@ fn emitVisibleEditableCodeLines(
|
|
|
2113
2434
|
var state: code_model.HighlightState = .{};
|
|
2114
2435
|
var span_storage: [text_spans_model.max_text_spans_per_paragraph]text_spans_model.TextSpan = undefined;
|
|
2115
2436
|
if (line_start > 0) {
|
|
2116
|
-
_ =
|
|
2437
|
+
_ = code_content.highlight(
|
|
2438
|
+
tokens.code_content_policy,
|
|
2117
2439
|
widget.text[0..line_start],
|
|
2118
2440
|
widget.code_language,
|
|
2119
2441
|
&span_storage,
|
|
@@ -2149,7 +2471,8 @@ fn emitVisibleEditableCodeLines(
|
|
|
2149
2471
|
.color = .syntax_plain,
|
|
2150
2472
|
};
|
|
2151
2473
|
break :blk span_storage[0..1];
|
|
2152
|
-
} else
|
|
2474
|
+
} else code_content.highlight(
|
|
2475
|
+
tokens.code_content_policy,
|
|
2153
2476
|
line_source,
|
|
2154
2477
|
widget.code_language,
|
|
2155
2478
|
&span_storage,
|
|
@@ -2684,10 +3007,11 @@ fn emitIconWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error
|
|
|
2684
3007
|
/// widget's foreground color token.
|
|
2685
3008
|
fn emitVectorIconWidget(builder: *Builder, widget: Widget, tokens: DesignTokens, icon: *const icon_model.Icon) Error!void {
|
|
2686
3009
|
const color = widgetForegroundColor(widget, tokens, tokens.colors.text);
|
|
2687
|
-
try widget_render_controls.
|
|
3010
|
+
try widget_render_controls.emitVectorIconWithTokens(builder, widget.id, 1, widget.frame, color, icon, tokens);
|
|
2688
3011
|
}
|
|
2689
3012
|
|
|
2690
|
-
fn emitImageWidget(builder: *Builder, widget: Widget) Error!void {
|
|
3013
|
+
fn emitImageWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3014
|
+
if (tokens.control_command_policy != null) return emitCompiledImage(builder, widget, tokens);
|
|
2691
3015
|
if (widget.image_id == 0 or widget.frame.normalized().isEmpty()) return;
|
|
2692
3016
|
const clips_image = widget.image_fit == .cover;
|
|
2693
3017
|
if (clips_image) try builder.pushClip(.{ .id = widgetPartId(widget.id, 2), .rect = widget.frame });
|
|
@@ -2968,6 +3292,7 @@ fn emitMediaSurfaceWidget(builder: *Builder, widget: Widget) Error!void {
|
|
|
2968
3292
|
}
|
|
2969
3293
|
|
|
2970
3294
|
fn emitAvatarWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3295
|
+
if (tokens.control_command_policy != null) return emitCompiledAvatar(builder, widget, tokens);
|
|
2971
3296
|
const visual = componentControlVisualTokens(widget, tokens);
|
|
2972
3297
|
const radius = componentPillRadius(widget, visual, widget.frame.height * 0.5);
|
|
2973
3298
|
const background = widgetBackgroundColor(widget, visual.background orelse tokens.colors.surface_subtle);
|
|
@@ -3030,6 +3355,7 @@ fn emitAvatarWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Err
|
|
|
3030
3355
|
}
|
|
3031
3356
|
|
|
3032
3357
|
fn emitBadgeWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3358
|
+
if (tokens.control_command_policy != null) return emitCompiledBadge(builder, widget, tokens);
|
|
3033
3359
|
const visual = componentControlVisualTokens(widget, tokens);
|
|
3034
3360
|
const radius = componentPillRadius(widget, visual, widget.frame.height * 0.5);
|
|
3035
3361
|
const text_size = widget_metrics.widgetBadgeTextSize(widget, tokens);
|
|
@@ -3068,11 +3394,11 @@ fn emitBadgeWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Erro
|
|
|
3068
3394
|
icon_extent,
|
|
3069
3395
|
icon_extent,
|
|
3070
3396
|
);
|
|
3071
|
-
try widget_render_controls.
|
|
3397
|
+
try widget_render_controls.emitVectorIconWithTokens(builder, widget.id, 4, icon_frame, content_color, resolved, tokens);
|
|
3072
3398
|
return;
|
|
3073
3399
|
}
|
|
3074
3400
|
const icon_frame = geometry.RectF.init(widget.frame.x + text_inset, icon_y, icon_extent, icon_extent);
|
|
3075
|
-
try widget_render_controls.
|
|
3401
|
+
try widget_render_controls.emitVectorIconWithTokens(builder, widget.id, 4, icon_frame, content_color, resolved, tokens);
|
|
3076
3402
|
const shift = icon_extent + widget_metrics.widgetBadgeIconGap(widget, tokens);
|
|
3077
3403
|
const text_frame = geometry.RectF.init(
|
|
3078
3404
|
widget.frame.x + shift,
|
|
@@ -3105,6 +3431,7 @@ fn emitBadgeWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Erro
|
|
|
3105
3431
|
}
|
|
3106
3432
|
|
|
3107
3433
|
fn emitSeparatorWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3434
|
+
if (tokens.control_command_policy != null) return emitCompiledSeparator(builder, widget, tokens);
|
|
3108
3435
|
const visual = componentControlVisualTokens(widget, tokens);
|
|
3109
3436
|
const normalized = widget.frame.normalized();
|
|
3110
3437
|
if (normalized.isEmpty()) return;
|
|
@@ -3125,6 +3452,7 @@ fn emitSeparatorWidget(builder: *Builder, widget: Widget, tokens: DesignTokens)
|
|
|
3125
3452
|
/// the hit target, so the affordance appears as the pointer reaches
|
|
3126
3453
|
/// it); keyboard focus draws the standard focus ring around the band.
|
|
3127
3454
|
fn emitSplitDividerWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3455
|
+
if (tokens.control_command_policy != null) return emitCompiledDivider(builder, widget, tokens);
|
|
3128
3456
|
const visual = componentControlVisualTokens(widget, tokens);
|
|
3129
3457
|
const normalized = widget.frame.normalized();
|
|
3130
3458
|
if (normalized.isEmpty()) return;
|
|
@@ -3162,6 +3490,7 @@ fn emitSplitDividerWidget(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
3162
3490
|
}
|
|
3163
3491
|
|
|
3164
3492
|
fn emitStatusBarWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3493
|
+
if (tokens.control_command_policy != null) return emitCompiledStatus(builder, widget, tokens);
|
|
3165
3494
|
const frame = widget.frame.normalized();
|
|
3166
3495
|
if (frame.isEmpty()) return;
|
|
3167
3496
|
|
|
@@ -3225,6 +3554,7 @@ pub fn skeletonWidgetFillCommandId(id: ObjectId) ObjectId {
|
|
|
3225
3554
|
}
|
|
3226
3555
|
|
|
3227
3556
|
fn emitSkeletonWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3557
|
+
if (tokens.control_command_policy != null) return emitCompiledSkeleton(builder, widget, tokens);
|
|
3228
3558
|
const visual = componentControlVisualTokens(widget, tokens);
|
|
3229
3559
|
try builder.fillRoundedRect(.{
|
|
3230
3560
|
.id = widgetPartId(widget.id, 1),
|
|
@@ -3238,6 +3568,7 @@ fn emitSkeletonWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) E
|
|
|
3238
3568
|
/// edge to edge (the table register's row hover), square-cornered so
|
|
3239
3569
|
/// adjacent rows tile. Rows at rest draw nothing.
|
|
3240
3570
|
fn emitDataRowWidgetWash(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3571
|
+
if (tokens.control_command_policy != null) return emitCompiledWash(builder, widget, tokens);
|
|
3241
3572
|
const fill = listItemFillColor(widget, tokens, widget.state);
|
|
3242
3573
|
if (fill.a <= 0) return;
|
|
3243
3574
|
try builder.fillRect(.{
|
|
@@ -3252,6 +3583,7 @@ fn emitDataRowWidgetWash(builder: *Builder, widget: Widget, tokens: DesignTokens
|
|
|
3252
3583
|
/// is a part of the ROW above it (stable command id per row), drawn by
|
|
3253
3584
|
/// the table so the last row can stay open-edged.
|
|
3254
3585
|
fn emitTableRowSeparators(builder: *Builder, children: []const Widget, tokens: DesignTokens) Error!void {
|
|
3586
|
+
if (tokens.control_command_policy != null) return emitCompiledTableRows(builder, children, tokens);
|
|
3255
3587
|
var last_row_index: ?usize = null;
|
|
3256
3588
|
for (children, 0..) |child, index| {
|
|
3257
3589
|
if (child.kind == .data_row and !child.semantics.hidden) last_row_index = index;
|
|
@@ -3264,6 +3596,7 @@ fn emitTableRowSeparators(builder: *Builder, children: []const Widget, tokens: D
|
|
|
3264
3596
|
}
|
|
3265
3597
|
|
|
3266
3598
|
fn emitTableRowSeparatorsLayout(builder: *Builder, layout: anytype, table_index: usize, tokens: DesignTokens, table: Widget, clip_to_table: bool) Error!void {
|
|
3599
|
+
if (tokens.control_command_policy != null) return emitCompiledTableRowsLayout(builder, layout, table_index, tokens, table, clip_to_table);
|
|
3267
3600
|
if (clip_to_table) try builder.pushClip(.{ .id = widgetPartId(table.id, 9), .rect = table.frame });
|
|
3268
3601
|
var last_row_index: ?usize = null;
|
|
3269
3602
|
for (layout.nodes, 0..) |node, index| {
|
|
@@ -3329,6 +3662,7 @@ const spinner_arc_stroke_ratio: f32 = 2.0 / 24.0;
|
|
|
3329
3662
|
/// the static pose shows the head-to-tail trail.
|
|
3330
3663
|
fn emitSpinnerWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3331
3664
|
const visual = componentControlVisualTokens(widget, tokens);
|
|
3665
|
+
if (tokens.control_command_policy != null) return executeIndicatorPlan(builder, widget, tokens, visual);
|
|
3332
3666
|
const normalized = widget.frame.normalized();
|
|
3333
3667
|
if (normalized.isEmpty()) return;
|
|
3334
3668
|
const size = @min(normalized.width, normalized.height);
|
|
@@ -3475,6 +3809,25 @@ fn emitSpinnerSegments(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
3475
3809
|
}
|
|
3476
3810
|
}
|
|
3477
3811
|
|
|
3812
|
+
/// Execute the portable spinner plan: resolve appearance when asked, then
|
|
3813
|
+
/// draw each copied path through the native builder.
|
|
3814
|
+
fn executeIndicatorPlan(builder: *Builder, widget: Widget, tokens: DesignTokens, visual: ControlVisualTokens) Error!void {
|
|
3815
|
+
var plan = indicator_plans.Plan.init(widget, tokens);
|
|
3816
|
+
if (plan.run() == .appearance) {
|
|
3817
|
+
const ink = widgetForegroundColor(widget, tokens, visual.foreground orelse tokens.colors.text);
|
|
3818
|
+
const stroke = if (tokens.metrics.spinner_style == .arc) controlStrokeWidth(widget, visual, plan.strokeFallback()) else 0;
|
|
3819
|
+
plan.reply(ink, stroke);
|
|
3820
|
+
if (plan.run() != .done) @panic("indicator plan repeated its appearance query");
|
|
3821
|
+
}
|
|
3822
|
+
for (0..plan.count()) |index| {
|
|
3823
|
+
const elements = try builder.allocPathElements(plan.elementCount(index));
|
|
3824
|
+
for (elements, 0..) |*element, ordinal| element.* = plan.element(index, ordinal);
|
|
3825
|
+
if (plan.stroked(index)) {
|
|
3826
|
+
try builder.strokePath(.{ .id = plan.commandId(index), .elements = elements, .stroke = .{ .fill = colorFill(plan.color(index)), .width = plan.strokeWidth() }, .cap = .round });
|
|
3827
|
+
} else try builder.fillPath(.{ .id = plan.commandId(index), .elements = elements, .fill = colorFill(plan.color(index)) });
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
|
|
3478
3831
|
/// The command id of a spinner's accent arc segment — the part slot
|
|
3479
3832
|
/// `emitSpinnerWidget` draws it under — so the runtime can target the
|
|
3480
3833
|
/// arc with a looping rotation render animation.
|
|
@@ -3486,6 +3839,7 @@ pub fn spinnerWidgetArcCommandId(id: ObjectId) ObjectId {
|
|
|
3486
3839
|
/// center of the PAINTED frame (pixel-snapped exactly like emission),
|
|
3487
3840
|
/// so the sampled rotation never wobbles against the emitted geometry.
|
|
3488
3841
|
pub fn spinnerWidgetRotationCenter(widget: Widget, tokens: DesignTokens) geometry.PointF {
|
|
3842
|
+
if (tokens.control_command_policy != null) return indicator_plans.anchors(widget, tokens).center;
|
|
3489
3843
|
const normalized = pixelSnapGeometryRect(tokens, widget.frame).normalized();
|
|
3490
3844
|
return geometry.PointF.init(normalized.x + normalized.width * 0.5, normalized.y + normalized.height * 0.5);
|
|
3491
3845
|
}
|
|
@@ -3503,6 +3857,7 @@ pub fn spinnerWidgetSegmentCommandId(id: ObjectId, index: usize) ObjectId {
|
|
|
3503
3857
|
/// range). Emitter and runtime both resolve the count through here, so
|
|
3504
3858
|
/// the armed opacity loops always match the emitted commands one-to-one.
|
|
3505
3859
|
pub fn spinnerWidgetSegmentCount(tokens: DesignTokens) usize {
|
|
3860
|
+
if (tokens.control_command_policy != null) return indicator_plans.anchors(.{ .kind = .spinner }, tokens).count;
|
|
3506
3861
|
return @intCast(std.math.clamp(tokens.metrics.spinner_segment_count, 3, 15));
|
|
3507
3862
|
}
|
|
3508
3863
|
|
|
@@ -3520,6 +3875,11 @@ pub fn spinnerWidgetSegmentCount(tokens: DesignTokens) usize {
|
|
|
3520
3875
|
/// (`chartWidgetPlotRect`) only when opted in, so unlabeled charts
|
|
3521
3876
|
/// render byte-identically to before.
|
|
3522
3877
|
fn emitChartWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
3878
|
+
if (tokens.control_command_policy != null) {
|
|
3879
|
+
var plan = chart_plans.Plan.init(widget, tokens, .render, .zero(), .zero(), null);
|
|
3880
|
+
defer plan.deinit();
|
|
3881
|
+
return executeChartPlan(&plan, builder);
|
|
3882
|
+
}
|
|
3523
3883
|
const data = widget.chart;
|
|
3524
3884
|
const plot = chartWidgetPlotRect(widget, tokens);
|
|
3525
3885
|
if (plot.isEmpty() or plot.width <= 0 or plot.height <= 0) return;
|
|
@@ -3597,6 +3957,12 @@ const chart_x_label_min_gap: f32 = 12;
|
|
|
3597
3957
|
/// cursor snaps exactly where the ink is. Without labels this is the
|
|
3598
3958
|
/// padded frame, byte-identical to the pre-label contract.
|
|
3599
3959
|
pub fn chartWidgetPlotRect(widget: Widget, tokens: DesignTokens) geometry.RectF {
|
|
3960
|
+
if (tokens.control_command_policy != null) {
|
|
3961
|
+
var plan = chart_plans.Plan.init(widget, tokens, .plot, .zero(), .zero(), null);
|
|
3962
|
+
defer plan.deinit();
|
|
3963
|
+
executeChartPlan(&plan, null) catch unreachable;
|
|
3964
|
+
return plan.plot();
|
|
3965
|
+
}
|
|
3600
3966
|
const data = widget.chart;
|
|
3601
3967
|
var plot = widget.frame.inset(widget.layout.padding).normalized();
|
|
3602
3968
|
if (data.x_labels.len > 0) {
|
|
@@ -3629,7 +3995,7 @@ fn chartYLabelGutterWidth(data: chart_model.ChartData, tokens: DesignTokens) f32
|
|
|
3629
3995
|
var buffer: [chart_model.max_chart_value_label_bytes]u8 = undefined;
|
|
3630
3996
|
for (0..lattice.count) |ordinal| {
|
|
3631
3997
|
const text = chart_model.formatChartValue(&buffer, lattice.value(ordinal), lattice.decimals);
|
|
3632
|
-
widest = @max(widest,
|
|
3998
|
+
widest = @max(widest, measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, text, size));
|
|
3633
3999
|
}
|
|
3634
4000
|
return @ceil(widest) + chart_axis_label_gap;
|
|
3635
4001
|
}
|
|
@@ -3653,7 +4019,7 @@ fn emitChartAxisLabels(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
3653
4019
|
const value = lattice.value(ordinal);
|
|
3654
4020
|
const formatted = chart_model.formatChartValue(&buffer, value, lattice.decimals);
|
|
3655
4021
|
const text = try builder.allocChartLabelBytes(formatted);
|
|
3656
|
-
const width =
|
|
4022
|
+
const width = measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, text, size);
|
|
3657
4023
|
const line_y = chartMapY(value, domain, plot, 0);
|
|
3658
4024
|
const top = std.math.clamp(line_y - line_height * 0.5, content.y, @max(content.y, content.maxY() - line_height));
|
|
3659
4025
|
try builder.drawText(.{
|
|
@@ -3675,7 +4041,7 @@ fn emitChartAxisLabels(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
3675
4041
|
// never touch. Pure over the labels and the plot width.
|
|
3676
4042
|
var widest: f32 = 0;
|
|
3677
4043
|
for (data.x_labels) |label| {
|
|
3678
|
-
widest = @max(widest,
|
|
4044
|
+
widest = @max(widest, measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, label, size));
|
|
3679
4045
|
}
|
|
3680
4046
|
const spacing = @max(1, widest + chart_x_label_min_gap);
|
|
3681
4047
|
const fit: usize = @max(1, @as(usize, @intFromFloat(plot.width / spacing)));
|
|
@@ -3685,7 +4051,7 @@ fn emitChartAxisLabels(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
3685
4051
|
while (ordinal < data.x_labels.len) : (ordinal += @max(1, stride)) {
|
|
3686
4052
|
const label = data.x_labels[ordinal];
|
|
3687
4053
|
if (label.len == 0) continue;
|
|
3688
|
-
const width =
|
|
4054
|
+
const width = measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, label, size);
|
|
3689
4055
|
const center_x = chartSampleX(data, count, ordinal, plot);
|
|
3690
4056
|
const x = std.math.clamp(center_x - width * 0.5, content.x, @max(content.x, content.maxX() - width));
|
|
3691
4057
|
try builder.drawText(.{
|
|
@@ -3979,6 +4345,13 @@ fn chartDetailRowName(series: chart_model.ChartSeries) []const u8 {
|
|
|
3979
4345
|
/// position depends only on the snapped index, never the raw pointer,
|
|
3980
4346
|
/// so a pointer gliding within one sample repaints nothing.
|
|
3981
4347
|
pub fn chartWidgetHoverDetail(widget: Widget, tokens: DesignTokens, point: geometry.PointF, bounds: geometry.RectF) ?ChartHoverDetail {
|
|
4348
|
+
if (tokens.control_command_policy != null) {
|
|
4349
|
+
var plan = chart_plans.Plan.init(widget, tokens, .hover_detail, bounds, point, null);
|
|
4350
|
+
defer plan.deinit();
|
|
4351
|
+
executeChartPlan(&plan, null) catch unreachable;
|
|
4352
|
+
const detail = plan.detail();
|
|
4353
|
+
return if (plan.admitted()) .{ .index = detail.index, .plot = detail.plot, .sample_x = detail.sample_x, .card = detail.card } else null;
|
|
4354
|
+
}
|
|
3982
4355
|
if (widget.kind != .chart or !widget.chart.hover_details) return null;
|
|
3983
4356
|
const data = widget.chart;
|
|
3984
4357
|
const plot = chartWidgetPlotRect(widget, tokens);
|
|
@@ -3994,15 +4367,15 @@ pub fn chartWidgetHoverDetail(widget: Widget, tokens: DesignTokens, point: geome
|
|
|
3994
4367
|
// index) over one row per series that has this sample.
|
|
3995
4368
|
var buffer: [chart_model.max_chart_value_label_bytes]u8 = undefined;
|
|
3996
4369
|
const title = chartHoverDetailTitle(data, index, &buffer);
|
|
3997
|
-
var content_width =
|
|
4370
|
+
var content_width = measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, title, size);
|
|
3998
4371
|
var rows: usize = 0;
|
|
3999
4372
|
for (data.series) |series| {
|
|
4000
4373
|
if (index >= series.values.len) continue;
|
|
4001
4374
|
rows += 1;
|
|
4002
4375
|
var value_buffer: [chart_model.max_chart_value_label_bytes]u8 = undefined;
|
|
4003
|
-
const name_width =
|
|
4376
|
+
const name_width = measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, chartDetailRowName(series), size);
|
|
4004
4377
|
const value_text = chart_model.formatChartValue(&value_buffer, series.values[index], decimals);
|
|
4005
|
-
const value_width =
|
|
4378
|
+
const value_width = measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, value_text, size);
|
|
4006
4379
|
content_width = @max(content_width, chart_detail_swatch + chart_detail_swatch_gap + name_width + chart_detail_column_gap + value_width);
|
|
4007
4380
|
}
|
|
4008
4381
|
if (rows == 0) return null;
|
|
@@ -4030,6 +4403,12 @@ pub fn chartWidgetHoverDetail(widget: Widget, tokens: DesignTokens, point: geome
|
|
|
4030
4403
|
/// The runtime's interaction path uses this to gate repaints: a pointer
|
|
4031
4404
|
/// gliding within one sample changes nothing, so nothing repaints.
|
|
4032
4405
|
pub fn chartWidgetHoverIndex(widget: Widget, tokens: DesignTokens, point: geometry.PointF) ?usize {
|
|
4406
|
+
if (tokens.control_command_policy != null) {
|
|
4407
|
+
var plan = chart_plans.Plan.init(widget, tokens, .hover_index, .zero(), point, null);
|
|
4408
|
+
defer plan.deinit();
|
|
4409
|
+
executeChartPlan(&plan, null) catch unreachable;
|
|
4410
|
+
return if (plan.admitted()) plan.index() else null;
|
|
4411
|
+
}
|
|
4033
4412
|
if (widget.kind != .chart or !widget.chart.hover_details) return null;
|
|
4034
4413
|
const plot = chartWidgetPlotRect(widget, tokens);
|
|
4035
4414
|
if (plot.isEmpty() or plot.width <= 0 or plot.height <= 0) return null;
|
|
@@ -4092,6 +4471,11 @@ fn emitWidgetLayoutChartHoverDetails(builder: *Builder, layout: anytype, tokens:
|
|
|
4092
4471
|
/// holding the sample's title over swatch/name/value rows. Values
|
|
4093
4472
|
/// format deterministically into the frame label scratch.
|
|
4094
4473
|
fn emitChartHoverDetail(builder: *Builder, widget: Widget, tokens: DesignTokens, detail: ChartHoverDetail) Error!void {
|
|
4474
|
+
if (tokens.control_command_policy != null) {
|
|
4475
|
+
var plan = chart_plans.Plan.init(widget, tokens, .hover_draw, .zero(), .zero(), .{ .index = detail.index, .plot = detail.plot, .sample_x = detail.sample_x, .card = detail.card });
|
|
4476
|
+
defer plan.deinit();
|
|
4477
|
+
return executeChartPlan(&plan, builder);
|
|
4478
|
+
}
|
|
4095
4479
|
const data = widget.chart;
|
|
4096
4480
|
const domain = chart_model.chartDomain(data);
|
|
4097
4481
|
const decimals = chartDetailDecimals(domain);
|
|
@@ -4191,7 +4575,7 @@ fn emitChartHoverDetail(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
4191
4575
|
});
|
|
4192
4576
|
var value_buffer: [chart_model.max_chart_value_label_bytes]u8 = undefined;
|
|
4193
4577
|
const value_text = try builder.allocChartLabelBytes(chart_model.formatChartValue(&value_buffer, series.values[detail.index], decimals));
|
|
4194
|
-
const value_width =
|
|
4578
|
+
const value_width = measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, value_text, size);
|
|
4195
4579
|
try builder.drawText(.{
|
|
4196
4580
|
.id = chartCommandId(widget.id, chart_hover_row_seed, series_index, 2),
|
|
4197
4581
|
.font_id = tokens.typography.font_id,
|
|
@@ -4205,6 +4589,71 @@ fn emitChartHoverDetail(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
4205
4589
|
}
|
|
4206
4590
|
}
|
|
4207
4591
|
|
|
4592
|
+
/// Execute explicit font, storage and drawing capabilities. Every returned
|
|
4593
|
+
/// continuation is copied before measurement or a nested drawing policy call.
|
|
4594
|
+
fn executeChartPlan(plan: *chart_plans.Plan, builder: ?*Builder) Error!void {
|
|
4595
|
+
while (true) {
|
|
4596
|
+
const action = plan.run();
|
|
4597
|
+
const tokens = plan.token;
|
|
4598
|
+
switch (action) {
|
|
4599
|
+
.done => return,
|
|
4600
|
+
.measure => {
|
|
4601
|
+
var text = plan.text();
|
|
4602
|
+
if (plan.allocateText()) {
|
|
4603
|
+
text = try (builder orelse @panic("chart query requested drawing storage")).allocChartLabelBytes(text);
|
|
4604
|
+
plan.saved_label = text;
|
|
4605
|
+
}
|
|
4606
|
+
plan.reply(measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, text, plan.scalar(224)));
|
|
4607
|
+
},
|
|
4608
|
+
.fill_rect => try (builder orelse @panic("chart query requested drawing")).fillRect(.{
|
|
4609
|
+
.id = plan.commandId(),
|
|
4610
|
+
.rect = plan.commandRect(),
|
|
4611
|
+
.fill = colorFill(plan.commandColor()),
|
|
4612
|
+
}),
|
|
4613
|
+
.fill_round => try (builder orelse @panic("chart query requested drawing")).fillRoundedRect(.{
|
|
4614
|
+
.id = plan.commandId(),
|
|
4615
|
+
.rect = plan.commandRect(),
|
|
4616
|
+
.radius = Radius.all(plan.scalar(232)),
|
|
4617
|
+
.fill = colorFill(plan.commandColor()),
|
|
4618
|
+
}),
|
|
4619
|
+
.text => {
|
|
4620
|
+
const target = builder orelse @panic("chart query requested drawing");
|
|
4621
|
+
const text = if (plan.allocateText()) try target.allocChartLabelBytes(plan.text()) else plan.text();
|
|
4622
|
+
try target.drawText(.{
|
|
4623
|
+
.id = plan.commandId(),
|
|
4624
|
+
.font_id = tokens.typography.font_id,
|
|
4625
|
+
.size = plan.scalar(224),
|
|
4626
|
+
.origin = plan.commandOrigin(),
|
|
4627
|
+
.color = plan.commandColor(),
|
|
4628
|
+
.text = text,
|
|
4629
|
+
.measure = tokens.text_measure,
|
|
4630
|
+
});
|
|
4631
|
+
},
|
|
4632
|
+
.fill_path, .stroke_path => {
|
|
4633
|
+
const target = builder orelse @panic("chart query requested drawing");
|
|
4634
|
+
const elements = try target.allocPathElements(plan.count());
|
|
4635
|
+
for (elements, 0..) |*element, i| element.* = plan.pathElement(i);
|
|
4636
|
+
if (action == .fill_path) try target.fillPath(.{ .id = plan.commandId(), .elements = elements, .fill = colorFill(plan.commandColor()) }) else try target.strokePath(.{ .id = plan.commandId(), .elements = elements, .stroke = .{ .fill = colorFill(plan.commandColor()), .width = plan.scalar(228) } });
|
|
4637
|
+
},
|
|
4638
|
+
.shadow => try (builder orelse @panic("chart query requested drawing")).shadow(.{
|
|
4639
|
+
.id = plan.commandId(),
|
|
4640
|
+
.rect = plan.commandRect(),
|
|
4641
|
+
.radius = Radius.all(plan.scalar(232)),
|
|
4642
|
+
.offset = .{ .dx = 0, .dy = tokens.shadow.sm.y },
|
|
4643
|
+
.blur = tokens.shadow.sm.blur,
|
|
4644
|
+
.spread = tokens.shadow.sm.spread,
|
|
4645
|
+
.color = plan.commandColor(),
|
|
4646
|
+
}),
|
|
4647
|
+
.stroke_rect => try (builder orelse @panic("chart query requested drawing")).strokeRect(snapHairlineStrokeRect(tokens, .{
|
|
4648
|
+
.id = plan.commandId(),
|
|
4649
|
+
.rect = plan.commandRect(),
|
|
4650
|
+
.radius = Radius.all(plan.scalar(232)),
|
|
4651
|
+
.stroke = .{ .fill = colorFill(plan.commandColor()), .width = plan.scalar(228) },
|
|
4652
|
+
})),
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4655
|
+
}
|
|
4656
|
+
|
|
4208
4657
|
/// Stable hashed command ids per (family, series, ordinal), same scheme
|
|
4209
4658
|
/// as span runs, so retained diffing tracks chart commands across frames.
|
|
4210
4659
|
fn chartCommandId(widget_id: ObjectId, seed: u64, series_index: usize, ordinal: usize) ObjectId {
|
|
@@ -4234,6 +4683,7 @@ pub fn textCaretCommandId(kind: WidgetKind, id: ObjectId) ObjectId {
|
|
|
4234
4683
|
|
|
4235
4684
|
pub fn toggleWidgetKnobTravel(widget: Widget, tokens: DesignTokens) f32 {
|
|
4236
4685
|
if (!widgetSwitchControlKind(widget.kind)) return 0;
|
|
4686
|
+
if (tokens.control_geometry_policy != null) return @import("control_geometry_policy.zig").controls(widget, tokens, .toggle).scalar;
|
|
4237
4687
|
// Shares the renderer's track/inset metrics (44x24 track, 2px thumb
|
|
4238
4688
|
// inset, both size- and density-scaled) so animated travel lands on
|
|
4239
4689
|
// exactly the painted on/off thumb positions.
|
|
@@ -4307,7 +4757,7 @@ fn alignedTextOrigin(frame: geometry.RectF, text: []const u8, size: f32, inset:
|
|
|
4307
4757
|
|
|
4308
4758
|
fn iconGlyphSize(widget: Widget, tokens: DesignTokens) f32 {
|
|
4309
4759
|
const min_size = widgetSizedDensityValue(widget, tokens, 12);
|
|
4310
|
-
if (widget.frame.height > 0) return @min(@max(min_size, widget.frame.height * widgetIconGlyphScale(widget)), @max(min_size,
|
|
4760
|
+
if (widget.frame.height > 0) return @min(@max(min_size, widget.frame.height * widgetIconGlyphScale(widget)), @max(min_size, widgetTypographySizeWithTokens(widget, tokens.typography.title_size, tokens)));
|
|
4311
4761
|
return widgetButtonTextSize(widget, tokens);
|
|
4312
4762
|
}
|
|
4313
4763
|
|
|
@@ -4360,7 +4810,7 @@ fn widgetWithRenderState(widget: Widget, state: WidgetRenderState) Widget {
|
|
|
4360
4810
|
/// Widget emitters derive every command id from the widget id, so remapping
|
|
4361
4811
|
/// each node before emission keeps the copied subtree valid for display-list
|
|
4362
4812
|
/// diffing without changing its retained/accessibility identity.
|
|
4363
|
-
fn dragPreviewWidgetId(id: ObjectId) ObjectId {
|
|
4813
|
+
pub fn dragPreviewWidgetId(id: ObjectId) ObjectId {
|
|
4364
4814
|
const mapped = std.hash.Wyhash.hash(0x5eed_59a2_d6a6_0001, std.mem.asBytes(&id));
|
|
4365
4815
|
return if (mapped == 0) 0x5eed_59a2_d6a6_0001 else mapped;
|
|
4366
4816
|
}
|
|
@@ -4392,3 +4842,223 @@ fn accordionContentFrame(widget: Widget, content: geometry.RectF, tokens: Design
|
|
|
4392
4842
|
fn nonNegative(value: f32) f32 {
|
|
4393
4843
|
return @max(0, value);
|
|
4394
4844
|
}
|
|
4845
|
+
|
|
4846
|
+
/// Independent native lane used to qualify the copied traversal boundary.
|
|
4847
|
+
pub fn referencePaintWalkLane(layout: anytype, index: usize, state: WidgetRenderState) paint_walk_policy.Lane {
|
|
4848
|
+
const node = layout.nodes[index];
|
|
4849
|
+
const widget = widgetWithRenderState(node.widget, state);
|
|
4850
|
+
const opacity = widgetOpacity(widget);
|
|
4851
|
+
const motion = state.layoutMotionOffset(widget.id);
|
|
4852
|
+
const transform = widgetTransform(widget);
|
|
4853
|
+
const wrap_transform = !affinesEqual(transform, Affine.identity());
|
|
4854
|
+
return .{
|
|
4855
|
+
.focused = widget.state.focused,
|
|
4856
|
+
.hovered = widget.state.hovered,
|
|
4857
|
+
.pressed = widget.state.pressed,
|
|
4858
|
+
.logical_focus = widgetHasLogicalFocus(widget, state),
|
|
4859
|
+
.group_focus = if (widget.kind != .input_group or widget.state.focused) widget.state.focused else if (state.focused_id != null or state.focus_visible_id != null) layoutSubtreeHasFocusVisible(layout, index, state) else layoutSubtreeHasBakedFocus(layout, index),
|
|
4860
|
+
.skip = node.widget.semantics.hidden or (!state.rendering_drag_preview and state.drag_preview_id != null and state.drag_preview_id.? == node.widget.id and widgetKindUsesFloatingDragPreview(node.widget.kind)),
|
|
4861
|
+
.wrap_opacity = opacity < 1,
|
|
4862
|
+
.wrap_motion = motion.dx != 0 or motion.dy != 0,
|
|
4863
|
+
.wrap_transform = wrap_transform,
|
|
4864
|
+
.suppress_flow = widget_tree.widgetEscapesAncestorClips(node.widget) or state.layoutMotionEscapesAncestorClips(node.widget.id),
|
|
4865
|
+
.disclosure = if (widget.kind != .accordion) .open else if (accordionChildrenVisible(widget)) if (widget_tree.disclosureSettledOpen(layout, index)) .open else .revealing else if (state.disclosureRevealing(widget.id)) .revealing else .closed,
|
|
4866
|
+
.opacity = opacity,
|
|
4867
|
+
.motion = motion,
|
|
4868
|
+
.inverse = if (wrap_transform) inversePaintTransform(transform) else Affine.identity(),
|
|
4869
|
+
};
|
|
4870
|
+
}
|
|
4871
|
+
pub fn referencePaintWalkSegment(layout: anytype, index: usize, tokens: DesignTokens) widget_model.WidgetGroupSegment {
|
|
4872
|
+
const parent = layout.nodes[index].parent_index orelse return .none;
|
|
4873
|
+
if (parent >= layout.nodes.len or layout.nodes[parent].widget.kind != .button_group or !buttonGroupStampsSegments(layout.nodes[parent].widget, tokens)) return .none;
|
|
4874
|
+
return layoutButtonGroupSegment(layout, parent, index);
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4877
|
+
/// GPU transform capability for exceptional scalar words. Keep its native
|
|
4878
|
+
/// arithmetic in one call boundary: inline specialization can move a NaN sign
|
|
4879
|
+
/// flip across multiplication. Finite transforms retain the ordinary path.
|
|
4880
|
+
pub fn inversePaintTransform(transform: Affine) ?Affine {
|
|
4881
|
+
inline for (.{ "a", "b", "c", "d", "tx", "ty" }) |name| {
|
|
4882
|
+
if (!std.math.isFinite(@field(transform, name))) return @call(.never_inline, Affine.inverse, .{transform});
|
|
4883
|
+
}
|
|
4884
|
+
return transform.inverse();
|
|
4885
|
+
}
|
|
4886
|
+
|
|
4887
|
+
fn leafFacts(widget: Widget) leaves.Facts {
|
|
4888
|
+
return .{ .text = widget.text.len != 0, .image = widget.image_id != 0, .cover = widget.image_fit == .cover, .focused = widget.state.focused, .hovered = widget.state.hovered, .pressed = widget.state.pressed };
|
|
4889
|
+
}
|
|
4890
|
+
fn leafText(builder: *Builder, widget: Widget, tokens: DesignTokens, id: ObjectId, frame: geometry.RectF, size: f32, inset: f32, color: Color) Error!void {
|
|
4891
|
+
const p = leaves.payload(tokens, .text, frame, .{ size, inset, 0, 0, 0, 0, 0, 0 }, 0, .nearest);
|
|
4892
|
+
try builder.drawText(.{ .id = id, .font_id = tokens.typography.font_id, .size = size, .origin = p.points[0], .color = color, .text = widget.text, .text_layout = .{ .max_width = p.max_width, .line_height = p.line_height, .alignment = .center, .wrap = .none, .measure = tokens.text_measure } });
|
|
4893
|
+
}
|
|
4894
|
+
fn leafImage(builder: *Builder, widget: Widget, tokens: DesignTokens, id: ObjectId, radius: Radius) Error!void {
|
|
4895
|
+
const p = leaves.payload(tokens, .raw, widget.frame, @splat(0), if (widget.image_src != null) 4 else 0, widget.image_sampling);
|
|
4896
|
+
try builder.drawImage(.{ .id = id, .image_id = widget.image_id, .src = widget.image_src, .dst = p.rects[0], .opacity = widget.image_opacity, .fit = widget.image_fit, .sampling = p.sampling, .radius = radius });
|
|
4897
|
+
}
|
|
4898
|
+
fn emitCompiledImage(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
4899
|
+
const program = leaves.Program.init(tokens, .image, 0, widget, leafFacts(widget));
|
|
4900
|
+
for (program.commands[0..program.count]) |command| switch (command.opcode) {
|
|
4901
|
+
.clip => try builder.pushClip(.{ .id = command.id, .rect = leaves.copiedFrame(tokens, widget.frame) }),
|
|
4902
|
+
.image => try leafImage(builder, widget, tokens, command.id, .{}),
|
|
4903
|
+
.unclip => try builder.popClip(),
|
|
4904
|
+
else => @panic("unsupported image drawing capability"),
|
|
4905
|
+
};
|
|
4906
|
+
}
|
|
4907
|
+
fn emitCompiledAvatar(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
4908
|
+
const visual = componentControlVisualTokens(widget, tokens);
|
|
4909
|
+
const radius = componentPillRadius(widget, visual, leaves.pillFallback(tokens, widget.frame));
|
|
4910
|
+
const background = widgetBackgroundColor(widget, visual.background orelse tokens.colors.surface_subtle);
|
|
4911
|
+
const program = leaves.Program.init(tokens, .avatar, 0, widget, leafFacts(widget));
|
|
4912
|
+
for (program.commands[0..program.count]) |command| switch (command.opcode) {
|
|
4913
|
+
.fill => try builder.fillRoundedRect(.{ .id = command.id, .rect = leaves.copiedFrame(tokens, widget.frame), .radius = radius, .fill = colorFill(background) }),
|
|
4914
|
+
.clip => try builder.pushClip(.{ .id = command.id, .rect = leaves.copiedFrame(tokens, widget.frame), .radius = radius }),
|
|
4915
|
+
.image => try leafImage(builder, widget, tokens, command.id, radius),
|
|
4916
|
+
.unclip => try builder.popClip(),
|
|
4917
|
+
.text => {
|
|
4918
|
+
const size = widgetLabelTextSize(widget, tokens);
|
|
4919
|
+
try leafText(builder, widget, tokens, command.id, widget.frame, size, 0, widgetForegroundColor(widget, tokens, visual.foreground orelse tokens.colors.text_muted));
|
|
4920
|
+
},
|
|
4921
|
+
.stroke => try builder.strokeRect(snapHairlineStrokeRect(tokens, .{ .id = command.id, .rect = leaves.copiedFrame(tokens, widget.frame), .radius = radius, .stroke = .{ .fill = widgetBorderFill(widget, visual.border orelse tokens.colors.border), .width = controlStrokeWidth(widget, visual, tokens.stroke.hairline) } })),
|
|
4922
|
+
else => @panic("unsupported avatar drawing capability"),
|
|
4923
|
+
};
|
|
4924
|
+
}
|
|
4925
|
+
fn emitCompiledBadge(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
4926
|
+
const visual = componentControlVisualTokens(widget, tokens);
|
|
4927
|
+
const radius = componentPillRadius(widget, visual, leaves.pillFallback(tokens, widget.frame));
|
|
4928
|
+
const size = widget_metrics.widgetBadgeTextSize(widget, tokens);
|
|
4929
|
+
const inset = widgetControlInset(widget, tokens, tokens.spacing.sm);
|
|
4930
|
+
const program = leaves.Program.init(tokens, .badge, 0, widget, leafFacts(widget));
|
|
4931
|
+
for (program.commands[0..program.count]) |command| switch (command.opcode) {
|
|
4932
|
+
.fill => try builder.fillRoundedRect(.{ .id = command.id, .rect = leaves.copiedFrame(tokens, widget.frame), .radius = radius, .fill = colorFill(badgeBackgroundColor(widget, tokens, visual)) }),
|
|
4933
|
+
.border_query => {
|
|
4934
|
+
const width = badgeStrokeWidth(widget, tokens, visual);
|
|
4935
|
+
const border = leaves.Program.init(tokens, .badge, 1, widget, .{ .scalar = width });
|
|
4936
|
+
for (border.commands[0..border.count]) |stroke| {
|
|
4937
|
+
if (stroke.opcode != .stroke) @panic("unsupported badge border capability");
|
|
4938
|
+
try builder.strokeRect(snapHairlineStrokeRect(tokens, .{ .id = stroke.id, .rect = leaves.copiedFrame(tokens, widget.frame), .radius = radius, .stroke = .{ .fill = colorFill(badgeBorderColor(widget, tokens, visual)), .width = width } }));
|
|
4939
|
+
}
|
|
4940
|
+
},
|
|
4941
|
+
.content_query => {
|
|
4942
|
+
const ink = badgeTextColor(widget, tokens, visual);
|
|
4943
|
+
const icon = icon_model.resolveOrMissing(widget.icon);
|
|
4944
|
+
var facts = leafFacts(widget);
|
|
4945
|
+
facts.icon = icon != null;
|
|
4946
|
+
const content = leaves.Program.init(tokens, .badge, 2, widget, facts);
|
|
4947
|
+
var text_frame = widget.frame;
|
|
4948
|
+
for (content.commands[0..content.count]) |item| switch (item.opcode) {
|
|
4949
|
+
.icon => {
|
|
4950
|
+
const extent = widget_metrics.widgetBadgeIconExtent(widget, tokens);
|
|
4951
|
+
// The gap is queried after drawing the icon, exactly as in
|
|
4952
|
+
// the independent reference, including buffer failures.
|
|
4953
|
+
const geometry_ = leaves.payload(tokens, .badge_content, widget.frame, .{ extent, inset, 0, 0, 0, 0, 0, 0 }, @intFromBool(facts.text), .nearest);
|
|
4954
|
+
try widget_render_controls.emitVectorIconWithTokens(builder, widget.id, item.slot, geometry_.rects[0], ink, icon.?, tokens);
|
|
4955
|
+
if (facts.text) {
|
|
4956
|
+
const gap = widget_metrics.widgetBadgeIconGap(widget, tokens);
|
|
4957
|
+
text_frame = leaves.payload(tokens, .badge_content, widget.frame, .{ extent, inset, gap, 0, 0, 0, 0, 0 }, 1, .nearest).rects[1];
|
|
4958
|
+
}
|
|
4959
|
+
},
|
|
4960
|
+
.text => try leafText(builder, widget, tokens, item.id, text_frame, size, inset, ink),
|
|
4961
|
+
else => @panic("unsupported badge content capability"),
|
|
4962
|
+
};
|
|
4963
|
+
},
|
|
4964
|
+
else => @panic("unsupported badge drawing capability"),
|
|
4965
|
+
};
|
|
4966
|
+
}
|
|
4967
|
+
fn emitCompiledSeparator(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
4968
|
+
const visual = componentControlVisualTokens(widget, tokens);
|
|
4969
|
+
const program = leaves.Program.init(tokens, .separator, 0, widget, leafFacts(widget));
|
|
4970
|
+
for (program.commands[0..program.count]) |command| {
|
|
4971
|
+
if (command.opcode != .fill) @panic("unsupported separator drawing capability");
|
|
4972
|
+
const width = controlStrokeWidth(widget, visual, tokens.stroke.hairline);
|
|
4973
|
+
const p = leaves.payload(tokens, .separator, widget.frame, .{ width, 0, 0, 0, 0, 0, 0, 0 }, 0, .nearest);
|
|
4974
|
+
try builder.fillRect(.{ .id = command.id, .rect = p.rects[0], .fill = colorFill(widgetBackgroundColor(widget, visual.background orelse visual.border orelse tokens.colors.border)) });
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
fn emitCompiledDivider(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
4978
|
+
const visual = componentControlVisualTokens(widget, tokens);
|
|
4979
|
+
const program = leaves.Program.init(tokens, .divider, 0, widget, leafFacts(widget));
|
|
4980
|
+
for (program.commands[0..program.count]) |command| switch (command.opcode) {
|
|
4981
|
+
.fill, .accent_fill => {
|
|
4982
|
+
const width = controlStrokeWidth(widget, visual, tokens.stroke.hairline);
|
|
4983
|
+
const active = command.opcode == .accent_fill;
|
|
4984
|
+
const p = leaves.payload(tokens, .divider, widget.frame, .{ width, 0, 0, 0, 0, 0, 0, 0 }, if (active) 2 else 0, .nearest);
|
|
4985
|
+
const ink = if (active) widgetAccentColor(widget, tokens.colors.accent) else widgetBorderColor(widget, visual.border orelse tokens.colors.border);
|
|
4986
|
+
try builder.fillRect(.{ .id = command.id, .rect = p.rects[0], .fill = colorFill(ink) });
|
|
4987
|
+
},
|
|
4988
|
+
.focus => {
|
|
4989
|
+
const p = leaves.payload(tokens, .divider, widget.frame, @splat(0), 0, .nearest);
|
|
4990
|
+
try builder.strokeRect(snapHairlineStrokeRect(tokens, .{ .id = command.id, .rect = p.rects[1], .radius = Radius.all(tokens.radius.sm), .stroke = .{ .fill = widget_render_style.widgetFocusRingFill(widget, tokens), .width = tokens.stroke.focus } }));
|
|
4991
|
+
},
|
|
4992
|
+
else => @panic("unsupported divider drawing capability"),
|
|
4993
|
+
};
|
|
4994
|
+
}
|
|
4995
|
+
fn emitCompiledStatus(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
4996
|
+
const program = leaves.Program.init(tokens, .status, 0, widget, leafFacts(widget));
|
|
4997
|
+
// Normalization is a payload operation rather than host-side arithmetic.
|
|
4998
|
+
const normalized = leaves.payload(tokens, .divider, widget.frame, @splat(0), 0, .nearest).rects[1];
|
|
4999
|
+
for (program.commands[0..program.count]) |command| switch (command.opcode) {
|
|
5000
|
+
.fill => try builder.fillRect(.{ .id = command.id, .rect = normalized, .fill = colorFill(widgetBackgroundColor(widget, tokens.colors.surface)) }),
|
|
5001
|
+
.status_separator => {
|
|
5002
|
+
const p = leaves.payload(tokens, .status_separator, widget.frame, .{ tokens.stroke.hairline, widget.style.stroke_width orelse tokens.stroke.hairline, 0, 0, 0, 0, 0, 0 }, 0, .nearest);
|
|
5003
|
+
try builder.fillRect(.{ .id = command.id, .rect = p.rects[0], .fill = widgetBorderFill(widget, tokens.colors.border) });
|
|
5004
|
+
},
|
|
5005
|
+
.status_text => {
|
|
5006
|
+
const size = widgetBodyTextSize(widget, tokens);
|
|
5007
|
+
const pad = widget.layout.padding;
|
|
5008
|
+
const p = leaves.payload(tokens, .status_text, widget.frame, .{ size, pad.top, pad.right, pad.bottom, pad.left, 0, 0, 0 }, 0, .nearest);
|
|
5009
|
+
if (p.admitted) try builder.drawText(.{ .id = command.id, .font_id = tokens.typography.font_id, .size = size, .origin = p.points[0], .color = widgetForegroundColor(widget, tokens, tokens.colors.text), .text = widget.text, .text_layout = .{ .max_width = p.max_width, .line_height = p.line_height, .wrap = .none, .alignment = widget.text_alignment, .overflow = widget.text_overflow, .measure = tokens.text_measure } });
|
|
5010
|
+
},
|
|
5011
|
+
else => @panic("unsupported status drawing capability"),
|
|
5012
|
+
};
|
|
5013
|
+
}
|
|
5014
|
+
fn emitCompiledSkeleton(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
5015
|
+
const visual = componentControlVisualTokens(widget, tokens);
|
|
5016
|
+
const program = leaves.Program.init(tokens, .skeleton, 0, widget, leafFacts(widget));
|
|
5017
|
+
for (program.commands[0..program.count]) |command| {
|
|
5018
|
+
if (command.opcode != .fill) @panic("unsupported skeleton drawing capability");
|
|
5019
|
+
try builder.fillRoundedRect(.{ .id = command.id, .rect = leaves.copiedFrame(tokens, widget.frame), .radius = controlRadius(widget, visual, tokens.radius.md), .fill = colorFill(widgetBackgroundColor(widget, visual.background orelse tokens.colors.surface_subtle)) });
|
|
5020
|
+
}
|
|
5021
|
+
}
|
|
5022
|
+
fn emitCompiledWash(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
5023
|
+
const fill = listItemFillColor(widget, tokens, widget.state);
|
|
5024
|
+
const program = leaves.Program.init(tokens, .wash, 0, widget, .{ .scalar = fill.a });
|
|
5025
|
+
for (program.commands[0..program.count]) |command| {
|
|
5026
|
+
if (command.opcode != .fill) @panic("unsupported row wash capability");
|
|
5027
|
+
try builder.fillRect(.{ .id = command.id, .rect = leaves.copiedFrame(tokens, widget.frame), .fill = colorFill(fill) });
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
5030
|
+
fn emitCompiledRowLine(builder: *Builder, id: ObjectId, frame: geometry.RectF, tokens: DesignTokens) Error!void {
|
|
5031
|
+
const widget: Widget = .{ .id = id, .kind = .data_row, .frame = frame };
|
|
5032
|
+
const program = leaves.Program.init(tokens, .row_line, 0, widget, .{});
|
|
5033
|
+
for (program.commands[0..program.count]) |command| {
|
|
5034
|
+
if (command.opcode != .line) @panic("unsupported row line capability");
|
|
5035
|
+
const p = leaves.payload(tokens, .row_line, frame, @splat(0), 0, .nearest);
|
|
5036
|
+
try builder.drawLine(.{ .id = command.id, .from = p.points[0], .to = p.points[1], .stroke = .{ .fill = colorFill(tokens.colors.border), .width = tokens.stroke.hairline } });
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
fn emitCompiledTableRows(builder: *Builder, children: []const Widget, tokens: DesignTokens) Error!void {
|
|
5040
|
+
const plan = leaves.RowPlan.init(std.heap.page_allocator, tokens, children, null) catch @panic("leaf row plan allocation failed");
|
|
5041
|
+
defer plan.deinit();
|
|
5042
|
+
for (0..plan.count) |i| {
|
|
5043
|
+
const child = children[plan.index(i)];
|
|
5044
|
+
try emitCompiledRowLine(builder, child.id, child.frame, tokens);
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
fn emitCompiledTableRowsLayout(builder: *Builder, layout: anytype, index: usize, tokens: DesignTokens, table: Widget, clip: bool) Error!void {
|
|
5048
|
+
var facts: leaves.Facts = .{};
|
|
5049
|
+
facts.cover = clip;
|
|
5050
|
+
const program = leaves.Program.init(tokens, .table, 0, table, facts);
|
|
5051
|
+
for (program.commands[0..program.count]) |command| switch (command.opcode) {
|
|
5052
|
+
.clip => try builder.pushClip(.{ .id = command.id, .rect = leaves.copiedFrame(tokens, table.frame) }),
|
|
5053
|
+
.rows => {
|
|
5054
|
+
const plan = leaves.RowPlan.init(std.heap.page_allocator, tokens, layout.nodes, index) catch @panic("leaf row plan allocation failed");
|
|
5055
|
+
defer plan.deinit();
|
|
5056
|
+
for (0..plan.count) |i| {
|
|
5057
|
+
const node = layout.nodes[plan.index(i)];
|
|
5058
|
+
try emitCompiledRowLine(builder, node.widget.id, node.frame, tokens);
|
|
5059
|
+
}
|
|
5060
|
+
},
|
|
5061
|
+
.unclip => try builder.popClip(),
|
|
5062
|
+
else => @panic("unsupported table drawing capability"),
|
|
5063
|
+
};
|
|
5064
|
+
}
|