Skip to content

Fix excessive line spacing in GroupBox popout layouts - #26

Merged
emosaru merged 2 commits into
avaloniafrom
fix/issue-10-groupbox-line-spacing
Apr 11, 2026
Merged

Fix excessive line spacing in GroupBox popout layouts#26
emosaru merged 2 commits into
avaloniafrom
fix/issue-10-groupbox-line-spacing

Conversation

@emosaru

@emosaru emosaru commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Line spacing issue #10
  • GroupBox ItemsPanel: <Grid /><StackPanel Orientation="Vertical" /> — with StretchItemContainer, a plain Grid stretches each ContentPresenter to the full Grid height, producing huge gaps between items
  • Set FontSize="12" on LayoutControl — Avalonia Fluent theme defaults to 14px; WPF inherits Windows system font (~12px). Pack designers built for WPF so Avalonia's larger default inflates row heights
  • Set ClipToBounds="False" on ItemsControl and LayoutTransformControl — WPF does not clip by default; pack makers use negative margins to overflow elements outside their containers
  • Fix ArrayPanel orientation binding — RelativeSource AncestorType=ItemsControl silently fails in Avalonia's ItemsPanelTemplate (panel not in visual tree yet), causing all arrays to default to Vertical orientation; fixed by binding directly to the inherited DataContext

Known remaining issue

Settings popup rows still show slightly more vertical spacing than the WPF version. Root cause not yet identified. Tracked in the PR comment below.

Test plan

  • Open a pack that uses GroupBox popout layouts — verify items stack normally
  • Open settings popup (gear icon) — verify rows are reasonably compact
  • Verify horizontal array panels render horizontally (not all collapsed to vertical)
  • Verify elements that use negative margins are not clipped

🤖 Generated with Claude Code

@emosaru
emosaru requested a review from a team April 11, 2026 19:20
@emosaru

emosaru commented Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

Testing Notes (2026-04-11)

Partial fix applied + additional fixes needed

During testing with alttpr_codetracker_codemann8 pack (-dev), the GroupBox StackPanel change alone did not fully resolve the spacing issue. Two additional fixes were applied and are included in the working branch:

Additional fixes in this branch (uncommitted)

  1. FontSize="12" on LayoutControl UserControl

    • Avalonia's Fluent theme defaults to 14px; WPF inherits the Windows system font (~12px / Segoe UI 9pt at 96 DPI)
    • Pack designers built for WPF, so the extra 2px per row (amplified by the 1.75x outer scale in the settings popup) added visible spacing
    • Note: independently confirmed by @codemann8
  2. ClipToBounds="False" on ItemsControl and LayoutTransformControl

    • WPF containers do not clip children by default; Avalonia's LayoutTransformControl sets ClipToBounds=True
    • Pack makers use negative margins to intentionally position elements outside their containing box (e.g. close buttons, overlapping badges)
    • Note: also from codemann8's commit above

Remaining issue

Even with all three fixes applied, the settings popup still shows extra vertical spacing between rows compared to the WPF version:

![Settings popup with remaining spacing issue](screenshot above)

The spacing is most visible in the vertical shared_v_settings layout, where each horizontal row (scale: 0.75, margin: "0,0,0,1") appears taller than expected. Root cause is not yet identified — likely a subtle difference in how Avalonia's LayoutTransformControl measures scaled items inside a vertical StackPanel vs. WPF's inline LayoutTransform property.

What's been ruled out

  • Font size (fixed with FontSize="12")
  • ClipToBounds clipping (fixed above)
  • Orientation binding (RelativeSource → direct binding, also in this branch)
  • ContentPresenter Stretch alignment (StretchItemContainer is correct)
  • LayoutTransformControl adding extra padding (none — it inherits from Decorator with Padding=0)

This PR should be merged with the current fixes; the remaining spacing refinement can be tracked as a follow-up issue.

EmoSaru and others added 2 commits April 11, 2026 15:50
GroupBox used a plain Grid as its ItemsPanel, which places all items
in cell (0,0). In Avalonia, StretchItemContainer stretches each item's
ContentPresenter to fill the entire Grid height, producing huge gaps
between items. Change to a vertical StackPanel so items stack normally.

Fixes #10

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…inding

- Set FontSize="12" on LayoutControl to match WPF's Windows system font
  default (Segoe UI 9pt at 96 DPI); Avalonia Fluent theme defaults to 14px
  which makes pack content larger than pack designers intended
- Set ClipToBounds="False" on ItemsControl and LayoutTransformControl to
  match WPF's default non-clipping behavior; pack makers use negative margins
  to intentionally overflow elements outside their containers
- Fix ArrayPanel StackPanel orientation binding from unreliable RelativeSource
  (silently fails in Avalonia's ItemsPanelTemplate, always defaulting to
  Vertical) to direct DataContext binding which works correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@emosaru
emosaru force-pushed the fix/issue-10-groupbox-line-spacing branch from 958fbc9 to 809cdb9 Compare April 11, 2026 22:50
@emosaru
emosaru merged commit e7f9c8b into avalonia Apr 11, 2026
3 checks passed
@emosaru
emosaru deleted the fix/issue-10-groupbox-line-spacing branch April 11, 2026 22:53
@emosaru emosaru mentioned this pull request Apr 12, 2026
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