@native-sdk/cli 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1818 -87
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -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 +57 -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 +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -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 +166 -19
- 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/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/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- 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_development.ts +160 -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 +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -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 +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- 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 +11 -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_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -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_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/core/references/web-engines-packaging-debugging.md +2 -1
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- 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/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 +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- 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/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -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/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/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 +128 -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/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- 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 +100 -0
- 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 +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -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 +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -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_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- 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 +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -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 +126 -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 +20 -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 +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -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/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 +4 -4
- 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 +437 -81
- 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/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- 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/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 +13 -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 +224 -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/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 +46 -36
- package/src/runtime/tests.zig +1 -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 +2325 -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 +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- 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 +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -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_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -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 +163 -10
- package/src/tooling/codesign.zig +125 -74
- 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/package.zig +85 -1
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- 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 +166 -0
- package/tools/corewire/core_abi.zig +51 -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 +360 -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 +290 -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 +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -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 +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -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 +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -20,12 +20,12 @@ const WidgetLayoutStyle = widget_model.WidgetLayoutStyle;
|
|
|
20
20
|
const WidgetLayoutNode = event_model.WidgetLayoutNode;
|
|
21
21
|
const DesignTokens = token_model.DesignTokens;
|
|
22
22
|
const virtualListRange = token_model.virtualListRange;
|
|
23
|
-
const
|
|
23
|
+
const measureTextWidthForFontWithPolicy = text_model.measureTextWidthForFontWithPolicy;
|
|
24
24
|
|
|
25
25
|
/// Text width for intrinsic sizing: the injected provider on `tokens` when
|
|
26
26
|
/// present, the deterministic estimator otherwise.
|
|
27
27
|
fn measuredTextWidth(tokens: DesignTokens, text: []const u8, size: f32) f32 {
|
|
28
|
-
return
|
|
28
|
+
return measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.font_id, text, size);
|
|
29
29
|
}
|
|
30
30
|
const gridColumnCount = widget_tree.gridColumnCount;
|
|
31
31
|
const gridRowCount = widget_tree.gridRowCount;
|
|
@@ -40,8 +40,8 @@ const widgetTabTriggerInset = widget_metrics.widgetTabTriggerInset;
|
|
|
40
40
|
const widgetTabTriggerIconExtent = widget_metrics.widgetTabTriggerIconExtent;
|
|
41
41
|
const widgetTabTriggerIconGap = widget_metrics.widgetTabTriggerIconGap;
|
|
42
42
|
const underlineTabsListInset = widget_metrics.underlineTabsListInset;
|
|
43
|
-
const
|
|
44
|
-
const
|
|
43
|
+
const widgetTypographySizeWithTokens = widget_metrics.widgetTypographySizeWithTokens;
|
|
44
|
+
const widgetLineHeightWithTokens = widget_metrics.widgetLineHeightWithTokens;
|
|
45
45
|
const widgetDefaultRowHeight = widget_metrics.widgetDefaultRowHeight;
|
|
46
46
|
const widgetButtonInset = widget_metrics.widgetButtonInset;
|
|
47
47
|
const widgetControlInset = widget_metrics.widgetControlInset;
|
|
@@ -55,7 +55,8 @@ const controlStrokeWidth = widget_render.controlStrokeWidth;
|
|
|
55
55
|
const componentControlVisualTokens = widget_render.componentControlVisualTokens;
|
|
56
56
|
const widgetTextSpanLayoutOptions = widget_metrics.widgetTextSpanLayoutOptions;
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
const coordination = @import("layout_coordination_policy.zig");
|
|
59
|
+
pub const max_widget_depth: usize = coordination.max_depth;
|
|
59
60
|
|
|
60
61
|
pub fn layoutWidgetDepth(
|
|
61
62
|
widget: Widget,
|
|
@@ -66,8 +67,13 @@ pub fn layoutWidgetDepth(
|
|
|
66
67
|
len: *usize,
|
|
67
68
|
tokens: DesignTokens,
|
|
68
69
|
) Error!usize {
|
|
69
|
-
if (
|
|
70
|
-
|
|
70
|
+
const route = if (tokens.layout_coordination_policy) |policy|
|
|
71
|
+
try coordination.admission(policy, widget, depth, len.*, output.len)
|
|
72
|
+
else reference: {
|
|
73
|
+
if (depth >= max_widget_depth) return error.WidgetDepthExceeded;
|
|
74
|
+
if (len.* >= output.len) return error.WidgetLayoutListFull;
|
|
75
|
+
break :reference coordination.referenceRoute(widget);
|
|
76
|
+
};
|
|
71
77
|
|
|
72
78
|
const index = len.*;
|
|
73
79
|
const root_bounds = if (index == 0) proposed_frame else output[0].frame;
|
|
@@ -85,95 +91,23 @@ pub fn layoutWidgetDepth(
|
|
|
85
91
|
|
|
86
92
|
const layout_padding = widgetLayoutPadding(widget, tokens);
|
|
87
93
|
const content = windowControlsClearedContent(frame.inset(layout_padding), widget, tokens);
|
|
88
|
-
switch (
|
|
89
|
-
.
|
|
90
|
-
// Button groups flow like rows but at their register's effective
|
|
91
|
-
// gap: the detached register supplies its own inter-chip gap when
|
|
92
|
-
// the author left the group's gap at 0.
|
|
94
|
+
switch (route) {
|
|
95
|
+
.horizontal => try layoutAxisChildren(widget.children, content, .horizontal, index, depth, output, len, widget.layout, tokens),
|
|
93
96
|
.button_group => try layoutAxisChildren(widget.children, content, .horizontal, index, depth, output, len, buttonGroupLayoutStyle(widget, tokens), tokens),
|
|
94
|
-
// Tab strips flow the same way: the underline register supplies
|
|
95
|
-
// its own inter-trigger gap when the author left the strip's gap
|
|
96
|
-
// at 0 (the house pill container keeps its flush triggers).
|
|
97
97
|
.tabs => try layoutTabsChildren(widget, content, index, depth, output, len, tokens),
|
|
98
|
-
.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.
|
|
103
|
-
.grid => if (widget.layout.virtualized)
|
|
104
|
-
try layoutVirtualGridChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
105
|
-
else
|
|
106
|
-
try layoutGridChildren(widget.children, content, index, depth, output, len, widget.layout.gap, widget.layout.columns, tokens),
|
|
107
|
-
.data_grid, .table => if (widget.layout.virtualized)
|
|
108
|
-
try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
109
|
-
else
|
|
110
|
-
try layoutAxisChildren(widget.children, content, .vertical, index, depth, output, len, widget.layout, tokens),
|
|
111
|
-
.data_row => try layoutAxisChildren(widget.children, content, .horizontal, index, depth, output, len, widget.layout, tokens),
|
|
112
|
-
// A list row with custom content: children flow horizontally
|
|
113
|
-
// (gap-consuming, like a row) inside the flat wash chrome, so
|
|
114
|
-
// apps compose indicator/title/meta rows without reaching for
|
|
115
|
-
// bordered card surfaces. Text/icon-only items stay leaves.
|
|
116
|
-
.list_item => try layoutAxisChildren(widget.children, content, .horizontal, index, depth, output, len, widget.layout, tokens),
|
|
117
|
-
.scroll_view => if (widget.layout.virtualized)
|
|
118
|
-
try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
119
|
-
else
|
|
120
|
-
try layoutScrollChildren(widget.children, content, index, depth, output, len, widget.scroll_axes, scrollLayoutOffset(widget), tokens),
|
|
121
|
-
.list => if (widget.layout.virtualized)
|
|
122
|
-
try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
123
|
-
else
|
|
124
|
-
try layoutAxisChildren(widget.children, content, .vertical, index, depth, output, len, widget.layout, tokens),
|
|
125
|
-
.tree => try layoutAxisChildren(widget.children, content, .vertical, index, depth, output, len, widget.layout, tokens),
|
|
98
|
+
.vertical => try layoutAxisChildren(widget.children, content, .vertical, index, depth, output, len, widget.layout, tokens),
|
|
99
|
+
.grid => try layoutGridChildren(widget.children, content, index, depth, output, len, widget.layout.gap, widget.layout.columns, tokens),
|
|
100
|
+
.virtual_grid => try layoutVirtualGridChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens),
|
|
101
|
+
.virtual_vertical => try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens),
|
|
102
|
+
.scroll => try layoutScrollChildren(widget.children, content, index, depth, output, len, widget.scroll_axes, if (tokens.intrinsic_layout_policy != null) geometry.OffsetF.init(widget.value_x, widget.value) else scrollLayoutOffset(widget), tokens),
|
|
126
103
|
.split => try layoutSplitChildren(widget, content, index, depth, output, len, tokens),
|
|
127
|
-
|
|
128
|
-
.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// identical in both poses and only the item's own extent
|
|
135
|
-
// (plus whatever stacks below it) moves.
|
|
136
|
-
const child_content = accordionContentFrame(widget, content, tokens, depth);
|
|
137
|
-
for (widget.children) |child| {
|
|
138
|
-
if (!widgetTakesFlowSlot(child)) continue;
|
|
139
|
-
_ = try layoutWidgetDepth(child, stackChildFrame(child_content, child, tokens), index, depth + 1, output, len, tokens);
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
.alert => {
|
|
143
|
-
// Alert children (the description under a chrome-drawn
|
|
144
|
-
// title) hang past the icon column and start under the
|
|
145
|
-
// title line — the standard callout grid.
|
|
146
|
-
const child_content = alertContentFrame(widget, content, tokens);
|
|
147
|
-
for (widget.children) |child| {
|
|
148
|
-
if (!widgetTakesFlowSlot(child)) continue;
|
|
149
|
-
_ = try layoutWidgetDepth(child, stackChildFrame(child_content, child, tokens), index, depth + 1, output, len, tokens);
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
.stack, .bubble, .card, .resizable, .panel, .popover => {
|
|
153
|
-
for (widget.children) |child| {
|
|
154
|
-
if (!widgetTakesFlowSlot(child)) continue;
|
|
155
|
-
_ = try layoutWidgetDepth(child, stackChildFrame(content, child, tokens), index, depth + 1, output, len, tokens);
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
// Modal surfaces own root-relative geometry: the dialog centers,
|
|
159
|
-
// the drawer pins to the bottom edge, and the sheet pins right.
|
|
160
|
-
// Their content still uses the stacking-surface contract inside
|
|
161
|
-
// that resolved frame.
|
|
162
|
-
.dialog, .drawer, .sheet => {
|
|
163
|
-
for (widget.children) |child| {
|
|
164
|
-
if (!widgetTakesFlowSlot(child)) continue;
|
|
165
|
-
_ = try layoutWidgetDepth(child, stackChildFrame(content, child, tokens), index, depth + 1, output, len, tokens);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
// Span paragraphs and span-carrying table cells share the link
|
|
169
|
-
// hotspot child convention. A span-less table cell may instead be
|
|
170
|
-
// a composed inline row (Markdown's resolved image + text shape).
|
|
171
|
-
.text => try layoutTextSpanLinkChildren(widget, content, index, depth, output, len, tokens),
|
|
172
|
-
.data_cell => if (widget.spans.len > 0)
|
|
173
|
-
try layoutTextSpanLinkChildren(widget, content, index, depth, output, len, tokens)
|
|
174
|
-
else
|
|
175
|
-
try layoutAxisChildren(widget.children, content, .horizontal, index, depth, output, len, widget.layout, tokens),
|
|
176
|
-
.icon, .image, .avatar, .badge, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .tooltip, .menu_item, .status_bar, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .progress, .separator, .skeleton, .spinner, .chart, .split_divider, .media_surface, .terminal => {},
|
|
104
|
+
// Disclosure children keep their full layout while the parent's
|
|
105
|
+
// extent reveals them. Alert descriptions clear the title/icon.
|
|
106
|
+
.accordion => try layoutStackChildren(widget.children, accordionContentFrame(widget, content, tokens, depth), index, depth, output, len, tokens),
|
|
107
|
+
.alert => try layoutStackChildren(widget.children, alertContentFrame(widget, content, tokens), index, depth, output, len, tokens),
|
|
108
|
+
.stack => try layoutStackChildren(widget.children, content, index, depth, output, len, tokens),
|
|
109
|
+
.spans => try layoutTextSpanLinkChildren(widget, content, index, depth, output, len, tokens),
|
|
110
|
+
.leaf => {},
|
|
177
111
|
}
|
|
178
112
|
|
|
179
113
|
// Root-relative modals and anchored floating children are excluded from
|
|
@@ -203,6 +137,14 @@ fn rootRelativeModalFrame(widget: Widget, proposed: geometry.RectF, root: geomet
|
|
|
203
137
|
else => return proposed,
|
|
204
138
|
};
|
|
205
139
|
const intrinsic = intrinsicWidgetSizeDepth(widget, tokens, depth);
|
|
140
|
+
if (tokens.surface_layout_policy) |policy| {
|
|
141
|
+
return @import("surface_layout_policy.zig").frame(policy, 0, switch (kind) {
|
|
142
|
+
.dialog => 0,
|
|
143
|
+
.drawer => 1,
|
|
144
|
+
.sheet => 2,
|
|
145
|
+
else => unreachable,
|
|
146
|
+
}, 1, &.{ root.x, root.y, root.width, root.height, widget.frame.width, widget.frame.height, intrinsic.width, intrinsic.height, widget.layout.min_size.width, widget.layout.min_size.height, widget.layout.max_size.width, widget.layout.max_size.height, 24 }) orelse proposed;
|
|
147
|
+
}
|
|
206
148
|
const preferred = geometry.SizeF.init(
|
|
207
149
|
clampIntrinsicAxis(if (widget.frame.width > 0) widget.frame.width else intrinsic.width, widget.layout.min_size.width, widget.layout.max_size.width),
|
|
208
150
|
clampIntrinsicAxis(if (widget.frame.height > 0) widget.frame.height else intrinsic.height, widget.layout.min_size.height, widget.layout.max_size.height),
|
|
@@ -241,6 +183,14 @@ fn layoutRootRelativeModalChildren(
|
|
|
241
183
|
root_bounds: geometry.RectF,
|
|
242
184
|
tokens: DesignTokens,
|
|
243
185
|
) Error!void {
|
|
186
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
187
|
+
var scratch = std.heap.stackFallback(1024, std.heap.page_allocator);
|
|
188
|
+
const plan = coordination.ChildPlan.init(scratch.get(), policy, children.len, 0, .modal, root_bounds, 0) catch @panic("modal layout program allocation failed");
|
|
189
|
+
defer plan.deinit();
|
|
190
|
+
for (children, 0..) |child, i| plan.setChild(i, child, false);
|
|
191
|
+
try applyLayoutChildren(plan, children, parent_index, depth, output, len, root_bounds, tokens);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
244
194
|
for (children) |child| {
|
|
245
195
|
if (!widget_tree.widgetIsRootRelativeModal(child)) continue;
|
|
246
196
|
_ = try layoutWidgetDepth(child, root_bounds, parent_index, depth + 1, output, len, tokens);
|
|
@@ -263,6 +213,9 @@ fn layoutRootRelativeModalChildren(
|
|
|
263
213
|
fn windowControlsClearedContent(content: geometry.RectF, widget: Widget, tokens: DesignTokens) geometry.RectF {
|
|
264
214
|
if (!widget.window_drag) return content;
|
|
265
215
|
const controls = (tokens.window_controls orelse return content).normalized();
|
|
216
|
+
if (tokens.surface_layout_policy) |policy| {
|
|
217
|
+
return @import("surface_layout_policy.zig").frame(policy, 2, 1, 1, &.{ content.x, content.y, content.width, content.height, controls.x, controls.y, controls.width, controls.height }) orelse @panic("invalid compiled caption frame");
|
|
218
|
+
}
|
|
266
219
|
if (controls.width <= 0 or controls.height <= 0) return content;
|
|
267
220
|
if (geometry.RectF.intersection(content, controls).isEmpty()) return content;
|
|
268
221
|
var cleared = content;
|
|
@@ -392,6 +345,14 @@ fn layoutAnchoredChildren(
|
|
|
392
345
|
root_bounds: geometry.RectF,
|
|
393
346
|
tokens: DesignTokens,
|
|
394
347
|
) Error!void {
|
|
348
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
349
|
+
var scratch = std.heap.stackFallback(1024, std.heap.page_allocator);
|
|
350
|
+
const plan = coordination.ChildPlan.init(scratch.get(), policy, children.len, 0, .anchor, anchor_rect, 0) catch @panic("anchor layout program allocation failed");
|
|
351
|
+
defer plan.deinit();
|
|
352
|
+
for (children, 0..) |child, i| plan.setChild(i, child, false);
|
|
353
|
+
try applyLayoutChildren(plan, children, parent_index, depth, output, len, root_bounds, tokens);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
395
356
|
for (children) |child| {
|
|
396
357
|
if (widget_tree.widgetIsRootRelativeModal(child)) continue;
|
|
397
358
|
const anchor = child.layout.anchor orelse continue;
|
|
@@ -413,14 +374,36 @@ pub fn anchoredNestingDepth(output: []const WidgetLayoutNode, node_index: usize)
|
|
|
413
374
|
if (node_index >= output.len) return 0;
|
|
414
375
|
var count: usize = 0;
|
|
415
376
|
var current: ?usize = node_index;
|
|
377
|
+
var remaining = output.len;
|
|
416
378
|
while (current) |index| {
|
|
417
|
-
if (index >= output.len) break;
|
|
379
|
+
if (index >= output.len or remaining == 0) break;
|
|
380
|
+
remaining -= 1;
|
|
418
381
|
if (widget_tree.widgetIsAnchored(output[index].widget)) count += 1;
|
|
419
382
|
current = output[index].parent_index;
|
|
420
383
|
}
|
|
421
384
|
return count;
|
|
422
385
|
}
|
|
423
386
|
|
|
387
|
+
pub fn anchoredNestingDepthWithTokens(output: []const WidgetLayoutNode, node_index: usize, tokens: DesignTokens) usize {
|
|
388
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
389
|
+
var scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
390
|
+
const plan = coordination.RetainedPlan.init(scratch.get(), policy, output) catch @panic("retained nesting allocation failed");
|
|
391
|
+
defer plan.deinit();
|
|
392
|
+
return plan.nesting(node_index);
|
|
393
|
+
}
|
|
394
|
+
return anchoredNestingDepth(output, node_index);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
pub fn maxAnchoredNestingDepthWithTokens(output: []const WidgetLayoutNode, tokens: DesignTokens) usize {
|
|
398
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
399
|
+
var scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
400
|
+
const plan = coordination.RetainedPlan.init(scratch.get(), policy, output) catch @panic("retained strata allocation failed");
|
|
401
|
+
defer plan.deinit();
|
|
402
|
+
return plan.maximum();
|
|
403
|
+
}
|
|
404
|
+
return maxAnchoredNestingDepth(output);
|
|
405
|
+
}
|
|
406
|
+
|
|
424
407
|
pub fn maxAnchoredNestingDepth(output: []const WidgetLayoutNode) usize {
|
|
425
408
|
var max_depth: usize = 0;
|
|
426
409
|
for (output, 0..) |node, index| {
|
|
@@ -448,10 +431,24 @@ pub fn relayoutAnchoredChildrenAtDepth(output: []WidgetLayoutNode, root_bounds:
|
|
|
448
431
|
// searching every parent's subtree: rebuilds with no open surface stay
|
|
449
432
|
// O(nodes), and an open surface pays only for the bounded anchored
|
|
450
433
|
// subtrees that are actually replayed.
|
|
434
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
435
|
+
var scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
436
|
+
const plan = coordination.RetainedPlan.init(scratch.get(), policy, output) catch @panic("retained anchor program allocation failed");
|
|
437
|
+
defer plan.deinit();
|
|
438
|
+
var cursor: usize = 1;
|
|
439
|
+
while (plan.next(cursor, parent_anchored_depth)) |selected| {
|
|
440
|
+
const parent = output[selected.parent];
|
|
441
|
+
var len = selected.index;
|
|
442
|
+
try layoutAnchoredChildren(parent.widget.children, windowControlsClearedContent(parent.frame, parent.widget, tokens), selected.parent, parent.depth, output, &len, root_bounds, tokens);
|
|
443
|
+
for (output[selected.index..len], selected.index..) |node, i| plan.setNode(i, node);
|
|
444
|
+
cursor = plan.advance(selected.index, len);
|
|
445
|
+
}
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
451
448
|
var anchored_start: usize = 1;
|
|
452
449
|
while (anchored_start < output.len) {
|
|
453
450
|
const anchored = output[anchored_start];
|
|
454
|
-
if (anchored.widget.layout.anchor == null) {
|
|
451
|
+
if (anchored.widget.layout.anchor == null or widget_tree.widgetIsRootRelativeModal(anchored.widget)) {
|
|
455
452
|
anchored_start += 1;
|
|
456
453
|
continue;
|
|
457
454
|
}
|
|
@@ -463,6 +460,10 @@ pub fn relayoutAnchoredChildrenAtDepth(output: []WidgetLayoutNode, root_bounds:
|
|
|
463
460
|
anchored_start += 1;
|
|
464
461
|
continue;
|
|
465
462
|
}
|
|
463
|
+
if (parent_index >= output.len) {
|
|
464
|
+
anchored_start += 1;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
466
467
|
const parent = output[parent_index];
|
|
467
468
|
var len = anchored_start;
|
|
468
469
|
try layoutAnchoredChildren(
|
|
@@ -489,7 +490,7 @@ pub fn relayoutAnchoredChildren(output: []WidgetLayoutNode, tokens: DesignTokens
|
|
|
489
490
|
}
|
|
490
491
|
|
|
491
492
|
pub fn relayoutAnchoredChildrenWithRootBounds(output: []WidgetLayoutNode, root_bounds: geometry.RectF, tokens: DesignTokens) Error!void {
|
|
492
|
-
const max_depth =
|
|
493
|
+
const max_depth = maxAnchoredNestingDepthWithTokens(output, tokens);
|
|
493
494
|
var parent_depth: usize = 0;
|
|
494
495
|
while (parent_depth < max_depth) : (parent_depth += 1) {
|
|
495
496
|
try relayoutAnchoredChildrenAtDepth(output, root_bounds, tokens, parent_depth);
|
|
@@ -513,6 +514,11 @@ pub fn anchoredWidgetFrame(
|
|
|
513
514
|
window_rect: geometry.RectF,
|
|
514
515
|
tokens: DesignTokens,
|
|
515
516
|
) geometry.RectF {
|
|
517
|
+
if (tokens.surface_layout_policy) |policy| {
|
|
518
|
+
const intrinsic = intrinsicWidgetSize(child, tokens);
|
|
519
|
+
const point = anchor.point orelse geometry.PointF.init(0, 0);
|
|
520
|
+
return @import("surface_layout_policy.zig").frame(policy, 1, @intFromEnum(anchor.placement), @import("surface_layout_policy.zig").anchorFlags(@intFromEnum(anchor.alignment), anchor.point != null), &.{ window_rect.x, window_rect.y, window_rect.width, window_rect.height, anchor_rect.x, anchor_rect.y, anchor_rect.width, anchor_rect.height, child.frame.width, child.frame.height, intrinsic.width, intrinsic.height, child.layout.min_size.width, child.layout.min_size.height, child.layout.max_size.width, child.layout.max_size.height, anchor.offset, point.x, point.y }) orelse @panic("invalid compiled anchor frame");
|
|
521
|
+
}
|
|
516
522
|
const window = window_rect.normalized();
|
|
517
523
|
const anchor_frame = if (anchor.point) |point| geometry.RectF.init(
|
|
518
524
|
std.math.clamp(point.x, window.x, window.maxX()),
|
|
@@ -730,6 +736,61 @@ fn layoutAxisChildrenMode(
|
|
|
730
736
|
}
|
|
731
737
|
if (flow_count == 0) return;
|
|
732
738
|
|
|
739
|
+
if (tokens.measurement_coordination_policy) |policy| {
|
|
740
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
741
|
+
const plan = @import("measurement_coordination_policy.zig").AxisPlan.init(scratch.get(), policy, children.len, content, @intFromEnum(axis), @intFromEnum(style.main_alignment), @intFromEnum(style.cross_alignment), style.gap) catch @panic("axis measurement allocation failed");
|
|
742
|
+
defer plan.deinit();
|
|
743
|
+
for (children, 0..) |child, index| plan.setFlow(index, widgetTakesFlowSlot(child));
|
|
744
|
+
while (true) {
|
|
745
|
+
const result = plan.run();
|
|
746
|
+
const index = result.index();
|
|
747
|
+
switch (result.action()) {
|
|
748
|
+
.done => break,
|
|
749
|
+
.child => plan.replyChild(result, containerChildFacts(children[index], axis, tokens, fill_primary_tabs, stretch_tab_triggers, true)),
|
|
750
|
+
.first_spans, .second_spans => plan.replySpans(result, widgetSubtreeHasTextSpans(children[index], 0, tokens)),
|
|
751
|
+
.wrapped => plan.replyHeight(result, wrappedVerticalExtentForWidth(children[index], result.width(), tokens, 0)),
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
if (!(plan.overflow() <= axis_layout_overflow_epsilon)) logAxisChildrenOverflow(output, parent_index, axis, if (axis == .horizontal) content.width else content.height, plan.used(), plan.overflow());
|
|
755
|
+
for (children, 0..) |child, index| {
|
|
756
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
757
|
+
const frame = plan.frame(index);
|
|
758
|
+
_ = try layoutWidgetDepth(child, frame, parent_index, depth + 1, output, len, tokens);
|
|
759
|
+
}
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
if (tokens.container_layout_policy) |policy| {
|
|
764
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
765
|
+
const plan = @import("container_layout_policy.zig").Plan.init(scratch.get(), policy, children.len, content, @intFromEnum(axis), @intFromEnum(style.main_alignment), @intFromEnum(style.cross_alignment), style.gap) catch @panic("container layout allocation failed");
|
|
766
|
+
defer plan.deinit();
|
|
767
|
+
var needs_wrapped = false;
|
|
768
|
+
for (children, 0..) |child, index| {
|
|
769
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
770
|
+
plan.setChild(index, containerChildFacts(child, axis, tokens, fill_primary_tabs, stretch_tab_triggers, true));
|
|
771
|
+
if (axis == .vertical and nonNegative(child.layout.grow) == 0 and child.frame.height <= 0 and widgetSubtreeHasTextSpans(child, 0, tokens)) needs_wrapped = true;
|
|
772
|
+
}
|
|
773
|
+
// Resolve cross sizes before measuring span paragraphs at their
|
|
774
|
+
// actual offered width. The measurements are native capabilities;
|
|
775
|
+
// allocation, bounds, theme floors and alignment are compiled policy.
|
|
776
|
+
if (needs_wrapped) {
|
|
777
|
+
plan.run(0);
|
|
778
|
+
for (children, 0..) |child, index| {
|
|
779
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
780
|
+
if (nonNegative(child.layout.grow) == 0 and child.frame.height <= 0 and widgetSubtreeHasTextSpans(child, 0, tokens))
|
|
781
|
+
plan.setMeasuredMain(index, wrappedVerticalExtentForWidth(child, plan.cross(index), tokens, 0));
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
plan.run(1);
|
|
785
|
+
if (!(plan.overflow() <= axis_layout_overflow_epsilon)) logAxisChildrenOverflow(output, parent_index, axis, if (axis == .horizontal) content.width else content.height, plan.used(), plan.overflow());
|
|
786
|
+
for (children, 0..) |child, index| {
|
|
787
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
788
|
+
const frame = plan.frame(index);
|
|
789
|
+
_ = try layoutWidgetDepth(child, frame, parent_index, depth + 1, output, len, tokens);
|
|
790
|
+
}
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
|
|
733
794
|
const available_extent = switch (axis) {
|
|
734
795
|
.horizontal => content.width,
|
|
735
796
|
.vertical => content.height,
|
|
@@ -977,7 +1038,7 @@ fn preferredMainExtentInCross(
|
|
|
977
1038
|
alignment: WidgetCrossAlignment,
|
|
978
1039
|
tokens: DesignTokens,
|
|
979
1040
|
) f32 {
|
|
980
|
-
if (axis == .vertical and child.frame.height <= 0 and widgetSubtreeHasTextSpans(child, 0)) {
|
|
1041
|
+
if (axis == .vertical and child.frame.height <= 0 and widgetSubtreeHasTextSpans(child, 0, tokens)) {
|
|
981
1042
|
const width = preferredCrossExtent(child, axis, cross_extent, alignment, tokens);
|
|
982
1043
|
return clampMainExtent(child, axis, wrappedVerticalExtentForWidth(child, width, tokens, 0));
|
|
983
1044
|
}
|
|
@@ -991,11 +1052,21 @@ fn widgetIsSpanParagraph(widget: Widget) bool {
|
|
|
991
1052
|
return (widget.kind == .text or widget.kind == .data_cell) and widget.spans.len > 0;
|
|
992
1053
|
}
|
|
993
1054
|
|
|
994
|
-
fn widgetSubtreeHasTextSpans(widget: Widget, depth: usize) bool {
|
|
1055
|
+
fn widgetSubtreeHasTextSpans(widget: Widget, depth: usize, tokens: DesignTokens) bool {
|
|
1056
|
+
if (tokens.measurement_coordination_policy) |policy| {
|
|
1057
|
+
var scratch = std.heap.stackFallback(256, std.heap.page_allocator);
|
|
1058
|
+
const plan = @import("measurement_coordination_policy.zig").SpanPlan.init(scratch.get(), policy, widget, depth, max_widget_depth) catch @panic("span subtree allocation failed");
|
|
1059
|
+
defer plan.deinit();
|
|
1060
|
+
while (true) {
|
|
1061
|
+
const result = plan.run();
|
|
1062
|
+
if (!result.pending()) return result.found();
|
|
1063
|
+
plan.reply(result, widgetSubtreeHasTextSpans(widget.children[result.index()], depth + 1, tokens));
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
995
1066
|
if (depth >= max_widget_depth) return false;
|
|
996
1067
|
if (widgetIsSpanParagraph(widget)) return true;
|
|
997
1068
|
for (widget.children) |child| {
|
|
998
|
-
if (widgetSubtreeHasTextSpans(child, depth + 1)) return true;
|
|
1069
|
+
if (widgetSubtreeHasTextSpans(child, depth + 1, tokens)) return true;
|
|
999
1070
|
}
|
|
1000
1071
|
return false;
|
|
1001
1072
|
}
|
|
@@ -1006,6 +1077,8 @@ fn widgetSubtreeHasTextSpans(widget: Widget, depth: usize) bool {
|
|
|
1006
1077
|
/// content composes from and falls back to the classic intrinsic extent
|
|
1007
1078
|
/// everywhere else.
|
|
1008
1079
|
fn wrappedVerticalExtentForWidth(widget: Widget, width: f32, tokens: DesignTokens, depth: usize) f32 {
|
|
1080
|
+
if (tokens.measurement_coordination_policy != null) return compiledWrappedExtent(widget, width, tokens, depth, false, false);
|
|
1081
|
+
if (tokens.intrinsic_layout_policy != null) return compiledWrappedExtentReference(widget, width, tokens, depth, false, false);
|
|
1009
1082
|
if (depth >= max_widget_depth) return preferredMainExtent(widget, .vertical, tokens);
|
|
1010
1083
|
if (widget.frame.height > 0) return clampMainExtent(widget, .vertical, widget.frame.height);
|
|
1011
1084
|
const padding = widgetLayoutPadding(widget, tokens);
|
|
@@ -1080,11 +1153,11 @@ fn wrappedVerticalExtentForWidth(widget: Widget, width: f32, tokens: DesignToken
|
|
|
1080
1153
|
var content = max_height;
|
|
1081
1154
|
if (widget.text.len > 0) {
|
|
1082
1155
|
const title_gap = densityValue(tokens, tokens.spacing.xs);
|
|
1083
|
-
content =
|
|
1156
|
+
content = widgetLineHeightWithTokens(text_size, tokens) + (if (max_height > 0) title_gap + max_height else 0);
|
|
1084
1157
|
}
|
|
1085
1158
|
// The same floor `intrinsicAlertWidgetSize` keeps, so wrapped
|
|
1086
1159
|
// and intrinsic measurements agree for short alerts.
|
|
1087
|
-
const chrome_floor = @max(widgetSizedDensityValue(widget, tokens, 52),
|
|
1160
|
+
const chrome_floor = @max(widgetSizedDensityValue(widget, tokens, 52), widgetLineHeightWithTokens(text_size, tokens) + inset * 2);
|
|
1088
1161
|
break :blk @max(content, chrome_floor - padding.top - padding.bottom);
|
|
1089
1162
|
},
|
|
1090
1163
|
// Accordion content sits below the header band; wrapped content
|
|
@@ -1134,6 +1207,23 @@ fn rowChildWidth(row: Widget, available_width: f32, index: usize, tokens: Design
|
|
|
1134
1207
|
fn rowChildWidthMode(row: Widget, available_width: f32, index: usize, tokens: DesignTokens, comptime fill_primary_tabs: bool) f32 {
|
|
1135
1208
|
const children = row.children;
|
|
1136
1209
|
if (children.len == 0) return available_width;
|
|
1210
|
+
if (tokens.container_layout_policy) |policy| {
|
|
1211
|
+
if (widgetFlowChildCount(children) == 0) return available_width;
|
|
1212
|
+
const gap = switch (row.kind) {
|
|
1213
|
+
.button_group => buttonGroupGap(row, tokens),
|
|
1214
|
+
.tabs => tabsGap(row, tokens),
|
|
1215
|
+
else => row.layout.gap,
|
|
1216
|
+
};
|
|
1217
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
1218
|
+
const plan = @import("container_layout_policy.zig").Plan.init(scratch.get(), policy, children.len, .init(0, 0, available_width, 0), 0, 0, 0, gap) catch @panic("row measurement allocation failed");
|
|
1219
|
+
defer plan.deinit();
|
|
1220
|
+
for (children, 0..) |child, child_index| {
|
|
1221
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
1222
|
+
plan.setChild(child_index, containerChildFacts(child, .horizontal, tokens, fill_primary_tabs, false, false));
|
|
1223
|
+
}
|
|
1224
|
+
plan.run(2);
|
|
1225
|
+
return plan.frame(index).width;
|
|
1226
|
+
}
|
|
1137
1227
|
var flow_count: usize = 0;
|
|
1138
1228
|
var fixed_extent: f32 = 0;
|
|
1139
1229
|
var grow_total: f32 = 0;
|
|
@@ -1232,6 +1322,21 @@ fn layoutTextSpanLinkChildren(
|
|
|
1232
1322
|
&runs,
|
|
1233
1323
|
);
|
|
1234
1324
|
|
|
1325
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
1326
|
+
var scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
1327
|
+
const plan = coordination.ChildPlan.init(scratch.get(), policy, widget.children.len, widget.spans.len, .spans, content, 0) catch @panic("span child program allocation failed");
|
|
1328
|
+
defer plan.deinit();
|
|
1329
|
+
for (widget.children, 0..) |child, i| plan.setChild(i, child, false);
|
|
1330
|
+
for (widget.spans, 0..) |span, i| plan.setLink(i, span.link.len != 0);
|
|
1331
|
+
while (true) {
|
|
1332
|
+
const result = plan.run();
|
|
1333
|
+
if (result.action() == .done) break;
|
|
1334
|
+
if (result.action() != .bounds) @panic("unexpected span child capability");
|
|
1335
|
+
plan.replyBounds(result, text_spans_model.textSpanBoundsWithPolicy(layout, result.span(), tokens.paragraph_policy));
|
|
1336
|
+
}
|
|
1337
|
+
try applyReadyLayoutChildren(plan, widget.children, parent_index, depth, output, len, .init(0, 0, 0, 0), tokens);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1235
1340
|
var child_index: usize = 0;
|
|
1236
1341
|
for (widget.spans, 0..) |span, span_index| {
|
|
1237
1342
|
if (span.link.len == 0) continue;
|
|
@@ -1310,9 +1415,22 @@ fn layoutGridChildren(
|
|
|
1310
1415
|
requested_columns: usize,
|
|
1311
1416
|
tokens: DesignTokens,
|
|
1312
1417
|
) Error!void {
|
|
1418
|
+
if (tokens.flow_measurement_policy) |policy| return compiledGridChildren(children, content, parent_index, depth, output, len, .{ .gap = gap, .columns = requested_columns }, 0, false, policy, tokens);
|
|
1313
1419
|
const flow_count = widgetFlowChildCount(children);
|
|
1314
1420
|
if (flow_count == 0) return;
|
|
1315
1421
|
|
|
1422
|
+
if (tokens.grid_layout_policy) |policy| {
|
|
1423
|
+
const grid = @import("grid_layout_policy.zig").plan(policy, flow_count, requested_columns, 0, content, gap, 0, 0, 0, false);
|
|
1424
|
+
var flow_index: usize = 0;
|
|
1425
|
+
for (children) |child| {
|
|
1426
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
1427
|
+
const child_frame = @import("grid_layout_policy.zig").frame(policy, grid, flow_index, content, child.frame, child.layout.min_size, child.layout.max_size, false, primaryUnderlineTabsFillWidth(child, tokens));
|
|
1428
|
+
flow_index += 1;
|
|
1429
|
+
_ = try layoutWidgetDepth(child, child_frame, parent_index, depth + 1, output, len, tokens);
|
|
1430
|
+
}
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1316
1434
|
const columns = gridColumnCount(flow_count, requested_columns);
|
|
1317
1435
|
const rows = gridRowCount(flow_count, columns);
|
|
1318
1436
|
const clamped_gap = nonNegative(gap);
|
|
@@ -1352,9 +1470,34 @@ fn layoutVirtualGridChildren(
|
|
|
1352
1470
|
style: WidgetLayoutStyle,
|
|
1353
1471
|
tokens: DesignTokens,
|
|
1354
1472
|
) Error!void {
|
|
1473
|
+
if (tokens.flow_measurement_policy) |policy| return compiledGridChildren(children, content, parent_index, depth, output, len, style, scroll_y, true, policy, tokens);
|
|
1355
1474
|
const flow_count = widgetFlowChildCount(children);
|
|
1356
1475
|
if (flow_count == 0) return;
|
|
1357
1476
|
|
|
1477
|
+
if (tokens.grid_layout_policy) |policy| {
|
|
1478
|
+
// Measurement needs the first row's slot count; the portable planner
|
|
1479
|
+
// chooses it before native text/intrinsic providers measure that row.
|
|
1480
|
+
const initial = @import("grid_layout_policy.zig").plan(policy, flow_count, style.columns, style.virtual_overscan, content, style.gap, style.virtual_item_extent, 0, scroll_y, true);
|
|
1481
|
+
const measured_extent = if (style.virtual_item_extent > 0) 0 else preferredGridRowExtent(children, initial.columns, tokens);
|
|
1482
|
+
const grid = if (style.virtual_item_extent > 0) initial else @import("grid_layout_policy.zig").plan(policy, flow_count, style.columns, style.virtual_overscan, content, style.gap, style.virtual_item_extent, measured_extent, scroll_y, true);
|
|
1483
|
+
output[parent_index].widget.layout.virtual_item_extent = grid.item_extent;
|
|
1484
|
+
output[parent_index].widget.semantics.list_item_count = saturatingU32(grid.rows);
|
|
1485
|
+
if (grid.start >= grid.end) return;
|
|
1486
|
+
var flow_index: usize = 0;
|
|
1487
|
+
for (children) |source| {
|
|
1488
|
+
if (!widgetTakesFlowSlot(source)) continue;
|
|
1489
|
+
defer flow_index += 1;
|
|
1490
|
+
const row = flow_index / grid.columns;
|
|
1491
|
+
if (row < grid.start or row >= grid.end) continue;
|
|
1492
|
+
var child = source;
|
|
1493
|
+
child.semantics.list_item_index = saturatingU32(flow_index);
|
|
1494
|
+
child.semantics.list_item_count = saturatingU32(flow_count);
|
|
1495
|
+
const child_frame = @import("grid_layout_policy.zig").frame(policy, grid, flow_index, content, child.frame, child.layout.min_size, child.layout.max_size, true, primaryUnderlineTabsFillWidth(child, tokens));
|
|
1496
|
+
_ = try layoutWidgetDepth(child, child_frame, parent_index, depth + 1, output, len, tokens);
|
|
1497
|
+
}
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1358
1501
|
const columns = gridColumnCount(flow_count, style.columns);
|
|
1359
1502
|
const rows = gridRowCount(flow_count, columns);
|
|
1360
1503
|
if (columns == 0 or rows == 0) return;
|
|
@@ -1404,6 +1547,32 @@ fn layoutVirtualGridChildren(
|
|
|
1404
1547
|
}
|
|
1405
1548
|
}
|
|
1406
1549
|
|
|
1550
|
+
fn compiledGridChildren(children: []const Widget, content: geometry.RectF, parent_index: usize, depth: usize, output: []WidgetLayoutNode, len: *usize, style: WidgetLayoutStyle, scroll_y: f32, windowed: bool, policy: @import("flow_measurement_policy.zig").Policy, tokens: DesignTokens) Error!void {
|
|
1551
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
1552
|
+
const plan = @import("flow_measurement_policy.zig").GridPlan.init(scratch.get(), policy, children.len, widgetFlowChildCount(children), content, style.columns, style.virtual_overscan, style.gap, style.virtual_item_extent, scroll_y, windowed) catch @panic("grid measurement allocation failed");
|
|
1553
|
+
defer plan.deinit();
|
|
1554
|
+
for (children, 0..) |child, index| plan.setChild(index, child, widgetTakesFlowSlot(child), primaryUnderlineTabsFillWidth(child, tokens));
|
|
1555
|
+
while (true) {
|
|
1556
|
+
const result = plan.run();
|
|
1557
|
+
if (!result.pending()) break;
|
|
1558
|
+
plan.reply(result, intrinsicWidgetSize(children[result.index()], tokens).height);
|
|
1559
|
+
}
|
|
1560
|
+
if (!plan.active()) return;
|
|
1561
|
+
if (windowed) {
|
|
1562
|
+
output[parent_index].widget.layout.virtual_item_extent = plan.extent();
|
|
1563
|
+
output[parent_index].widget.semantics.list_item_count = plan.rows();
|
|
1564
|
+
}
|
|
1565
|
+
for (children, 0..) |source, index| {
|
|
1566
|
+
if (!plan.enabled(index)) continue;
|
|
1567
|
+
var child = source;
|
|
1568
|
+
if (windowed) {
|
|
1569
|
+
child.semantics.list_item_index = plan.itemIndex(index);
|
|
1570
|
+
child.semantics.list_item_count = plan.itemCount(index);
|
|
1571
|
+
}
|
|
1572
|
+
_ = try layoutWidgetDepth(child, plan.frame(index), parent_index, depth + 1, output, len, tokens);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1407
1576
|
/// A grid cell is the containing width for Geist's primary ruled row.
|
|
1408
1577
|
/// Translate the theme-agnostic house width to the remaining cell width,
|
|
1409
1578
|
/// while keeping deliberate overflow and explicit max bounds intact.
|
|
@@ -1450,6 +1619,26 @@ fn layoutScrollChildren(
|
|
|
1450
1619
|
scroll_offset: geometry.OffsetF,
|
|
1451
1620
|
tokens: DesignTokens,
|
|
1452
1621
|
) Error!void {
|
|
1622
|
+
if (tokens.flow_measurement_policy) |policy| return compiledMeasuredFlow(children, parent_index, depth, output, len, 2, .{ .content = content, .horizontal = axes.scrollsHorizontally(), .vertical = axes.scrollsVertically(), .scroll_x = scroll_offset.dx, .scroll_y = scroll_offset.dy }, policy, tokens);
|
|
1623
|
+
if (tokens.intrinsic_layout_policy) |policy| {
|
|
1624
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
1625
|
+
const plan = @import("virtual_flow_policy.zig").Plan.init(scratch.get(), policy, children.len, .{ .content = content, .horizontal = axes.scrollsHorizontally(), .vertical = axes.scrollsVertically(), .scroll_x = scroll_offset.dx, .scroll_y = scroll_offset.dy }) catch @panic("scroll flow allocation failed");
|
|
1626
|
+
defer plan.deinit();
|
|
1627
|
+
for (children, 0..) |child, index| if (widgetTakesFlowSlot(child)) {
|
|
1628
|
+
plan.setChild(index, child, 0);
|
|
1629
|
+
};
|
|
1630
|
+
plan.run(2);
|
|
1631
|
+
for (children, 0..) |child, index| {
|
|
1632
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
1633
|
+
plan.setFrame(index, stackChildFrame(plan.content(), child, tokens));
|
|
1634
|
+
if (plan.needsWidth(index)) plan.setIntrinsicWidth(index, intrinsicChildSize(child, tokens, depth + 1).width);
|
|
1635
|
+
}
|
|
1636
|
+
plan.run(2);
|
|
1637
|
+
for (children, 0..) |child, index| {
|
|
1638
|
+
if (plan.enabled(index)) _ = try layoutWidgetDepth(child, plan.frame(index), parent_index, depth + 1, output, len, tokens);
|
|
1639
|
+
}
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1453
1642
|
const scrolled_content = content.translate(geometry.OffsetF.init(-scroll_offset.dx, -scroll_offset.dy));
|
|
1454
1643
|
for (children) |child| {
|
|
1455
1644
|
if (!widgetTakesFlowSlot(child)) continue;
|
|
@@ -1476,6 +1665,8 @@ fn layoutVirtualVerticalChildren(
|
|
|
1476
1665
|
style: WidgetLayoutStyle,
|
|
1477
1666
|
tokens: DesignTokens,
|
|
1478
1667
|
) Error!void {
|
|
1668
|
+
if (tokens.flow_measurement_policy) |policy| return compiledMeasuredFlow(children, parent_index, depth, output, len, 0, .{ .content = content, .first = style.virtual_first_index, .declared = style.virtual_item_count, .anchor = style.virtual_anchor_index, .overscan = style.virtual_overscan, .flow_count = widgetFlowChildCount(children), .gap = style.gap, .item_extent = style.virtual_item_extent, .scroll_y = scroll_y, .anchor_extent = style.virtual_anchor_extent, .total_extent = style.virtual_total_extent }, policy, tokens);
|
|
1669
|
+
if (tokens.intrinsic_layout_policy != null) return compiledVirtualVerticalChildren(children, content, parent_index, depth, output, len, scroll_y, style, tokens);
|
|
1479
1670
|
const flow_count = widgetFlowChildCount(children);
|
|
1480
1671
|
if (flow_count == 0) return;
|
|
1481
1672
|
|
|
@@ -1602,6 +1793,75 @@ fn layoutVariableVirtualChildren(
|
|
|
1602
1793
|
}
|
|
1603
1794
|
}
|
|
1604
1795
|
|
|
1796
|
+
fn compiledMeasuredFlow(children: []const Widget, parent_index: usize, depth: usize, output: []WidgetLayoutNode, len: *usize, operation: u8, options: @import("virtual_flow_policy.zig").Options, policy: @import("flow_measurement_policy.zig").Policy, tokens: DesignTokens) Error!void {
|
|
1797
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
1798
|
+
const plan = @import("flow_measurement_policy.zig").FlowPlan.init(scratch.get(), policy, children.len, operation, options) catch @panic("flow measurement allocation failed");
|
|
1799
|
+
defer plan.deinit();
|
|
1800
|
+
var flow: usize = 0;
|
|
1801
|
+
for (children, 0..) |child, index| {
|
|
1802
|
+
const takes_flow = widgetTakesFlowSlot(child);
|
|
1803
|
+
plan.setChild(index, child, options.first +% flow, takes_flow, primaryUnderlineTabsFillWidth(child, tokens));
|
|
1804
|
+
if (takes_flow) flow += 1;
|
|
1805
|
+
}
|
|
1806
|
+
while (true) {
|
|
1807
|
+
const result = plan.run();
|
|
1808
|
+
const measured = switch (result.action()) {
|
|
1809
|
+
.done => break,
|
|
1810
|
+
.extent => intrinsicWidgetSize(children[result.index()], tokens).height,
|
|
1811
|
+
.height => variableVirtualRowExtent(children[result.index()], result.width(), tokens, depth + 1),
|
|
1812
|
+
.width => intrinsicChildSize(children[result.index()], tokens, depth + 1).width,
|
|
1813
|
+
};
|
|
1814
|
+
plan.reply(result, measured);
|
|
1815
|
+
}
|
|
1816
|
+
if (!plan.active()) return;
|
|
1817
|
+
if (operation == 0) {
|
|
1818
|
+
if (plan.mode() == 0) output[parent_index].widget.layout.virtual_item_extent = plan.extent();
|
|
1819
|
+
output[parent_index].widget.semantics.list_item_count = plan.itemCount();
|
|
1820
|
+
}
|
|
1821
|
+
for (children, 0..) |source, index| {
|
|
1822
|
+
if (!plan.enabled(index)) continue;
|
|
1823
|
+
var child = source;
|
|
1824
|
+
if (operation == 0) {
|
|
1825
|
+
child.semantics.list_item_index = plan.itemIndex(index);
|
|
1826
|
+
child.semantics.list_item_count = plan.itemCount();
|
|
1827
|
+
}
|
|
1828
|
+
_ = try layoutWidgetDepth(child, plan.frame(index), parent_index, depth + 1, output, len, tokens);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
/// Native measurement and traversal surround one copied portable row plan.
|
|
1833
|
+
fn compiledVirtualVerticalChildren(children: []const Widget, content: geometry.RectF, parent_index: usize, depth: usize, output: []WidgetLayoutNode, len: *usize, scroll_y: f32, style: WidgetLayoutStyle, tokens: DesignTokens) Error!void {
|
|
1834
|
+
const flow_count = widgetFlowChildCount(children);
|
|
1835
|
+
if (flow_count == 0) return;
|
|
1836
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
1837
|
+
const plan = @import("virtual_flow_policy.zig").Plan.init(scratch.get(), tokens.intrinsic_layout_policy.?, children.len, .{ .content = content, .first = style.virtual_first_index, .declared = style.virtual_item_count, .anchor = style.virtual_anchor_index, .overscan = style.virtual_overscan, .flow_count = flow_count, .gap = style.gap, .item_extent = style.virtual_item_extent, .scroll_y = scroll_y, .anchor_extent = style.virtual_anchor_extent, .total_extent = style.virtual_total_extent }) catch @panic("virtual row allocation failed");
|
|
1838
|
+
defer plan.deinit();
|
|
1839
|
+
var flow: usize = 0;
|
|
1840
|
+
for (children, 0..) |child, index| {
|
|
1841
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
1842
|
+
plan.setChild(index, child, style.virtual_first_index +% flow);
|
|
1843
|
+
flow += 1;
|
|
1844
|
+
}
|
|
1845
|
+
plan.run(0);
|
|
1846
|
+
if (plan.mode() == 1) {
|
|
1847
|
+
for (children, 0..) |child, index| {
|
|
1848
|
+
if (widgetTakesFlowSlot(child) and !(child.frame.height > 0)) plan.setHeight(index, variableVirtualRowExtent(child, content.width, tokens, depth + 1));
|
|
1849
|
+
}
|
|
1850
|
+
} else if (!(style.virtual_item_extent > 0)) {
|
|
1851
|
+
plan.setExtent(preferredMainExtent(firstWidgetFlowChild(children).?, .vertical, tokens));
|
|
1852
|
+
}
|
|
1853
|
+
plan.run(0);
|
|
1854
|
+
if (plan.mode() == 0) output[parent_index].widget.layout.virtual_item_extent = plan.itemExtent();
|
|
1855
|
+
output[parent_index].widget.semantics.list_item_count = plan.itemCount();
|
|
1856
|
+
for (children, 0..) |source, index| {
|
|
1857
|
+
if (!plan.enabled(index)) continue;
|
|
1858
|
+
var child = source;
|
|
1859
|
+
child.semantics.list_item_index = plan.itemIndex(index);
|
|
1860
|
+
child.semantics.list_item_count = plan.itemCount();
|
|
1861
|
+
_ = try layoutWidgetDepth(child, plan.frame(index), parent_index, depth + 1, output, len, tokens);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1605
1865
|
fn variableVirtualChildExtent(child: Widget, width: f32, tokens: DesignTokens, depth: usize) f32 {
|
|
1606
1866
|
return clampIntrinsicAxis(
|
|
1607
1867
|
if (child.frame.height > 0) child.frame.height else variableVirtualRowExtent(child, width, tokens, depth + 1),
|
|
@@ -1644,6 +1904,8 @@ fn layoutVariableVirtualChild(
|
|
|
1644
1904
|
/// non-virtual list_item keeps its classic intrinsic sizing
|
|
1645
1905
|
/// byte-identically.
|
|
1646
1906
|
fn variableVirtualRowExtent(child: Widget, width: f32, tokens: DesignTokens, depth: usize) f32 {
|
|
1907
|
+
if (child.kind == .list_item and tokens.measurement_coordination_policy != null) return compiledWrappedExtent(child, width, tokens, depth, true, false);
|
|
1908
|
+
if (child.kind == .list_item and tokens.intrinsic_layout_policy != null) return compiledWrappedExtentReference(child, width, tokens, depth, true, false);
|
|
1647
1909
|
if (child.kind != .list_item) return wrappedVerticalExtentForWidth(child, width, tokens, depth);
|
|
1648
1910
|
if (depth >= max_widget_depth) return preferredMainExtent(child, .vertical, tokens);
|
|
1649
1911
|
if (child.frame.height > 0) return clampMainExtent(child, .vertical, child.frame.height);
|
|
@@ -1700,6 +1962,18 @@ pub fn splitEffectiveFraction(value: f32, available: f32, first_min: f32, second
|
|
|
1700
1962
|
return std.math.clamp(base, bounds.low, bounds.high);
|
|
1701
1963
|
}
|
|
1702
1964
|
|
|
1965
|
+
/// Compiled splits choose their effective fraction beside the app model.
|
|
1966
|
+
/// Native supplies measured extents and keeps the reference for other trees.
|
|
1967
|
+
pub fn widgetSplitEffectiveFraction(widget: Widget, value: f32, available: f32, first_min: f32, second_min: f32, applied: bool) f32 {
|
|
1968
|
+
return event_model.widgetCompiledSplitValue(widget, .{
|
|
1969
|
+
.operation = if (applied) 1 else 0,
|
|
1970
|
+
.value = value,
|
|
1971
|
+
.available = available,
|
|
1972
|
+
.first_min = first_min,
|
|
1973
|
+
.second_min = second_min,
|
|
1974
|
+
}) orelse splitEffectiveFraction(if (applied) @max(value, 0.0001) else value, available, first_min, second_min);
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1703
1977
|
/// Split layout: [pane 1][divider][pane 2] along the horizontal axis.
|
|
1704
1978
|
/// The divider is the builder-synthesized `.split_divider` child; panes
|
|
1705
1979
|
/// are the remaining flow children (exactly two by the validator's
|
|
@@ -1715,6 +1989,20 @@ fn layoutSplitChildren(
|
|
|
1715
1989
|
len: *usize,
|
|
1716
1990
|
tokens: DesignTokens,
|
|
1717
1991
|
) Error!void {
|
|
1992
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
1993
|
+
var scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
1994
|
+
const plan = coordination.ChildPlan.init(scratch.get(), policy, widget.children.len, 0, .split, content, widget.layout.gap) catch @panic("split layout program allocation failed");
|
|
1995
|
+
defer plan.deinit();
|
|
1996
|
+
for (widget.children, 0..) |child, i| plan.setChild(i, child, false);
|
|
1997
|
+
while (true) {
|
|
1998
|
+
const result = plan.run();
|
|
1999
|
+
if (result.action() == .done) break;
|
|
2000
|
+
if (result.action() != .fraction) @panic("unexpected split layout capability");
|
|
2001
|
+
plan.replyFraction(result, widgetSplitEffectiveFraction(widget, widget.value, result.available(), result.firstMin(), result.secondMin(), false));
|
|
2002
|
+
}
|
|
2003
|
+
try applyReadyLayoutChildren(plan, widget.children, parent_index, depth, output, len, .init(0, 0, 0, 0), tokens);
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
1718
2006
|
var panes: [2]?Widget = .{ null, null };
|
|
1719
2007
|
var divider: ?Widget = null;
|
|
1720
2008
|
var extra_start: ?usize = null;
|
|
@@ -1737,7 +2025,7 @@ fn layoutSplitChildren(
|
|
|
1737
2025
|
const available = @max(0, content.width - divider_extent);
|
|
1738
2026
|
const first_min = if (panes[0]) |pane| nonNegative(pane.layout.min_size.width) else 0;
|
|
1739
2027
|
const second_min = if (panes[1]) |pane| nonNegative(pane.layout.min_size.width) else 0;
|
|
1740
|
-
const fraction =
|
|
2028
|
+
const fraction = widgetSplitEffectiveFraction(widget, widget.value, available, first_min, second_min, false);
|
|
1741
2029
|
const first_width = if (panes[1] == null) available else available * fraction;
|
|
1742
2030
|
|
|
1743
2031
|
var cursor = content.x;
|
|
@@ -1813,6 +2101,34 @@ pub fn slideSplitChildren(
|
|
|
1813
2101
|
node_index: usize,
|
|
1814
2102
|
nodes: []WidgetLayoutNode,
|
|
1815
2103
|
) void {
|
|
2104
|
+
slideSplitChildrenWithTokens(frame, fraction, node_index, nodes, .{});
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
pub fn slideSplitChildrenWithTokens(frame: geometry.RectF, fraction: f32, node_index: usize, nodes: []WidgetLayoutNode, tokens: DesignTokens) void {
|
|
2108
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
2109
|
+
var scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
2110
|
+
const content = frame.inset(nodes[node_index].widget.layout.padding).normalized();
|
|
2111
|
+
const plan = coordination.ChildPlan.init(scratch.get(), policy, nodes.len, 0, .slide, content, 0) catch @panic("split slide program allocation failed");
|
|
2112
|
+
defer plan.deinit();
|
|
2113
|
+
plan.setRoot(node_index);
|
|
2114
|
+
for (nodes, 0..) |node, i| plan.setNode(i, node);
|
|
2115
|
+
while (true) {
|
|
2116
|
+
const result = plan.run();
|
|
2117
|
+
if (result.action() == .done) break;
|
|
2118
|
+
if (result.action() != .fraction) @panic("unexpected split slide capability");
|
|
2119
|
+
plan.replyFraction(result, widgetSplitEffectiveFraction(nodes[node_index].widget, fraction, result.available(), result.firstMin(), result.secondMin(), true));
|
|
2120
|
+
}
|
|
2121
|
+
const count = std.mem.readInt(u32, plan.result[8..12], .little);
|
|
2122
|
+
for (0..count) |i| {
|
|
2123
|
+
const index = plan.source(i);
|
|
2124
|
+
if (plan.flags(i) & 1 != 0) nodes[index].widget.value = plan.value(i);
|
|
2125
|
+
if (plan.flags(i) & 2 != 0) {
|
|
2126
|
+
nodes[index].frame = plan.frame(i);
|
|
2127
|
+
nodes[index].widget.frame = nodes[index].frame;
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
return;
|
|
2131
|
+
}
|
|
1816
2132
|
const split_depth = nodes[node_index].depth;
|
|
1817
2133
|
var pane_indices: [2]?usize = .{ null, null };
|
|
1818
2134
|
var divider_index: ?usize = null;
|
|
@@ -1840,7 +2156,7 @@ pub fn slideSplitChildren(
|
|
|
1840
2156
|
// The same clamp family the runtime's drag echo applies: a
|
|
1841
2157
|
// sub-epsilon fraction stays a sliver instead of falling into the
|
|
1842
2158
|
// `<= 0` unset sentinel, and pane min widths bound the boundary.
|
|
1843
|
-
const effective =
|
|
2159
|
+
const effective = widgetSplitEffectiveFraction(nodes[node_index].widget, fraction, available, first_min, second_min, true);
|
|
1844
2160
|
|
|
1845
2161
|
const first_width = available * effective;
|
|
1846
2162
|
const divider_x = content.x + first_width;
|
|
@@ -1883,7 +2199,44 @@ pub fn widgetKindStacksChildren(kind: widget_model.WidgetKind) bool {
|
|
|
1883
2199
|
};
|
|
1884
2200
|
}
|
|
1885
2201
|
|
|
2202
|
+
fn layoutStackChildren(children: []const Widget, content: geometry.RectF, parent: usize, depth: usize, output: []WidgetLayoutNode, len: *usize, tokens: DesignTokens) Error!void {
|
|
2203
|
+
if (tokens.layout_coordination_policy) |policy| {
|
|
2204
|
+
var scratch = std.heap.stackFallback(2048, std.heap.page_allocator);
|
|
2205
|
+
const plan = coordination.ChildPlan.init(scratch.get(), policy, children.len, 0, .stack, content, 0) catch @panic("stack layout program allocation failed");
|
|
2206
|
+
defer plan.deinit();
|
|
2207
|
+
for (children, 0..) |child, i| plan.setChild(i, child, primaryUnderlineTabsFillWidth(child, tokens));
|
|
2208
|
+
try applyLayoutChildren(plan, children, parent, depth, output, len, .init(0, 0, 0, 0), tokens);
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
for (children) |child| {
|
|
2212
|
+
if (!widgetTakesFlowSlot(child)) continue;
|
|
2213
|
+
_ = try layoutWidgetDepth(child, stackChildFrame(content, child, tokens), parent, depth + 1, output, len, tokens);
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
fn applyLayoutChildren(plan: coordination.ChildPlan, children: []const Widget, parent: usize, depth: usize, output: []WidgetLayoutNode, len: *usize, root: geometry.RectF, tokens: DesignTokens) Error!void {
|
|
2217
|
+
if (plan.run().action() != .done) @panic("unexpected child layout capability");
|
|
2218
|
+
try applyReadyLayoutChildren(plan, children, parent, depth, output, len, root, tokens);
|
|
2219
|
+
}
|
|
2220
|
+
fn applyReadyLayoutChildren(plan: coordination.ChildPlan, children: []const Widget, parent: usize, depth: usize, output: []WidgetLayoutNode, len: *usize, root: geometry.RectF, tokens: DesignTokens) Error!void {
|
|
2221
|
+
const count = std.mem.readInt(u32, plan.result[8..12], .little);
|
|
2222
|
+
for (0..count) |i| {
|
|
2223
|
+
var child = children[plan.source(i)];
|
|
2224
|
+
const flags = plan.flags(i);
|
|
2225
|
+
if (flags & 1 != 0) child.value = plan.value(i);
|
|
2226
|
+
const frame = if (flags == 4) anchoredWidgetFrame(child, child.layout.anchor orelse @panic("missing planned anchor"), plan.frame(i), root, tokens) else plan.frame(i);
|
|
2227
|
+
_ = try layoutWidgetDepth(child, frame, parent, depth + 1, output, len, tokens);
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
|
|
1886
2231
|
fn stackChildFrame(content: geometry.RectF, child: Widget, tokens: DesignTokens) geometry.RectF {
|
|
2232
|
+
if (tokens.container_layout_policy) |policy| {
|
|
2233
|
+
var scratch = std.heap.stackFallback(256, std.heap.page_allocator);
|
|
2234
|
+
const plan = @import("container_layout_policy.zig").Plan.init(scratch.get(), policy, 1, content, 0, 0, 0, 0) catch @panic("stack layout allocation failed");
|
|
2235
|
+
defer plan.deinit();
|
|
2236
|
+
plan.setChild(0, .{ .flags = 1 | (if (primaryUnderlineTabsFillWidth(child, tokens)) @as(u32, 2) else 0), .main = child.frame.width, .cross = child.frame.height, .offset_main = child.frame.x, .offset_cross = child.frame.y, .min_main = child.layout.min_size.width, .max_main = child.layout.max_size.width, .min_cross = child.layout.min_size.height, .max_cross = child.layout.max_size.height });
|
|
2237
|
+
plan.run(3);
|
|
2238
|
+
return plan.frame(0);
|
|
2239
|
+
}
|
|
1887
2240
|
const width = if (child.frame.width > 0) child.frame.width else content.width;
|
|
1888
2241
|
const height = if (child.frame.height > 0) child.frame.height else content.height;
|
|
1889
2242
|
var frame = geometry.RectF.init(
|
|
@@ -1945,6 +2298,8 @@ fn accordionContentFrame(widget: Widget, content: geometry.RectF, tokens: Design
|
|
|
1945
2298
|
/// vertical extent uses, replayed so a closed pose can hand children
|
|
1946
2299
|
/// full-size frames.
|
|
1947
2300
|
fn accordionOpenContentExtent(widget: Widget, width: f32, tokens: DesignTokens, depth: usize) f32 {
|
|
2301
|
+
if (tokens.measurement_coordination_policy != null) return compiledWrappedExtent(widget, width, tokens, depth, false, true);
|
|
2302
|
+
if (tokens.intrinsic_layout_policy != null) return compiledWrappedExtentReference(widget, width, tokens, depth, false, true);
|
|
1948
2303
|
var max_height: f32 = 0;
|
|
1949
2304
|
for (widget.children) |child| {
|
|
1950
2305
|
if (!widgetTakesFlowSlot(child)) continue;
|
|
@@ -1954,12 +2309,99 @@ fn accordionOpenContentExtent(widget: Widget, width: f32, tokens: DesignTokens,
|
|
|
1954
2309
|
return max_height;
|
|
1955
2310
|
}
|
|
1956
2311
|
|
|
2312
|
+
/// Native supplies measurement capabilities and owns copied storage while
|
|
2313
|
+
/// TypeScript selects widths, short circuits and complete height composition.
|
|
2314
|
+
/// Recursive calls never invalidate a borrowed core/view result.
|
|
2315
|
+
fn compiledWrappedExtent(widget: Widget, width: f32, tokens: DesignTokens, depth: usize, variable_row: bool, accordion_content: bool) f32 {
|
|
2316
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
2317
|
+
const plan = @import("measurement_coordination_policy.zig").WrappedPlan.init(scratch.get(), widget, tokens, width, depth, max_widget_depth, variable_row, accordion_content, accordionChildrenVisible(widget)) catch @panic("wrapped measurement allocation failed");
|
|
2318
|
+
defer plan.deinit();
|
|
2319
|
+
for (widget.children, 0..) |child, index| plan.setChild(index, child, widgetTakesFlowSlot(child));
|
|
2320
|
+
while (true) {
|
|
2321
|
+
const result = plan.run();
|
|
2322
|
+
const measured = switch (result.action()) {
|
|
2323
|
+
.done => return result.height(),
|
|
2324
|
+
.intrinsic => intrinsicWidgetSize(widget, tokens).height,
|
|
2325
|
+
.paragraph => spanParagraphHeight(widget, result.width(), tokens),
|
|
2326
|
+
.row_width => rowChildWidth(widget, result.width(), result.index(), tokens),
|
|
2327
|
+
.bubble_width => intrinsicWidgetSizeDepth(widget.children[result.index()], tokens, depth + 1).width,
|
|
2328
|
+
.child_height => wrappedVerticalExtentForWidth(widget.children[result.index()], result.width(), tokens, depth + 1),
|
|
2329
|
+
};
|
|
2330
|
+
plan.reply(result, measured);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
// Retained native coordinator for existing callers and parity verification.
|
|
2335
|
+
fn compiledWrappedExtentReference(widget: Widget, width: f32, tokens: DesignTokens, depth: usize, variable_row: bool, accordion_content: bool) f32 {
|
|
2336
|
+
const wrapped = @import("wrapped_layout_policy.zig");
|
|
2337
|
+
const padding = if (variable_row) widget.layout.padding else widgetLayoutPadding(widget, tokens);
|
|
2338
|
+
const text_size = widgetBodyTextSize(widget, tokens);
|
|
2339
|
+
const title_height = if (widget.kind == .accordion) accordionHeaderHeight(widget, tokens) else widgetLineHeightWithTokens(text_size, tokens);
|
|
2340
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
2341
|
+
const plan = wrapped.Plan.init(scratch.get(), tokens.intrinsic_layout_policy.?, widget.children.len, .{
|
|
2342
|
+
.kind = widget.kind,
|
|
2343
|
+
.spans = widget.spans.len > 0,
|
|
2344
|
+
.virtualized = widget.layout.virtualized,
|
|
2345
|
+
.titled = widget.text.len > 0,
|
|
2346
|
+
.open = accordionChildrenVisible(widget),
|
|
2347
|
+
.variable_row = variable_row,
|
|
2348
|
+
.depth = depth,
|
|
2349
|
+
.depth_limit = max_widget_depth,
|
|
2350
|
+
.width = width,
|
|
2351
|
+
.authored_height = widget.frame.height,
|
|
2352
|
+
.min_height = widget.layout.min_size.height,
|
|
2353
|
+
.max_height = widget.layout.max_size.height,
|
|
2354
|
+
.padding = padding,
|
|
2355
|
+
.gap = widget.layout.gap,
|
|
2356
|
+
.title_height = title_height,
|
|
2357
|
+
.indent = widgetSizedDensityValue(widget, tokens, 16) + widgetControlInset(widget, tokens, tokens.spacing.md),
|
|
2358
|
+
.floor = widgetSizedDensityValue(widget, tokens, 52),
|
|
2359
|
+
.inset = widgetAlertInset(widget, tokens),
|
|
2360
|
+
.title_gap = densityValue(tokens, tokens.spacing.xs),
|
|
2361
|
+
}) catch @panic("wrapped layout allocation failed");
|
|
2362
|
+
defer plan.deinit();
|
|
2363
|
+
for (widget.children, 0..) |child, index| {
|
|
2364
|
+
if (widgetTakesFlowSlot(child)) plan.setChild(index, child.frame.width, bubbleThreadCapEligible(child));
|
|
2365
|
+
}
|
|
2366
|
+
const operation: u8 = if (accordion_content) 2 else 0;
|
|
2367
|
+
plan.run(operation);
|
|
2368
|
+
switch (plan.action()) {
|
|
2369
|
+
.fallback => plan.setFallback(preferredMainExtent(widget, .vertical, tokens)),
|
|
2370
|
+
.paragraph => plan.setParagraph(spanParagraphHeight(widget, plan.innerWidth(), tokens)),
|
|
2371
|
+
.authored, .header => {},
|
|
2372
|
+
.children => {
|
|
2373
|
+
var resolved = false;
|
|
2374
|
+
for (widget.children, 0..) |child, index| {
|
|
2375
|
+
switch (plan.query(index)) {
|
|
2376
|
+
0 => {},
|
|
2377
|
+
1 => {
|
|
2378
|
+
plan.resolveWidth(index, rowChildWidth(widget, plan.innerWidth(), index, tokens));
|
|
2379
|
+
resolved = true;
|
|
2380
|
+
},
|
|
2381
|
+
2 => {
|
|
2382
|
+
const available = plan.innerWidth();
|
|
2383
|
+
plan.resolveWidth(index, bubbleThreadWidthCap(child, available, @min(available, intrinsicWidgetSizeDepth(child, tokens, depth + 1).width)));
|
|
2384
|
+
resolved = true;
|
|
2385
|
+
},
|
|
2386
|
+
else => @panic("invalid wrapped measurement query"),
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
if (resolved) plan.run(operation);
|
|
2390
|
+
for (widget.children, 0..) |child, index| {
|
|
2391
|
+
if (widgetTakesFlowSlot(child)) plan.setHeight(index, wrappedVerticalExtentForWidth(child, plan.width(index), tokens, depth + 1));
|
|
2392
|
+
}
|
|
2393
|
+
},
|
|
2394
|
+
}
|
|
2395
|
+
plan.run(if (accordion_content) 2 else 1);
|
|
2396
|
+
return plan.height();
|
|
2397
|
+
}
|
|
2398
|
+
|
|
1957
2399
|
pub fn accordionHeaderHeight(widget: Widget, tokens: DesignTokens) f32 {
|
|
1958
2400
|
// The house trigger band: the label line with py-4 — a spacing.lg
|
|
1959
2401
|
// inset above and below it (density/size scaled).
|
|
1960
2402
|
const text_size = widgetBodyTextSize(widget, tokens);
|
|
1961
2403
|
const inset = widgetControlInset(widget, tokens, tokens.spacing.lg);
|
|
1962
|
-
return @max(widgetControlHeight(widget, tokens),
|
|
2404
|
+
return @max(widgetControlHeight(widget, tokens), widgetLineHeightWithTokens(text_size, tokens) + inset * 2);
|
|
1963
2405
|
}
|
|
1964
2406
|
|
|
1965
2407
|
/// Alert children start under the chrome-drawn title line and hang past
|
|
@@ -1973,7 +2415,7 @@ fn alertContentFrame(widget: Widget, content: geometry.RectF, tokens: DesignToke
|
|
|
1973
2415
|
const text_gap = widgetControlInset(widget, tokens, tokens.spacing.md);
|
|
1974
2416
|
const title_gap = densityValue(tokens, tokens.spacing.xs);
|
|
1975
2417
|
const indent = @min(content.width, icon_size + text_gap);
|
|
1976
|
-
const y = @min(content.maxY(), content.y +
|
|
2418
|
+
const y = @min(content.maxY(), content.y + widgetLineHeightWithTokens(text_size, tokens) + title_gap);
|
|
1977
2419
|
return geometry.RectF.init(
|
|
1978
2420
|
content.x + indent,
|
|
1979
2421
|
y,
|
|
@@ -1987,6 +2429,15 @@ pub fn intrinsicWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF
|
|
|
1987
2429
|
}
|
|
1988
2430
|
|
|
1989
2431
|
fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
2432
|
+
if (tokens.intrinsic_layout_policy) |policy| {
|
|
2433
|
+
var owned = tokens;
|
|
2434
|
+
owned.control_geometry_policy = owned.control_geometry_policy orelse policy;
|
|
2435
|
+
if (@import("widget_metric_policy.zig").intrinsic(widget, owned)) |size| return size;
|
|
2436
|
+
return compiledIntrinsicMeasure(widget, owned, depth);
|
|
2437
|
+
}
|
|
2438
|
+
if (tokens.control_geometry_policy != null) {
|
|
2439
|
+
if (@import("widget_metric_policy.zig").intrinsic(widget, tokens)) |size| return size;
|
|
2440
|
+
}
|
|
1990
2441
|
// The composed-media contract (`WidgetLayoutStyle.zero_intrinsic`):
|
|
1991
2442
|
// the container measures like the media-surface leaf regardless of
|
|
1992
2443
|
// what chrome it composes. Declared width/height still apply — they
|
|
@@ -2029,7 +2480,7 @@ fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize)
|
|
|
2029
2480
|
// A span-carrying cell (markdown tables) measures like a padded
|
|
2030
2481
|
// span paragraph; classic cells keep the single-line row metric.
|
|
2031
2482
|
.data_cell => if (widget.spans.len > 0)
|
|
2032
|
-
paddedIntrinsicSize(widget, intrinsicTextWidgetSize(widget, tokens, widgetBodyTextSize(widget, tokens)))
|
|
2483
|
+
paddedIntrinsicSize(widget, tokens, intrinsicTextWidgetSize(widget, tokens, widgetBodyTextSize(widget, tokens)))
|
|
2033
2484
|
else if (widget.children.len > 0)
|
|
2034
2485
|
intrinsicAxisChildrenSize(widget, tokens, .horizontal, depth)
|
|
2035
2486
|
else
|
|
@@ -2094,8 +2545,38 @@ fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize)
|
|
|
2094
2545
|
};
|
|
2095
2546
|
}
|
|
2096
2547
|
|
|
2548
|
+
fn compiledIntrinsicMeasure(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
2549
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
2550
|
+
const plan = @import("intrinsic_measure_policy.zig").Plan.init(scratch.get(), widget, tokens, depth, max_widget_depth, booleanControlSelected(widget)) catch @panic("intrinsic measurement allocation failed");
|
|
2551
|
+
defer plan.deinit();
|
|
2552
|
+
for (widget.children, 0..) |child, index| plan.setChild(index, child, widgetTakesFlowSlot(child));
|
|
2553
|
+
while (true) {
|
|
2554
|
+
const result = plan.run();
|
|
2555
|
+
const measured = switch (result.action()) {
|
|
2556
|
+
.done => return result.size(),
|
|
2557
|
+
.title => intrinsicTextWidgetSize(widget, tokens, result.textSize()),
|
|
2558
|
+
.row => blk: {
|
|
2559
|
+
var leaf = widget;
|
|
2560
|
+
leaf.children = &.{};
|
|
2561
|
+
break :blk @import("widget_metric_policy.zig").intrinsic(leaf, tokens) orelse @panic("missing intrinsic row owner");
|
|
2562
|
+
},
|
|
2563
|
+
.child => intrinsicWidgetSizeDepth(widget.children[result.index()], tokens, depth + 1),
|
|
2564
|
+
.wrapped => geometry.SizeF.init(0, wrappedVerticalExtentForWidth(widget.children[result.index()], result.width(), tokens, depth + 1)),
|
|
2565
|
+
};
|
|
2566
|
+
plan.reply(result, measured);
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2097
2570
|
fn intrinsicChildSize(child: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
2098
2571
|
const intrinsic = intrinsicWidgetSizeDepth(child, tokens, depth);
|
|
2572
|
+
if (tokens.intrinsic_layout_policy) |policy| {
|
|
2573
|
+
var scratch = std.heap.stackFallback(256, std.heap.page_allocator);
|
|
2574
|
+
const plan = @import("intrinsic_layout_policy.zig").Plan.init(scratch.get(), policy, 1, .{}) catch @panic("intrinsic child allocation failed");
|
|
2575
|
+
defer plan.deinit();
|
|
2576
|
+
plan.setChild(0, intrinsicChildFacts(child, intrinsic));
|
|
2577
|
+
plan.run(0);
|
|
2578
|
+
return plan.child(0);
|
|
2579
|
+
}
|
|
2099
2580
|
return geometry.SizeF.init(
|
|
2100
2581
|
clampIntrinsicAxis(@max(intrinsic.width, nonNegative(child.frame.width)), child.layout.min_size.width, child.layout.max_size.width),
|
|
2101
2582
|
clampIntrinsicAxis(@max(intrinsic.height, nonNegative(child.frame.height)), child.layout.min_size.height, child.layout.max_size.height),
|
|
@@ -2158,8 +2639,8 @@ fn intrinsicAxisChildrenSize(widget: Widget, tokens: DesignTokens, axis: LayoutA
|
|
|
2158
2639
|
.horizontal => geometry.SizeF.init(main_sum + gap, cross_max),
|
|
2159
2640
|
.vertical => geometry.SizeF.init(cross_max, main_sum + gap),
|
|
2160
2641
|
};
|
|
2161
|
-
if (widget.kind == .tabs) return paddedIntrinsicSizeWithPadding(widget, content_size, tabsLayoutPadding(widget, tokens));
|
|
2162
|
-
return paddedIntrinsicSize(widget, content_size);
|
|
2642
|
+
if (widget.kind == .tabs) return paddedIntrinsicSizeWithPadding(widget, tokens, content_size, tabsLayoutPadding(widget, tokens));
|
|
2643
|
+
return paddedIntrinsicSize(widget, tokens, content_size);
|
|
2163
2644
|
}
|
|
2164
2645
|
|
|
2165
2646
|
fn intrinsicOverlayChildrenSize(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
@@ -2172,7 +2653,7 @@ fn intrinsicOverlayChildrenSize(widget: Widget, tokens: DesignTokens, depth: usi
|
|
|
2172
2653
|
width_max = @max(width_max, size.width);
|
|
2173
2654
|
height_max = @max(height_max, size.height);
|
|
2174
2655
|
}
|
|
2175
|
-
return paddedIntrinsicSize(widget, geometry.SizeF.init(width_max, height_max));
|
|
2656
|
+
return paddedIntrinsicSize(widget, tokens, geometry.SizeF.init(width_max, height_max));
|
|
2176
2657
|
}
|
|
2177
2658
|
|
|
2178
2659
|
/// A horizontal viewport stays width-neutral but hugs the full vertical
|
|
@@ -2193,7 +2674,7 @@ fn intrinsicHorizontalScrollSize(widget: Widget, tokens: DesignTokens, depth: us
|
|
|
2193
2674
|
wrappedVerticalExtentForWidth(child, child_width, tokens, depth + 1),
|
|
2194
2675
|
);
|
|
2195
2676
|
}
|
|
2196
|
-
const padded = paddedIntrinsicSize(widget, geometry.SizeF.init(0, height_max));
|
|
2677
|
+
const padded = paddedIntrinsicSize(widget, tokens, geometry.SizeF.init(0, height_max));
|
|
2197
2678
|
return geometry.SizeF.init(0, padded.height);
|
|
2198
2679
|
}
|
|
2199
2680
|
|
|
@@ -2215,7 +2696,7 @@ fn intrinsicGridChildrenSize(widget: Widget, tokens: DesignTokens, depth: usize)
|
|
|
2215
2696
|
// builds when a parent intrinsically measures a maxInt-columns grid.
|
|
2216
2697
|
const rows = gridRowCount(flow_count, columns);
|
|
2217
2698
|
const gap = nonNegative(widget.layout.gap);
|
|
2218
|
-
return paddedIntrinsicSize(widget, geometry.SizeF.init(
|
|
2699
|
+
return paddedIntrinsicSize(widget, tokens, geometry.SizeF.init(
|
|
2219
2700
|
cell_width * @as(f32, @floatFromInt(columns)) + gap * @as(f32, @floatFromInt(columns - 1)),
|
|
2220
2701
|
cell_height * @as(f32, @floatFromInt(rows)) + gap * @as(f32, @floatFromInt(rows - 1)),
|
|
2221
2702
|
));
|
|
@@ -2225,12 +2706,23 @@ fn intrinsicOwnMinSize(widget: Widget) geometry.SizeF {
|
|
|
2225
2706
|
return geometry.SizeF.init(nonNegative(widget.layout.min_size.width), nonNegative(widget.layout.min_size.height));
|
|
2226
2707
|
}
|
|
2227
2708
|
|
|
2228
|
-
fn
|
|
2709
|
+
fn intrinsicChildFacts(child: Widget, measured: geometry.SizeF) @import("intrinsic_layout_policy.zig").Child {
|
|
2710
|
+
return .{ .flags = 1 | (if (child.kind == .separator) @as(u32, 2) else 0), .measured = measured, .authored = .init(child.frame.width, child.frame.height), .min_size = child.layout.min_size, .max_size = child.layout.max_size };
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
fn paddedIntrinsicSize(widget: Widget, tokens: DesignTokens, content: geometry.SizeF) geometry.SizeF {
|
|
2229
2714
|
const padding = widget.layout.padding;
|
|
2230
|
-
return paddedIntrinsicSizeWithPadding(widget, content, padding);
|
|
2715
|
+
return paddedIntrinsicSizeWithPadding(widget, tokens, content, padding);
|
|
2231
2716
|
}
|
|
2232
2717
|
|
|
2233
|
-
fn paddedIntrinsicSizeWithPadding(widget: Widget, content: geometry.SizeF, padding: geometry.InsetsF) geometry.SizeF {
|
|
2718
|
+
fn paddedIntrinsicSizeWithPadding(widget: Widget, tokens: DesignTokens, content: geometry.SizeF, padding: geometry.InsetsF) geometry.SizeF {
|
|
2719
|
+
if (tokens.intrinsic_layout_policy) |policy| {
|
|
2720
|
+
var scratch = std.heap.stackFallback(256, std.heap.page_allocator);
|
|
2721
|
+
const plan = @import("intrinsic_layout_policy.zig").Plan.init(scratch.get(), policy, 0, .{ .content = content, .padding = padding, .min_size = widget.layout.min_size }) catch @panic("intrinsic padding allocation failed");
|
|
2722
|
+
defer plan.deinit();
|
|
2723
|
+
plan.run(6);
|
|
2724
|
+
return plan.size();
|
|
2725
|
+
}
|
|
2234
2726
|
return geometry.SizeF.init(
|
|
2235
2727
|
@max(content.width + padding.left + padding.right, widget.layout.min_size.width),
|
|
2236
2728
|
@max(content.height + padding.top + padding.bottom, widget.layout.min_size.height),
|
|
@@ -2243,12 +2735,12 @@ fn intrinsicTextWidgetSize(widget: Widget, tokens: DesignTokens, text_size: f32)
|
|
|
2243
2735
|
return geometry.SizeF.init(
|
|
2244
2736
|
text_spans_model.textSpansIntrinsicWidth(widget.spans, options) +
|
|
2245
2737
|
widgetCodeLineNumberGutterWidth(widget, tokens),
|
|
2246
|
-
|
|
2738
|
+
widgetLineHeightWithTokens(text_size * text_spans_model.textSpansMaxScale(widget.spans), tokens),
|
|
2247
2739
|
);
|
|
2248
2740
|
}
|
|
2249
2741
|
return geometry.SizeF.init(
|
|
2250
2742
|
measuredTextWidth(tokens, widget.text, text_size),
|
|
2251
|
-
|
|
2743
|
+
widgetLineHeightWithTokens(text_size, tokens),
|
|
2252
2744
|
);
|
|
2253
2745
|
}
|
|
2254
2746
|
|
|
@@ -2279,14 +2771,14 @@ fn intrinsicAlertWidgetSize(widget: Widget, tokens: DesignTokens, depth: usize)
|
|
|
2279
2771
|
const text = intrinsicTextWidgetSize(widget, tokens, text_size);
|
|
2280
2772
|
var size = geometry.SizeF.init(
|
|
2281
2773
|
@max(widgetSizedDensityValue(widget, tokens, 240), text.width + padding.left + padding.right + icon_size + text_gap),
|
|
2282
|
-
@max(widgetSizedDensityValue(widget, tokens, 52),
|
|
2774
|
+
@max(widgetSizedDensityValue(widget, tokens, 52), widgetLineHeightWithTokens(text_size, tokens) + padding.top + padding.bottom),
|
|
2283
2775
|
);
|
|
2284
2776
|
// A description column under the title (`alertContentFrame`) grows
|
|
2285
2777
|
// the alert instead of overflowing it.
|
|
2286
2778
|
const children = intrinsicStackedChildrenSize(widget, tokens, depth);
|
|
2287
2779
|
if (children.height > 0 and widget.text.len > 0) {
|
|
2288
2780
|
const title_gap = densityValue(tokens, tokens.spacing.xs);
|
|
2289
|
-
size.height = @max(size.height,
|
|
2781
|
+
size.height = @max(size.height, widgetLineHeightWithTokens(text_size, tokens) + title_gap + children.height + padding.top + padding.bottom);
|
|
2290
2782
|
size.width = @max(size.width, children.width + icon_size + text_gap + padding.left + padding.right);
|
|
2291
2783
|
} else if (children.height > 0) {
|
|
2292
2784
|
size.height = @max(size.height, children.height + padding.top + padding.bottom);
|
|
@@ -2320,16 +2812,16 @@ fn intrinsicAccordionWidgetSize(widget: Widget, tokens: DesignTokens, depth: usi
|
|
|
2320
2812
|
content = intrinsicStackedChildrenSize(widget, tokens, depth);
|
|
2321
2813
|
}
|
|
2322
2814
|
const gap = if (content.height > 0) nonNegative(widget.layout.gap) else 0;
|
|
2323
|
-
return paddedIntrinsicSize(widget, geometry.SizeF.init(content.width, header_height + gap + content.height));
|
|
2815
|
+
return paddedIntrinsicSize(widget, tokens, geometry.SizeF.init(content.width, header_height + gap + content.height));
|
|
2324
2816
|
}
|
|
2325
2817
|
|
|
2326
2818
|
fn intrinsicCardWidgetSize(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
2327
|
-
const title_size =
|
|
2819
|
+
const title_size = widgetTypographySizeWithTokens(widget, tokens.typography.body_size + 1, tokens);
|
|
2328
2820
|
const inset = widgetControlInset(widget, tokens, tokens.spacing.lg);
|
|
2329
2821
|
const text = intrinsicTextWidgetSize(widget, tokens, title_size);
|
|
2330
2822
|
var size = geometry.SizeF.init(
|
|
2331
2823
|
@max(widgetSizedDensityValue(widget, tokens, 240), text.width + inset * 2),
|
|
2332
|
-
@max(widgetSizedDensityValue(widget, tokens, 120), if (widget.text.len > 0)
|
|
2824
|
+
@max(widgetSizedDensityValue(widget, tokens, 120), if (widget.text.len > 0) widgetLineHeightWithTokens(title_size, tokens) + inset * 2 else 0),
|
|
2333
2825
|
);
|
|
2334
2826
|
// Content-bearing cards grow around their children plus the card's
|
|
2335
2827
|
// own padding (the default 24px house inset) instead of clipping
|
|
@@ -2344,7 +2836,7 @@ fn intrinsicCardWidgetSize(widget: Widget, tokens: DesignTokens, depth: usize) g
|
|
|
2344
2836
|
}
|
|
2345
2837
|
|
|
2346
2838
|
fn intrinsicModalSurfaceWidgetSize(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
2347
|
-
const title_size =
|
|
2839
|
+
const title_size = widgetTypographySizeWithTokens(widget, tokens.typography.title_size, tokens);
|
|
2348
2840
|
const inset = widgetControlInset(widget, tokens, tokens.spacing.xl);
|
|
2349
2841
|
const text = intrinsicTextWidgetSize(widget, tokens, title_size);
|
|
2350
2842
|
const default_size = switch (widget.kind) {
|
|
@@ -2354,7 +2846,7 @@ fn intrinsicModalSurfaceWidgetSize(widget: Widget, tokens: DesignTokens, depth:
|
|
|
2354
2846
|
};
|
|
2355
2847
|
var size = geometry.SizeF.init(
|
|
2356
2848
|
@max(widgetSizedDensityValue(widget, tokens, default_size.width), text.width + inset * 2),
|
|
2357
|
-
@max(widgetSizedDensityValue(widget, tokens, default_size.height), if (widget.text.len > 0)
|
|
2849
|
+
@max(widgetSizedDensityValue(widget, tokens, default_size.height), if (widget.text.len > 0) widgetLineHeightWithTokens(title_size, tokens) + inset * 2 else 0),
|
|
2358
2850
|
);
|
|
2359
2851
|
// Content-bearing modal surfaces hug their children plus their own
|
|
2360
2852
|
// padding, like cards. The fixed default height is a placeholder for
|
|
@@ -2366,7 +2858,7 @@ fn intrinsicModalSurfaceWidgetSize(widget: Widget, tokens: DesignTokens, depth:
|
|
|
2366
2858
|
if (children.height > 0) {
|
|
2367
2859
|
const padding = widget.layout.padding;
|
|
2368
2860
|
size.height = children.height + padding.top + padding.bottom;
|
|
2369
|
-
if (widget.text.len > 0) size.height = @max(size.height,
|
|
2861
|
+
if (widget.text.len > 0) size.height = @max(size.height, widgetLineHeightWithTokens(title_size, tokens) + inset * 2);
|
|
2370
2862
|
size.width = @max(size.width, children.width + padding.left + padding.right);
|
|
2371
2863
|
}
|
|
2372
2864
|
return size;
|
|
@@ -2386,7 +2878,7 @@ fn intrinsicButtonWidgetSize(widget: Widget, tokens: DesignTokens) geometry.Size
|
|
|
2386
2878
|
0;
|
|
2387
2879
|
// Measured with the button-label face (not the body face) so the
|
|
2388
2880
|
// medium advances the render draws are the widths layout reserves.
|
|
2389
|
-
const text_width =
|
|
2881
|
+
const text_width = measureTextWidthForFontWithPolicy(tokens.text_measure, tokens.text_run_policy, tokens.typography.buttonFontId(), widget.text, widgetButtonTextSize(widget, tokens));
|
|
2390
2882
|
// Ceil to the snap grid (`pixelSnapCeil`): a button or toggle chip
|
|
2391
2883
|
// sized exactly to its measured label ("PID" in a sort-chip row)
|
|
2392
2884
|
// must not lose a fraction of a pixel to render-time edge snapping
|
|
@@ -2515,7 +3007,7 @@ fn intrinsicCheckboxWidgetSize(widget: Widget, tokens: DesignTokens) geometry.Si
|
|
|
2515
3007
|
// Ceil to the snap grid (`pixelSnapCeil`): the label tail after the
|
|
2516
3008
|
// box is measured exactly, and render-time edge snapping must not
|
|
2517
3009
|
// shave it into eliding.
|
|
2518
|
-
return geometry.SizeF.init(pixelSnapCeil(tokens, box_size + gap + label_width), @max(box_size,
|
|
3010
|
+
return geometry.SizeF.init(pixelSnapCeil(tokens, box_size + gap + label_width), @max(box_size, widgetLineHeightWithTokens(label_size, tokens)));
|
|
2519
3011
|
}
|
|
2520
3012
|
|
|
2521
3013
|
fn intrinsicRadioWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF {
|
|
@@ -2525,7 +3017,7 @@ fn intrinsicRadioWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF
|
|
|
2525
3017
|
const gap = if (widget.text.len > 0) widgetControlInset(widget, tokens, tokens.spacing.sm) else 0;
|
|
2526
3018
|
// Same label-exact tail as the checkbox: ceil so snapping cannot
|
|
2527
3019
|
// elide the label (`pixelSnapCeil`).
|
|
2528
|
-
return geometry.SizeF.init(pixelSnapCeil(tokens, circle_size + gap + label_width), @max(circle_size,
|
|
3020
|
+
return geometry.SizeF.init(pixelSnapCeil(tokens, circle_size + gap + label_width), @max(circle_size, widgetLineHeightWithTokens(label_size, tokens)));
|
|
2529
3021
|
}
|
|
2530
3022
|
|
|
2531
3023
|
fn intrinsicToggleWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF {
|
|
@@ -2535,7 +3027,7 @@ fn intrinsicToggleWidgetSize(widget: Widget, tokens: DesignTokens) geometry.Size
|
|
|
2535
3027
|
const label_size = widgetLabelTextSize(widget, tokens);
|
|
2536
3028
|
const label_width = measuredTextWidth(tokens, widget.text, label_size);
|
|
2537
3029
|
const gap = if (widget.text.len > 0) widgetControlInset(widget, tokens, tokens.spacing.sm) else 0;
|
|
2538
|
-
const height = @max(track_height,
|
|
3030
|
+
const height = @max(track_height, widgetLineHeightWithTokens(label_size, tokens));
|
|
2539
3031
|
// The renderer widens the track to 1.75x a tall row's height and
|
|
2540
3032
|
// snaps the track RECT itself to the pixel grid, where nearest-
|
|
2541
3033
|
// rounding can grow it past a fractional reserve (a 38.5px sm track
|
|
@@ -2681,6 +3173,37 @@ fn intrinsicMainExtent(widget: Widget, axis: LayoutAxis, tokens: DesignTokens) f
|
|
|
2681
3173
|
};
|
|
2682
3174
|
}
|
|
2683
3175
|
|
|
3176
|
+
fn containerChildFacts(child: Widget, axis: LayoutAxis, tokens: DesignTokens, comptime fill_primary_tabs: bool, comptime stretch_tab_triggers: bool, measure_cross: bool) @import("container_layout_policy.zig").Child {
|
|
3177
|
+
if (tokens.measurement_coordination_policy != null) {
|
|
3178
|
+
var plan = @import("measurement_coordination_policy.zig").ChildPlan.init(child, tokens, @intFromEnum(axis), fill_primary_tabs, stretch_tab_triggers, measure_cross);
|
|
3179
|
+
while (true) {
|
|
3180
|
+
const result = plan.run();
|
|
3181
|
+
if (result.action() == .done) return result.child();
|
|
3182
|
+
plan.reply(result, intrinsicWidgetSize(child, tokens));
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
const horizontal = axis == .horizontal;
|
|
3186
|
+
const authored_main = if (horizontal) child.frame.width else child.frame.height;
|
|
3187
|
+
const authored_cross = if (horizontal) child.frame.height else child.frame.width;
|
|
3188
|
+
return .{
|
|
3189
|
+
.flags = 1 | (if (fill_primary_tabs and child.kind == .tabs and (child.variant == .default or child.variant == .primary)) @as(u32, 2) else 0) |
|
|
3190
|
+
(if (primaryUnderlineTabsFillWidth(child, tokens)) @as(u32, 4) else 0) |
|
|
3191
|
+
(if (child.kind == .bubble and child.variant != .ghost) @as(u32, 8) else 0) |
|
|
3192
|
+
(if (stretch_tab_triggers and child.kind == .segmented_control) @as(u32, 16) else 0),
|
|
3193
|
+
.grow = child.layout.grow,
|
|
3194
|
+
.main = authored_main,
|
|
3195
|
+
.cross = authored_cross,
|
|
3196
|
+
.offset_main = if (horizontal) child.frame.x else child.frame.y,
|
|
3197
|
+
.offset_cross = if (horizontal) child.frame.y else child.frame.x,
|
|
3198
|
+
.min_main = if (horizontal) child.layout.min_size.width else child.layout.min_size.height,
|
|
3199
|
+
.max_main = if (horizontal) child.layout.max_size.width else child.layout.max_size.height,
|
|
3200
|
+
.min_cross = if (horizontal) child.layout.min_size.height else child.layout.min_size.width,
|
|
3201
|
+
.max_cross = if (horizontal) child.layout.max_size.height else child.layout.max_size.width,
|
|
3202
|
+
.measured_main = if (authored_main > 0 or nonNegative(child.layout.grow) > 0) 0 else intrinsicMainExtent(child, axis, tokens),
|
|
3203
|
+
.measured_cross = if (!measure_cross or authored_cross > 0) 0 else intrinsicCrossExtent(child, axis, tokens),
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
|
|
2684
3207
|
fn intrinsicCrossExtent(widget: Widget, axis: LayoutAxis, tokens: DesignTokens) f32 {
|
|
2685
3208
|
const size = orientedIntrinsicWidgetSize(widget, tokens, axis);
|
|
2686
3209
|
return switch (axis) {
|
|
@@ -2708,6 +3231,7 @@ pub fn virtualWidgetScrollContentExtent(widget: Widget, viewport_extent: f32) f3
|
|
|
2708
3231
|
}
|
|
2709
3232
|
|
|
2710
3233
|
pub fn virtualWidgetScrollContentExtentWithTokens(widget: Widget, viewport_extent: f32, tokens: DesignTokens) f32 {
|
|
3234
|
+
if (tokens.intrinsic_layout_policy != null) return compiledVirtualContentExtent(widget, viewport_extent, tokens);
|
|
2711
3235
|
// A variable-extent windowed virtual list DECLARES its content
|
|
2712
3236
|
// extent: the window's offset table already summed estimates plus
|
|
2713
3237
|
// measured corrections plus gaps, and stamping it here is what
|
|
@@ -2736,6 +3260,27 @@ pub fn virtualWidgetScrollContentExtentWithTokens(widget: Widget, viewport_exten
|
|
|
2736
3260
|
}).content_extent;
|
|
2737
3261
|
}
|
|
2738
3262
|
|
|
3263
|
+
fn compiledVirtualContentExtent(widget: Widget, viewport: f32, tokens: DesignTokens) f32 {
|
|
3264
|
+
const flow_count = widgetFlowChildCount(widget.children);
|
|
3265
|
+
const policy = tokens.intrinsic_layout_policy.?;
|
|
3266
|
+
const grid = if (widget.kind == .grid and flow_count > 0 and widget.layout.virtual_item_count == 0) @import("grid_layout_policy.zig").plan(policy, flow_count, widget.layout.columns, 0, .{}, 0, 0, 0, 0, false) else null;
|
|
3267
|
+
var scratch = std.heap.stackFallback(4096, std.heap.page_allocator);
|
|
3268
|
+
const plan = @import("virtual_flow_policy.zig").Plan.init(scratch.get(), policy, widget.children.len, .{ .content = .init(0, 0, 0, viewport), .first = widget.layout.virtual_first_index, .declared = widget.layout.virtual_item_count, .grid_rows = if (grid) |value| value.rows else 0, .grid = widget.kind == .grid, .semantic = widget.semantics.list_item_count orelse 0, .flow_count = flow_count, .gap = widget.layout.gap, .item_extent = widget.layout.virtual_item_extent, .scroll_y = widget.value, .total_extent = widget.layout.virtual_total_extent }) catch @panic("virtual content allocation failed");
|
|
3269
|
+
defer plan.deinit();
|
|
3270
|
+
for (widget.children, 0..) |child, index| if (widgetTakesFlowSlot(child)) {
|
|
3271
|
+
plan.setChild(index, child, 0);
|
|
3272
|
+
};
|
|
3273
|
+
plan.run(1);
|
|
3274
|
+
if (plan.mode() != 2 and !(widget.layout.virtual_item_extent > 0)) {
|
|
3275
|
+
if (widget.kind == .grid and flow_count > 0) {
|
|
3276
|
+
const columns = if (grid) |value| value.columns else @import("grid_layout_policy.zig").plan(policy, flow_count, widget.layout.columns, 0, .{}, 0, 0, 0, 0, false).columns;
|
|
3277
|
+
plan.setExtent(preferredGridRowExtent(widget.children, columns, tokens));
|
|
3278
|
+
} else if (firstWidgetFlowChild(widget.children)) |child| plan.setExtent(preferredMainExtent(child, .vertical, tokens));
|
|
3279
|
+
}
|
|
3280
|
+
plan.run(1);
|
|
3281
|
+
return plan.contentExtent();
|
|
3282
|
+
}
|
|
3283
|
+
|
|
2739
3284
|
fn virtualWidgetScrollItemCount(widget: Widget) usize {
|
|
2740
3285
|
// A windowed virtual list's extent comes from its DECLARED count:
|
|
2741
3286
|
// children hold only the built window, so counting them would
|