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

feat(layout): allow layout fill to be configurable #633

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

joshka
Copy link
Member

@joshka joshka commented Nov 18, 2023

feat(layout): allow configuring layout fill

The layout split will generally fill the remaining area when split()
is called. This change allows the caller to configure how any extra
space is allocated to the Rects. This is useful for cases where the
caller wants to have a fixed size for one of the Rects, and have the
other Rects fill the remaining space.

For now, the method and enum are marked as unstable because the exact
name is still being bikeshedded. To enable this functionality, add the
unstable-segment-size feature flag in your Cargo.toml.

To configure the layout to fill the remaining space evenly, use
Layout::segment_size(SegmentSize::EvenDistribution). The default
behavior is SegmentSize::LastTakesRemainder, which gives the last
segment the remaining space. SegmentSize::None will disable this
behavior. See the docs for Layout::segment_size() and
layout::SegmentSize for more information.


Method docs:

image

Type docs:

image

Note: I fixed the link to the Table widget - just didn't re-screenshot.

Copy link

codecov bot commented Nov 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1f88da7) 90.4% compared to head (a22a9f1) 90.4%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #633   +/-   ##
=====================================
  Coverage   90.4%   90.4%           
=====================================
  Files         41      41           
  Lines      11907   11907           
=====================================
  Hits       10775   10775           
  Misses      1132    1132           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The layout split will generally fill the remaining area when `split()`
is called. This change allows the caller to configure how any extra
space is allocated to the `Rect`s. This is useful for cases where the
caller wants to have a fixed size for one of the `Rect`s, and have the
other `Rect`s fill the remaining space.

For now, the method and enum are marked as unstable because the exact
name is still being bikeshedded. To enable this functionality, add the
`unstable-segment-size` feature flag in your `Cargo.toml`.

To configure the layout to fill the remaining space evenly, use
`Layout::segment_size(SegmentSize::EvenDistribution)`. The default
behavior is `SegmentSize::LastTakesRemainder`, which gives the last
segment the remaining space. `SegmentSize::None` will disable this
behavior. See the docs for `Layout::segment_size()` and
`layout::SegmentSize` for more information.

Fixes #536
@joshka joshka force-pushed the segment-experimental branch from 430d420 to a22a9f1 Compare November 21, 2023 22:08
@joshka
Copy link
Member Author

joshka commented Nov 21, 2023

Updated commit message to work better in the changelog

@joshka joshka merged commit 753e246 into main Dec 2, 2023
39 checks passed
@joshka joshka deleted the segment-experimental branch December 2, 2023 20:21
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