Add layout arrangement evaluation engine - #10
Merged
Conversation
FlowArrangement had only a single unconditional root tree - nowhere to represent Screenplay's when width/height <class> overrides, unlike FreeformArrangement which already keys its variants by size class. FlowOverride replaces the root for a targeted width and/or height size class; both dimensions are independently optional to match what Screenplay's when clause actually allows (width-only, height-only, or both).
SizeClassCalculator computes a SizeClass from actual available dimensions, shared by every renderer. FlowArrangementEvaluator selects the most specific matching override's tree (both dimensions targeted beats one; last declared wins among equally specific matches), falling back to the base root. FreeformArrangementEvaluator selects the variant with an exact size-class match, or nothing - deliberately no fallback, matching the language's own "warn, don't silently pick" design for an unmatched size class.
computeSizeClass/evaluateFlowArrangement/evaluateFreeformArrangement are the runtime twins of the C# evaluators, run whenever a screen renders and its available size may have changed.
layout-evaluation-fixtures.json is asserted independently by both Cratis.Scene.Engine.Specs (C#) and @cratis/scene.engine's own Vitest suite, covering flow override specificity/tie-breaking and freeform exact-match selection - the same pattern used for the package resolver in #3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
SizeClassCalculator.Compute()(C#) /computeSizeClass()(TypeScript) - computes the current width x height size class from actual available dimensions, shared by every renderer so they all agree on when a class boundary is crossed. (Layout engine:flowandfreeformarrangement rendering #4)FlowArrangementEvaluator.Evaluate()/evaluateFlowArrangement()- selects the most specific matchingwhen width/height <class>override's tree for the current size class (both dimensions targeted beats one; the last declared wins among equally specific matches), falling back to the base tree when nothing matches. (Layout engine:flowandfreeformarrangement rendering #4)FreeformArrangementEvaluator.Evaluate()/evaluateFreeformArrangement()- selects the placement variant with an exact size-class match, or nothing - deliberately no fallback, matching the language's own "warn, don't silently pick" design for a size class with no matching variant. (Layout engine:flowandfreeformarrangement rendering #4)FlowArrangementgained anOverrideslist (C#) /overrides(TypeScript) - the model previously had no field at all for Screenplay'swhen width/height <class>override construct, unlikeFreeformArrangementwhich was already keyed by size class.layout-evaluation-fixtures.json) asserted independently by both the C# and TypeScript specs, following the same pattern established for the package resolver inui profilepackage resolution engine #3/Add ui profile package resolution engine #9.Notes
Per Scene#8's original design (confirmed against its merged PR description),
Slot.Arrangementis per-slot, not per-layout - this evaluation engine works against that shape as-is and does not assume every slot in a layout shares one arrangement mode.