-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Migrate 2d_shapes to use FeathersCheckbox
#25164
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
Open
tevans-3
wants to merge
4
commits into
bevyengine:main
Choose a base branch
from
tevans-3:25032_13_migrate_2d_shapes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+203
−30
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /// Helpers to create an option menu using Feathers Checkboxes. | ||
| /// Using these helpers requires the `bevy_feathers` feature to be enabled. | ||
| use bevy::{ | ||
| feathers::{controls::FeathersCheckbox, display::caption}, | ||
| picking::hover::Hovered, | ||
| prelude::*, | ||
| ui_widgets::checkbox_self_update, | ||
| }; | ||
|
|
||
| /// Creates a single feathers checkbox that allows configuration of a setting. | ||
| /// | ||
| /// Examples that use this to create a checkbox should handle its `ValueChange<bool>` events. | ||
| /// If there is a need to identify the checkbox that originated the value change, | ||
| /// query which `checkbox_identifier` with the `FeathersCheckbox` is the value change's | ||
| /// source entity. | ||
| pub fn feathers_option_checkbox<T>( | ||
| option_name: &str, | ||
| checkbox_identifier: Option<T>, | ||
| ) -> Box<dyn Scene> | ||
| where | ||
| T: Template<Output: Component> + Clone + Default + Send + Sync + Unpin + 'static, | ||
| { | ||
| if let Some(identifier) = checkbox_identifier { | ||
| Box::new(bsn! { | ||
| Node { | ||
| align_items: AlignItems::Center, | ||
| column_gap: px(5), | ||
| } | ||
| Children [ | ||
| @FeathersCheckbox { | ||
| @caption: bsn! { caption(option_name) } | ||
| } | ||
| Hovered::default() | ||
| template_value(identifier) | ||
| on(checkbox_self_update) | ||
| ] | ||
| }) | ||
| } else { | ||
| Box::new(bsn! { | ||
| Node { | ||
| align_items: AlignItems::Center, | ||
| column_gap: px(5), | ||
| } | ||
| Children [ | ||
| @FeathersCheckbox { | ||
| @caption: bsn! { caption(option_name) } | ||
| } | ||
| Hovered::default() | ||
| on(checkbox_self_update) | ||
| ] | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /// Helpers to create a [`Node`] appropriate for the outer main UI node as a `Scene`. | ||
| use bevy::prelude::*; | ||
|
|
||
| /// 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 bottom_left_scene() -> impl Scene { | ||
| bsn! { | ||
| Node { | ||
| flex_direction: FlexDirection::Column, | ||
| position_type: PositionType::Absolute, | ||
| row_gap: px(6), | ||
| left: px(10), | ||
| bottom: px(10), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Returns a [`Node`] appropriate for the outer main UI node as a `Scene`. | ||
| /// | ||
| /// This UI is in the top left corner and has flex column support | ||
| pub fn top_left_scene() -> impl Scene { | ||
| bsn! { | ||
| Node { | ||
| flex_direction: FlexDirection::Column, | ||
| position_type: PositionType::Absolute, | ||
| row_gap: px(6), | ||
| left: px(10), | ||
| top: px(10), | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
I think this can be simplified to just one
cfgcall within theCheckboxInput::Wireframematch itself for#[cfg(not(target_arch = "wasm32"))]i.e.
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.
Hmm that throws an error since the Wireframe2dConfig is removed at compile time by the #[cfg(...)] gate on
use bevy::sprite_renderand since the cfg macro doesn't remove any code at compile time (TIL) the compiler still requires wireframe_config to be defined somewhere