Skip to content

GridWrap: Add StretchItems option to fill available width#6100

Open
alexballas wants to merge 3 commits into
fyne-io:developfrom
alexballas:feature/add_support_for_grid_stretching
Open

GridWrap: Add StretchItems option to fill available width#6100
alexballas wants to merge 3 commits into
fyne-io:developfrom
alexballas:feature/add_support_for_grid_stretching

Conversation

@alexballas

Copy link
Copy Markdown
Contributor

Problem: Applications using GridWrap cannot stretch items to fill available width without causing scrollbar jitter during resize. The issue is that GridWrap uses CreateItem().MinSize() for both column count calculation and item sizing. When MinSize depends on viewport width (for stretching), a feedback loop occurs:

  1. Viewport width changes
  2. MinSize returns different stretched width
  3. Column count recalculates
  4. Content height changes
  5. Scrollbar toggles on/off
  6. Viewport width changes → goto 1

Proposed Solution: Add a StretchItems bool field that, when enabled, calculates stretched item widths in updateGrid() at layout time:

This keeps column count calculation stable (uses base itemMin) while still filling available width visually.

The StretchItems feature solves a fundamental limitation in GridWrap where stretching items to fill width and having stable scrollbars were mutually exclusive. By moving the stretch calculation to layout time, applications get both benefits without any trade-offs.

Comment thread widget/gridwrap.go Outdated
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.

2 participants