feat(api): RowBuilder.verticalAlign(...) — cross-axis row child alignment#239
Merged
Conversation
…ment
A row sizes its band to the tallest child, but shorter children always sat
flush with the band top; aligning a small label beside a large price, or an
icon with a line of text, meant computing offsets by hand.
verticalAlign(RowVerticalAlign.{TOP, CENTER, BOTTOM}) seats a row's children
on the cross axis within the band — the align-items analogue for a horizontal
row. The default is TOP, and the measure phase is untouched, so an existing
row computes the same band height and places its children byte-for-byte as
before; only CENTER/BOTTOM shift a child, by the band slack (accounting for
the child's own margin). Applies to both leaf and container children.
BASELINE is intentionally omitted for now — first-line ascent is not carried
through the measure result, so it cannot be honoured without a measure-layer
change; the enum admits it additively later.
Tests: RowVerticalAlignTest seats a short child beside a 60pt-tall one and
asserts its bottom lands 40 / 20 / 0 pt above the tall child's for TOP /
CENTER / BOTTOM, covers a container child at CENTER and a child whose own
bottom margin offsets BOTTOM, and confirms the default and the back-compat
RowNode constructor resolve to TOP. Example: RowVerticalAlignExample (a price
row at all three alignments). Full suite green, no visual baselines changed.
The cross-axis offset subtracts the child margin from the band slack; add a comment that the measure phase guarantees that slack stays non-negative (the band is the tallest child's margin-box), so the offset never lifts a child above the band top.
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.
Why
A row sizes its band to the tallest child, but shorter children always sat flush with the band top. Aligning a small
/monthlabel beside a large price, or an icon with a line of text, meant computing vertical offsets by hand.What changed
RowBuilder.verticalAlign(RowVerticalAlign.{TOP, CENTER, BOTTOM})— seats a row's children on the cross axis within the band (height = tallest child). Thealign-itemsanalogue for a horizontal row, no manual coordinates. Applies to both leaf and container children.TOPis the default and the measure phase is untouched — an existing row computes the same band height and places its children byte-for-byte as before. OnlyCENTER/BOTTOMshift a child, by the band slack (accounting for the child's own margin). The seating computes a0.0offset forTOP, so the placement expression is bit-identical to the pre-feature code.BASELINEis intentionally omitted — first-line ascent is not carried throughMeasureResult, so it cannot be honoured without a measure-layer change. The enum admits it additively later.This is the cross-axis half of the row-layout work; flex-spacer + main-axis arrangement (
pushRight,SPACE_BETWEEN, …) is a separate follow-up that touches the width-distribution lockstep.Lane: canonical DSL (
RowBuilder,RowVerticalAlign,RowNode) + a 2-line shared-engine seating change. Purely additive → japicmp-safe (the newRowNodecomponent is gated behind re-declared back-compat delegating constructors).Verification
./mvnw test -pl .— green, 0 changed visual baselines → existing (TOP) rows render identically../mvnw -P japicmp verify— binary-compatible.RowVerticalAlignTest(7): a short child beside a 60pt-tall one lands 40 / 20 / 0 pt above the tall child's bottom forTOP / CENTER / BOTTOM; a container child seats atCENTER; a child's own bottom margin offsetsBOTTOM; the default and the back-compatRowNodeconstructor resolve toTOP.TOPbyte-identity (including the-0.0edge), the offset math incl. margins, and the delegating-ctor chain; it drove the composite-child + margined-child tests.RowVerticalAlignExample+ committed preview: a$49 / monthrow at all three alignments.