-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Migrate UI bundles to required components #15889
Comments
Ah I'm stupid I was worried this was going to be terrible but I hadn't realised required components were transitive until now 😅 I think though that |
I think most of Style's fields should be migrated to Node, the rest should be moved elsewhere, and Style should be removed. So in a way, I agree. |
Do you want to do that now, or wait for 0.16? I firmly agree about the ultimate action though. |
Do you mean that I'd prefer it if we had more granular UI components anyway. |
I also prefer more granular UI components, i.e., keeping |
I think we should do the conservative port as outlined in the hackmd and do more involved changes in a later release.
I think Node should be the "driving" public facing interface containing all of the "styleable" properties inherent to a UI node. For computed values (such as calculated_size), we should move those to one or more separate components. There should be no more generic Style component. You "style" fields on specific components, you don't set Style. |
That sounds good. I've never liked how we keep the relatively non-distinct geometric layout constraints in a component called It still bothers me though that the ouput component containing the computed layout is going to be the primary defining component, even if it's only intended to be temporary it doesn't feel very pleasant. Couldn't we do a renaming with |
I'd really try to reduce breaking changes for right now: this migration is already going to be really painful. |
If we don't want breaking changes then commands
.spawn((
Node::default(),
Style {
width: Val::Percent(100.),
height: Val::Percent(100.),
..default()
}
)) which seems obviously wrong to me. I realise this really is not all that important though and it will be fixed in 0.16. I'll leave this alone now and go and fix some bugs. |
Last thing, we could put require on both |
It's frustrating to see numerous instances of @ickshonpe Are you proposing that we make I suggest we either make no changes beyond the required component migration, or implement a comprehensive overhaul. A middle ground approach might lead to unnecessary complexity. |
I don't think it makes the transition any more awkward or unituitive. It isn't
to
I guess? Or maybe we'll have bsn in by then, I'm not sure about the timeline. |
@ickshonpe You're right. I totally agree with you. I will update the PR. Thanks! |
# Objective - Migrate UI bundles to required components, fixes #15889 ## Solution - deprecate `NodeBundle` in favor of `Node` - deprecate `ImageBundle` in favor of `UiImage` - deprecate `ButtonBundle` in favor of `Button` ## Testing CI. ## Migration Guide - Replace all uses of `NodeBundle` with `Node`. e.g. ```diff commands - .spawn(NodeBundle { - style: Style { + .spawn(( + Node::default(), + Style { width: Val::Percent(100.), align_items: AlignItems::Center, justify_content: JustifyContent::Center, ..default() }, - ..default() - }) + )) ``` - Replace all uses of `ButtonBundle` with `Button`. e.g. ```diff .spawn(( - ButtonBundle { - style: Style { - width: Val::Px(w), - height: Val::Px(h), - // horizontally center child text - justify_content: JustifyContent::Center, - // vertically center child text - align_items: AlignItems::Center, - margin: UiRect::all(Val::Px(20.0)), - ..default() - }, - image: image.clone().into(), + Button, + Style { + width: Val::Px(w), + height: Val::Px(h), + // horizontally center child text + justify_content: JustifyContent::Center, + // vertically center child text + align_items: AlignItems::Center, + margin: UiRect::all(Val::Px(20.0)), ..default() }, + UiImage::from(image.clone()), ImageScaleMode::Sliced(slicer.clone()), )) ``` - Replace all uses of `ImageBundle` with `UiImage`. e.g. ```diff - commands.spawn(ImageBundle { - image: UiImage { + commands.spawn(( + UiImage { texture: metering_mask, ..default() }, - style: Style { + Style { width: Val::Percent(100.0), height: Val::Percent(100.0), ..default() }, - ..default() - }); + )); ``` --------- Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Almost all of our bundle types have been migrated to required components after #14791. However, UI bundles have not been done yet.
#15550 will conflict with that, but since that PR needs more time to bake, we should press on with this work for the 0.15 release.
The strategy to do so is laid out here: https://hackmd.io/@bevy/required_components/%2FpuAA8c18TzeMhjclo36vEQ#Combined-Proposal-1-Conservative-Port-no-major-reworks-Selected
The text was updated successfully, but these errors were encountered: