Repository navigation
[patch] Stretch StackPanel children across the cross axis so alignment applies - #195
Merged
Merged
Conversation
…pplies [patch] A StackPanel gave each child its measured size on both axes, so a child's box was exactly as wide (vertical) or tall (horizontal) as its content and HorizontalAlignment.Center/Right had no room to act. Children now span the panel on the cross axis and keep their measured size on the stacking axis, so stacking offsets are unchanged. Fixes #158 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015YFg3aG1od37a8RytUTWQy
|
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.



Fixes #158
What changed
StackPanel.OnArrangeChildrennow gives each child the panel's full content width in a vertical stack, and its full content height in a horizontal stack. On the stacking axis each child keeps its measured size, so the stacking offsets do not change. A centered or right-alignedTextElement, or aBorderElementheader in a vertical stack, now has room to align or span. Before, it was boxed to exactly its content width.Behaviour change to review
Two existing tests checked the old content-sized cross axis, so I updated them:
StackPanelVerticalMeasuresWidthIndependentElementsAtTheirOwnSizenow expects a width of10(the panel) rather than3for a fixed-size child. The measured height, and the next child's position, are still asserted unchanged.RenderAfterAResizeRelaysOutEveryContainerBeneathTheRoot: the precondition now expects the label to span the panel rather than sit at its text width. The post-resize assertion, which checks that the label is re-laid out to the narrower width, is unchanged.This PR adds no opt-out
Stretchproperty (triage listed it as optional). Any element that wants a content-sized box inside a stack now has to position itself with its own alignment.Tests
StackPanelVerticalChildAlignsWithinThePanelWidthcovers Left/Center/Right. It is the issue's minimal repro: "hi" in a 40-wide vertical stack is drawn at x=0, 19 and 38.StackPanelHorizontalChildSpansThePanelHeightchecks that the cross-axis height is stretched and that widths and offsets on the stacking axis are kept.Independent of #194 (#157). Both branch from
main.🤖 Generated with Claude Code
https://claude.ai/code/session_015YFg3aG1od37a8RytUTWQy
Generated by Claude Code