-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add CSS Grid support to bevy_ui
#8026
Conversation
bevy_ui
Example added: |
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
1 similar comment
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
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.
Just took a quick look at the docs for now. Hope to look closer and play with this later.
@rparrett The docs needs a full once-over by the way. I haven't paid any attention to docs yet. All the new types need docs, and quite a few of the existing style properties need updates to reflect how they work with CSS Grid. |
The text wrapping isn't working properly, but I don't think that's grid specific. And I suspect it will be fixed by #7779 |
Looks great. Having the default variants instead of optional fields is a really good compromise. |
@ickshonpe Scaling implemented :) |
I really like the |
@ickshonpe I see you have repeated track definitions in your test example. I've added support for grid_template_columns: vec![GridTrack::px(100.).repeat(alignments.len())]
grid_template_rows: vec![GridTrack::auto()), GridTrack::px(80.)).repeat(justifications.len())] instead of grid_template_columns: iter::repeat(GridTrack::px(100.))
.take(alignments.len())
.collect(),
grid_template_rows: iter::once(GridTrack::auto())
.chain(iter::repeat(GridTrack::px(80.)).take(justifications.len()))
.collect(), You can also use GridPlacement {
start: Some(4),
span: 1,
} |
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.
From what I can tell, this the implementation looks good and correct. Comments and documentation is what needs some improvements before this is released, but that could also be done in follow up PRs.
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.
The doc comment on NodeBundle::style
wasn't updated with its siblings.
Once that's done, the rest has my approval and I'll merge :)
@alice-i-cecile Doc comment updated (also resolved conflicts with #7779) |
Could you add the rename from |
Done for you :) |
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
Objective
An easy way to create 2D grid layouts
Solution
Enable the
grid
feature in Taffy and add new style types for defining grids.Notes
I'm having a bit of trouble gettingThis is now fixed#[derive(Reflect)]
to work properly. Help with that would be appreciated (EDIT: got it to compile by ignoring the problematic fields, but this presumably can't be merged).The alignment types now have aI've decided to stick with the flattened variant, as it saves a level of wrapping when authoring styles. But I've renamed the variants fromNormal
variant because I couldn't get reflect to work withOption
.Normal
toDefault
.This currently exposes a simplified API on top of grid. In particular the following is not currently supported:Negative grid indicesNow supported.CustomNow supportedend
values for grid placement (you can only usestart
andspan
)minmax is now support through aminmax()
track sizing functionsGridTrack::minmax()
constructorrepeat is now implemented asrepeat()
RepeatedGridTrack
Documentation still needs to be improved.An initial pass over the documentation has been completed.Screenshot
Changelog
bevy_ui
UiSystem::Flex
system set toUiSystem::Layout
Migration guide
-The
UiSystem::Flex
system set has been renamed toUiSystem::Layout