Core button widget
Objective
Part of #19236
Solution
Adds a new bevy_core_widgets crate containing headless widget implementations. This PR adds a single CoreButton widget, more widgets to be added later once this is approved.
Testing
There's an example, ui/core_widgets.
The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.
From @cart on Discord.
Another thing thats come up with @DreamerTalin's core widget work (in addition to Marker Component Change Queries): we now have increased need for something like @doot's static multi-event-listening proposal: https://github.com/bevyengine/bevy/pull/14674
While the newer dynamic proposal is flexible, I think we will want the ease of use / directness of the static API, as these are likely to be defined "in context" next to widgets. Ex: currently this requires six different identical observers, which isn't defensible:
fn on_button_change( trigger: Trigger<( OnAdd<Pressed>, OnRemove<Pressed>, OnAdd<InteractionDisabled>, OnRemove<InteractionDisabled>, OnInsert<Hovered>, )>, mut buttons: Query< ( Has<Depressed>, &IsHovered, Has<InteractionDisabled>, &mut BackgroundColor, &mut BorderColor, &Children, ), With<DemoButton>, >, mut text_query: Query<&mut Text>, ) { if let Ok((pressed, hovered, disabled, mut color, mut border_color, children)) = buttons.get_mut(trigger.target()) { let mut text = text_query.get_mut(children[0]).unwrap(); set_button_style( disabled, hovered.get(), pressed, &mut color, &mut border_color, &mut text, ); } }Notice that I switched to Trigger<OnAdd<Pressed>> instead of Trigger<OnAdd, Pressed>, as the current interface only supports a single component-target, which doesn't lend itself to expressing multiple events
To effectively support things like the set_button_style scenario, I think we need need to land one or both of Multi-Event Observers and Marker Component Change Queries
I'd like to merge so we can iterate. I think worst case scenario we move it to an experimental module
@alice-i-cecile CI is broken, I don't get why. OnAdd is private?
Ah right, lifecycle migration.