Repository navigation
Measure a container's children from its content origin - #176
Merged
Merged
Conversation
The default OnCalculateRequiredDimensionsForChildren measured each child's extent from screen column/row 0, so a custom container's required size included its own position and its padding, which OnCalculateRequiredDimensions then added again. A 5x3 container at (10,5) measured 16x9. Children are now measured relative to GetContentPosition(). Fixes #145 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCL6GX9wshgqiBeq6z98ZH
|
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 #145
What changed
UIContainerBase.OnCalculateRequiredDimensionsForChildrenmeasured each child aschild.Position + childDimensions. Child positions are absolute screen coordinates, so the container's own position and padding ended up in its required size.OnCalculateRequiredDimensionsthen added the padding a second time. The default measurement now works relative toGetContentPosition(), and padding is still added once.StackPanelandBorderElementoverride this method, so they aren't affected. The fix is for custom containers that rely on the default.Tests
New
UIContainerBaseMeasureTestsuses a minimal container that keeps the default measurement:Padding.Uniform(1)holdingTextElement("abc")measures 5×3. Before the fix it measured 16×9.Both tests failed before the fix. The full suite passes with it (211/211).
🤖 Generated with Claude Code
https://claude.ai/code/session_01VCL6GX9wshgqiBeq6z98ZH
Generated by Claude Code