-
Notifications
You must be signed in to change notification settings - Fork 25
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
FlexPanel enhancements (grow, shrink, basis, fixes) #45
Conversation
…ly implementation without remeasuring).
@dotnet-policy-service agree |
Added support for
Known issues:
|
It looks like |
Yes, Min/Max constraints are used on the visual element directly, and parent Panel can't really redefine this behavior. It only can read this property and add side effects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I feel like this PR is already good enough, and other problems with flex-basis and min/max can be addressed later. Or at least flex-basis.
In general, I feel like unit tests would be a great addition to this PR as well, as flex panel lacks them, but let's merge it as it is.
Browsers contain tons of flexbox tests. This seems to be the source (of some of them?): I think it should be possible to convert the relevant subset of these tests to C#... |
Several enhancements to
FlexPanel
:Fixed implementation of
justify-content
andalign-content
to follow the correct spacing calculation like in HTML. The original implementation was off in case of non-zero row and column gaps. Frankly, all variations looks kinda messy, but one is at least the standardized mess.Fixed implementation of
align-content
in case of items overflowing out of available panel size. In HTML, it falls back to three basic cases.Implemented
flex-shrink
andflex-grow
. It's a very basic implementation which performs all calculations in the arrange stage. It covers the basic case of stretching items in wrap and no-wrap modes, as well as shrinking in no-wrap mode.Proper flexbox implementation with fully functional
flex-grow
andflex-shrink
would require support forflex-basis
, much more sophisticated measure stage to handle min/max width/height constraints, resizing across main axis affecting cross axis and stuff like this. I don't understand HTML's and Avalonia's layout systems enough to properly match everything, so only basic implementation is included.Maybe I'll implement
flex-basis
later. Using it as percent/absolute main axis constraint at the measure stage sounds potentially useful (?).If anybody is curious, here's the official specification of the flex layout algorithm.
P.S. Is there any reason to use
RowSpacing
andColumnSpacing
property names instead ofRowGap
andColumnGap
? This seems to be the only mismatch with HTML flexbox naming. [EDIT] I see, there'sSpacing
inStackPanel
.