bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Size Constraints Example

Open ickshonpe opened this issue 2 years ago • 1 comments

Objective

Add a simple example demonstrating how to use size constraints.

Related to #7946

Solution

Capture

Changelog

  • Added the example size_constraints

ickshonpe avatar Mar 07 '23 20:03 ickshonpe

Just spent ten minutes trying to fix why the min_size and max_size constraints didn't work. That's because of #7946 which was the reason for making the example in the first place :sweat_smile:.

Still needs a bit work on the presentation and some explanatory text, it'll wait till #7948 is merged.

ickshonpe avatar Mar 07 '23 20:03 ickshonpe

It might be a good idea to give the node a non-zero content size to illustrate the difference between min_size: auto and min_size: 0. Then again, maybe that overcomplicates things. This does seem useful as it is.

nicoburns avatar Mar 23 '23 13:03 nicoburns

It might be a good idea to give the node a non-zero content size to illustrate the difference between min_size: auto and min_size: 0. Then again, maybe that overcomplicates things. This does seem useful as it is.

Yeah, material for a separate example I think

ickshonpe avatar Mar 24 '23 00:03 ickshonpe

The flex-basis property seems to have no effect here. If that's expected, I think we should probably just cut it from this example (and add another one to demonstrate this).

alice-i-cecile avatar Apr 21 '23 15:04 alice-i-cecile

The flex-basis property seems to have no effect here. If that's expected, I think we should probably just cut it from this example (and add another one to demonstrate this).

Flex basis would have an effect if there were two child nodes (where it could be controlled separately). Which might make for a better example? Otherwise I agree that flex-basis probably ought to be removed.

nicoburns avatar Apr 21 '23 15:04 nicoburns

The flex-basis property seems to have no effect here. If that's expected, I think we should probably just cut it from this example (and add another one to demonstrate this).

That's odd, flex_basis is working for me. If you look at the screenshot at the top of the page, the bar is set to 75% using the flex-basis property. Does it not respond even with everything else set to Auto?

ickshonpe avatar Apr 21 '23 20:04 ickshonpe

flex_basis is working for me as well.

@alice-i-cecile, you could try running cargo update to make sure you're on the latest taffy patch.

tim-blackbird avatar Apr 21 '23 20:04 tim-blackbird

Ah, I didn't actually try it. I was just mentally simulating it. But I'd hallucinated a flex-grow: 1 in my mental model.

nicoburns avatar Apr 21 '23 20:04 nicoburns

Working correctly now! I had to change only flex_basis while leaving other values to auto to see an effect :)

alice-i-cecile avatar Apr 22 '23 00:04 alice-i-cecile