Skip to content

Fix container overlay items displaying outside bounds - #30

Merged
emosaru merged 1 commit into
avaloniafrom
fix/issue-12-clip-to-bounds
Apr 11, 2026
Merged

Fix container overlay items displaying outside bounds#30
emosaru merged 1 commit into
avaloniafrom
fix/issue-12-clip-to-bounds

Conversation

@emosaru

@emosaru emosaru commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Some container overlay displaying is off #12
  • Avalonia sets ClipToBounds=true by default on most layout containers, unlike WPF which leaves it false. Pack makers rely on negative margins and overflow rendering (overlay items positioned outside their container bounds) which are silently clipped in Avalonia.
  • Adds global Application.Styles setting ClipToBounds=False on all common layout container types: Grid, StackPanel, Panel, WrapPanel, DockPanel, ItemsControl, ContentControl, ContentPresenter, Border, Decorator, Viewbox, ScrollContentPresenter, ItemsPresenter.
  • LayoutTransformControl overrides ClipToBounds in its static constructor so it can't be beaten by Application.Styles; a UserControl-scoped style is added to LayoutControl to win via style proximity.
  • Explicitly sets ClipToBounds=False on ItemGridControl inner elements for belt-and-suspenders coverage.
  • Adds HorizontalAlignment/VerticalAlignment=Stretch to the Button in TrackableItemControl so it fills its grid cell correctly.

Test plan

  • Load CodeTracker, switch Alternate Layout to 2 in Settings Tab
  • Verify overlay items display in the correct position over the item grid
  • Open the Doors Tab, select a dungeon, click 4 rooms — verify ? icons appear correctly over doors
  • Verify no visual regression in other layout types or map displays

🤖 Generated with Claude Code

@emosaru
emosaru requested a review from a team April 11, 2026 19:40
Fixes #12.

Avalonia sets ClipToBounds=true by default on most layout containers,
unlike WPF which leaves it false. Pack makers rely on negative margins
and overflow rendering (e.g. overlay items positioned outside their
container bounds). This causes items with negative margins or
out-of-bounds placement to be silently clipped instead of drawn.

Fix: add global Application-level styles setting ClipToBounds=False on
all common layout container types (Grid, StackPanel, Panel, WrapPanel,
DockPanel, ItemsControl, ContentControl, ContentPresenter, Border,
Decorator, Viewbox, ScrollContentPresenter, ItemsPresenter).
LayoutTransformControl overrides ClipToBounds in its static constructor
so a UserControl-scoped style is added to LayoutControl to win via
style proximity.

Also explicitly set ClipToBounds=False on ItemGridControl's inner
elements, and add HorizontalAlignment/VerticalAlignment=Stretch to the
Button in TrackableItemControl so it fills its grid cell correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@emosaru
emosaru force-pushed the fix/issue-12-clip-to-bounds branch from 5d5567a to 229cd4f Compare April 11, 2026 22:48
@emosaru
emosaru merged commit 245a08f into avalonia Apr 11, 2026
@emosaru
emosaru deleted the fix/issue-12-clip-to-bounds branch April 11, 2026 22:48
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.

1 participant