Skip to content

Conversation

@Aaronontheweb
Copy link
Owner

Summary

  • Changes VerticalLayout and HorizontalLayout default constraints from Fill() to Auto() for both height and width
  • Keeps StackLayout as Fill() since overlays should fill by default
  • Updates documentation to clarify when Fill() is actually needed

Breaking Change

This is a breaking change for users who rely on implicit Fill() behavior for nested layouts. Previously, nested layouts would compete with siblings for space. Now they size to their content by default.

Migration: Add .Fill() explicitly where expansion is desired. Note that root layouts (returned from BuildLayout()) always receive full terminal bounds regardless of constraints, so no changes needed there.

Why This Change

The previous Fill() default caused unexpected behavior when nesting layouts. An inner layout with implicit Fill() would compete with siblings for space rather than sizing to its content. The documentation already worked around this by always calling .Fill() explicitly - this change makes the default match the documented patterns.

Changes

  • src/Termina/Layout/VerticalLayout.cs - Default to Auto()
  • src/Termina/Layout/HorizontalLayout.cs - Default to Auto()
  • docs/layout/vertical-horizontal.md - Updated default behavior section
  • docs/layout/size-constraints.md - Clarified when Fill() is needed
  • docs/layout/nesting.md - Removed redundant Fill() from examples

Test plan

  • All 673 unit tests pass
  • All 3 demo projects build successfully
  • Visual verification of demos (optional - existing Fill() calls on child elements still work correctly)

Fixes #95

BREAKING CHANGE: VerticalLayout and HorizontalLayout now default to
Auto() sizing for both height and width constraints.

Previously, these layouts defaulted to Fill(), which caused nested
layouts to compete with siblings for space. This led to unexpected
behavior when composing layouts.

The new Auto() default means:
- Nested layouts size to their content by default
- No need for explicit Fill() on root layouts (rendering always uses
  full terminal bounds regardless of constraints)
- Fill() is now only needed for children that should claim remaining
  space within a container

StackLayout retains Fill() as its default since overlays should fill.

Updated documentation to:
- Remove redundant Fill() calls from root layout examples
- Add info box explaining root layouts always fill terminal
- Clarify when Fill() is actually needed (spacers, content areas)
- Add ASCII diagrams showing Fill() use cases

Fixes #95
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) December 18, 2025 02:33
@Aaronontheweb Aaronontheweb merged commit 0ca69cf into dev Dec 18, 2025
7 checks passed
@Aaronontheweb Aaronontheweb deleted the feature/issue-95-layout-auto-default branch December 18, 2025 02:36
@Aaronontheweb Aaronontheweb mentioned this pull request Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider changing VerticalLayout default height constraint from Fill() to Auto()

2 participants