Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Migrate 2d_shapes to use FeathersCheckbox#25164

Open
tevans-3 wants to merge 3 commits into
bevyengine:mainbevyengine/bevy:mainfrom
tevans-3:25032_13_migrate_2d_shapestevans-3/bevy:25032_13_migrate_2d_shapesCopy head branch name to clipboard
Open

Migrate 2d_shapes to use FeathersCheckbox#25164
tevans-3 wants to merge 3 commits into
bevyengine:mainbevyengine/bevy:mainfrom
tevans-3:25032_13_migrate_2d_shapestevans-3/bevy:25032_13_migrate_2d_shapesCopy head branch name to clipboard

Conversation

@tevans-3

Copy link
Copy Markdown
Contributor

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"
  • This code executes differently depending on the target architecture (because the wireframes need POLYGON_MODE_LINE, and that isn't available in wasm32, that feature's only enabled when the target architecture is not wasm32). I wasn't able to test this for a wasm32 target, only because I'm not sure how to do that. I can test it there too but could use some advice or pointers to resources.

Showcase

image

@tevans-3

Copy link
Copy Markdown
Contributor Author

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.

@kfc35 kfc35 added C-Examples An addition or correction to our examples A-UI Graphical user interfaces, styles, layouts, and widgets S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 26, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in UI Jul 26, 2026
@kfc35

kfc35 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

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

@kfc35
kfc35 self-requested a review July 26, 2026 13:16
Comment thread examples/helpers/checkbox.rs Outdated
/// 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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good for a separate PR, nice thinking :)

Comment thread examples/2d/2d_shapes.rs Outdated
Comment thread examples/2d/2d_shapes.rs Outdated
Comment thread examples/2d/2d_shapes.rs Outdated
Comment thread examples/2d/2d_shapes.rs Outdated
));
fn handle_value_change_checkbox(
event: On<ValueChange<bool>>,
mut wireframe_config: ResMut<Wireframe2dConfig>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@kfc35 kfc35 added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 26, 2026
Comment thread examples/2d/2d_shapes.rs
}
#[cfg(target_arch = "wasm32")]
CheckboxInput::Wireframe => {}
#[cfg(not(target_arch = "wasm32"))]

@kfc35 kfc35 Jul 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
                }
            }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 kfc35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread examples/2d/2d_shapes.rs Outdated
@@ -13,30 +12,52 @@
//! You can toggle wireframes with the space bar except on wasm. Wasm does not support

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’ll have to update this comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried rebasing and dropping those commits from this branch instead of PRing anew. @kfc35

@tevans-3
tevans-3 force-pushed the 25032_13_migrate_2d_shapes branch from 3956f98 to af24eb0 Compare July 27, 2026 01:30
@kfc35 kfc35 added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Jul 27, 2026
@kfc35 kfc35 added D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-UI Graphical user interfaces, styles, layouts, and widgets C-Examples An addition or correction to our examples D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.