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. |
rparrett
left a comment
There was a problem hiding this comment.
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,
} |
Weibye
left a comment
There was a problem hiding this comment.
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.
alice-i-cecile
left a comment
There was a problem hiding this comment.
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
gridfeature 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 fromNormalvariant because I couldn't get reflect to work withOption.NormaltoDefault.This currently exposes a simplified API on top of grid. In particular the following is not currently supported:Negative grid indicesNow supported.CustomNow supportedendvalues for grid placement (you can only usestartandspan)minmax is now support through aminmax()track sizing functionsGridTrack::minmax()constructorrepeat is now implemented asrepeat()RepeatedGridTrackDocumentation still needs to be improved.An initial pass over the documentation has been completed.Screenshot
Changelog
bevy_uiUiSystem::Flexsystem set toUiSystem::LayoutMigration guide
-The
UiSystem::Flexsystem set has been renamed toUiSystem::Layout