Repository navigation
feat(visual): center layout visuals that have no transform - #388
Merged
Merged
Conversation
A layout visual, with an inline layout or a layout resource, no longer needs a transform. Without transformId or transform it is centered on the screen at scale 1, like a background, so a screen-sized layout covers the screen and its elements keep the positions they were authored at. Top-level transform fields still override that placement. Image, video, spritesheet, particle and text visuals still need a transform. An inline layout may now carry a `source` field, which the engine keeps in the presentation state and never draws, so an authoring tool can map what is presented back to the form it edits. Bumps the version to 1.52.0.
…s of a centered layout visual
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.
Problem
A layout visual, whether it has an inline
layoutor aresourceIdthat names a layout resource, throwsVisual item "…" requires transformId or transformwhen it has no transform.An authoring tool that edits a visual as a full screen layout has no transform to give it: the layout's elements are already placed on the screen. Requiring a predefined or inline transform for that case forces the tool to invent one, and a predefined transform made for character sprites (for example a bottom-left anchor) moves the whole layout off the screen.
Fix
transformIdortransformis centered on the screen at scale 1, like a background: its container is drawn at the screen's center with anchor0.5, 0.5. The container is the size of the screen unless the layout setswidthandheight, so a screen-sized layout covers the screen and each element keeps the position it was authored at. A scale or rotation turns the layout around the screen's center.sourcefield. The engine keeps it in the presentation state and never draws it, so an authoring tool can map what is presented back to the form it edits. The schema anddocs/RouteEngine.mddocument it.No existing project data changes behaviour: a layout visual without a transform could not render before.
Tests
spec/visualInlineLayout.test.js: an inline layout and a layout resource without a transform are centered on the screen and keep their elements' positions; on a 1280×720 screen the center is 640, 360; a layout with its ownwidthandheightis centered at that size; top-levelx,anchorX,scaleXandrotationoverride the centered placement; a later line that changes only the opacity keeps the layout centered; a layout resource with a transform is placed by it; a resource visual without a transform still throws; a layout'ssourcestays in the presentation state and is not drawn.spec/system/renderState/addVisuals.spec.yaml: the render state of an inline layout without a transform.bun run test(2602 tests),bun run lint,bun run format:changedandbun run buildpass.