Replace BoxConstraints and update Layout function #701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request works towards implementing changes proposed in #37
It does so by replacing
BoxConstraints
with a generic type that has a vertical and horizontal component. The Layout function has theBoxConstraints
parameter replaced withavailable_space
andrequested_fill
.available_space
is like the Size type; it uses the new generic type withf64
as the type on the axes.requested_fill
takes the place of themin
size in BoxConstraints, and will have more future uses with Intrinsic sizing. When set toExact
, the widgets should behave the way they did when they previously got BoxConstraints with the min equaling the max. I did not find any instances where min wasn't set to either 0 by 0 or the max.I chose
BiAxial
for the name for the generic 2D type that is used for the layout parameters. I think it is descriptive while not colliding with the names of other types.Size
was proposed in #37, but it collided with the Size type in several libraries, including Kurbo. And for the uses that were proposed, includingrequested_fill
, I felt like a more generic name made sense. If the community doesn't like the name, I'm open to changing it.This code is ready for high-level review, including discussions on whether or not this is the way forward, as well as naming and file structure.
This design is a major step forward towards implementing Taffy integration.
The code still has at least one bug (like in the Flex example). I need to fix the linter errors, validate the tests, and fix the ordering of the code in the new files. But the examples should work mostly.