Migrate 2d_shapes to use FeathersCheckbox#25164
Migrate 2d_shapes to use FeathersCheckbox#25164tevans-3 wants to merge 3 commits intobevyengine:mainbevyengine/bevy:mainfrom tevans-3:25032_13_migrate_2d_shapestevans-3/bevy:25032_13_migrate_2d_shapesCopy head branch name to clipboard
2d_shapes to use FeathersCheckbox#25164Conversation
|
I just realized that this includes my clearcoat PR commits. 🤦♂️ I'll remove those, probably by submitting a new PR from a new branch. I'll do that after this has been reviewed, though, in case other changes need to be made. |
|
For testing on wasm, directions are available in the examples readme https://github.com/bevyengine/bevy/blob/main/examples%2FREADME.md under the wasm section |
| /// Returns a [`Node`] appropriate for the outer main UI node as a `Scene`. | ||
| /// | ||
| /// This UI is in the bottom left corner and has flex column support | ||
| pub fn main_ui_node_scene() -> impl Scene { |
There was a problem hiding this comment.
doesn’t have to be addressed now, but just a future note that if you happen to create an example that uses both this new checkbox helper and the radio helper, ci might complain that one of the main_ui_node_scene() helpers in either file isn’t used (since presumably you’d only be using one of them). you can cross that bridge when you get there (or you can do something about it now if you wish)
There was a problem hiding this comment.
I'll address this now! Would it be worth it do you think to extract main_ui_node_scene from radio.rs out into a separate scene.rs helper? We could have a few different canonical scene constructors with different screen positions (top_left, bottom_left, etc).
There was a problem hiding this comment.
A separate helper file makes sense yeah! And you can rename the function to bottom_left_scene() or something if youd like. I like your idea about specifying the potential different positions for potential control settings, but you can just stick to extracting out the single shared one for now -- dont need to overengineer it at this point
There was a problem hiding this comment.
Okay cool. I added that. I did add a top_left_scene as well, only because I wanted to use it in this particular example for wasm builds. I think it's a better ux in browser to place the checkbox in the top left of the screen since then when the page loads it's immediately obvious what controls are available, whereas if placed in the bottom the user has to scroll down to see them.
I didn't touch the main_ui_node_scene function in radio.rs or any references to it. I can submit a separate PR updating those?
There was a problem hiding this comment.
sounds good for a separate PR, nice thinking :)
| )); | ||
| fn handle_value_change_checkbox( | ||
| event: On<ValueChange<bool>>, | ||
| mut wireframe_config: ResMut<Wireframe2dConfig>, |
There was a problem hiding this comment.
I tested in wasm and this breaks the example because this param is not available in that target_arch
I’d recommend you walk through testing in wasm yourself too just to see what happens / try out debugging
| } | ||
| #[cfg(target_arch = "wasm32")] | ||
| CheckboxInput::Wireframe => {} | ||
| #[cfg(not(target_arch = "wasm32"))] |
There was a problem hiding this comment.
I think this can be simplified to just one cfg call within the CheckboxInput::Wireframe match itself for #[cfg(not(target_arch = "wasm32"))]
i.e.
CheckboxInput::Wireframe => {
if !cfg!(target_arch = "wasm32") {
wireframe_config.global = !wireframe_config.global;
}
}There was a problem hiding this comment.
Hmm that throws an error since the Wireframe2dConfig is removed at compile time by the #[cfg(...)] gate on use bevy::sprite_render and since the cfg macro doesn't remove any code at compile time (TIL) the compiler still requires wireframe_config to be defined somewhere
kfc35
left a comment
There was a problem hiding this comment.
I have a couple last comments, and I assume you’ll be making the PR anew to get rid of the clearcoat commits? So I won’t put an approval, but just @ me in the appropriate PR to land my approval on
| @@ -13,30 +12,52 @@ | ||
| //! You can toggle wireframes with the space bar except on wasm. Wasm does not support |
There was a problem hiding this comment.
You’ll have to update this comment
There was a problem hiding this comment.
I tried rebasing and dropping those commits from this branch instead of PRing anew. @kfc35
3956f98 to
af24eb0
Compare
Objective
Solution
I added a feathers checkbox helper + some checkbox theming in themes.rs (following the examples of the existing helpers).
Testing
cargo run --example 2d_shapes --features="bevy_feathers"Showcase