Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement grid flex layout #191

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

avsaase
Copy link
Contributor

@avsaase avsaase commented Oct 20, 2023

This PR implements a new version of the grid widget I added in #190.

This version has two major improvements over the previous implementation:

  • It support taking up more space than the minimum to fit the contents with width() and height() methods, similar to the built-in row, column and container widgets.
  • Has options to control how column widths and row heights are allocated when the grid is stretched.

The algorithm to allocate space to the rows and columns when the flexible size is enabled is somewhat complex because I wanted the relative columns widths/row heights to be dependent on the relevant fill factors of the length settings. When there's not enough overall space to achieve this ration it's "taken away" first from the columns/rows that have space left given their contents. It's a little hard to describe but the updated example makes it clear.

I added itertools as a dependency because it adds some methods on iterators that made implementing much more concise and probably more performant.

Copy link
Collaborator

@genusistimelord genusistimelord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@genusistimelord genusistimelord merged commit 38b15f4 into iced-rs:main Oct 20, 2023
2 checks passed
@avsaase avsaase deleted the feat/grid-flex-layout branch October 20, 2023 19:08
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