diff --git a/_release-content/migration-guides/Core-Prefix-Removal.md b/_release-content/migration-guides/Core-Prefix-Removal.md new file mode 100644 index 0000000000..09b12331b1 --- /dev/null +++ b/_release-content/migration-guides/Core-Prefix-Removal.md @@ -0,0 +1,12 @@ +--- +title: "`Core` prefix removed from UI widget components" +pull_requests: [23612, 23938] +--- + +`CoreScrollbarThumb` has been renamed to `ScrollbarThumb`. +`CoreScrollbarDragState` has been renamed to `ScrollbarDragState`. +`CoreSliderDragState` has been renamed to `SliderDragState`. + +Additionally, `ScrollbarThumb` nodes are now laid out after `ui_layout_system` by `update_scrollbar_thumb`. `ScrollbarThumb` entities do +not have a `Node` component. The only layout options are for borders, which can be set using `ScrollbarThumb`'s new +`border` and `border_radius` fields. diff --git a/_release-content/migration-guides/CoreScrollThumb-is-now-ScrollThumb.md b/_release-content/migration-guides/CoreScrollThumb-is-now-ScrollThumb.md deleted file mode 100644 index 5af290a1f1..0000000000 --- a/_release-content/migration-guides/CoreScrollThumb-is-now-ScrollThumb.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: "CoreScrollbarThumb is now `ScrollbarThumb` and scroll bar thumb layout is updated separately" -pull_requests: [23612] ---- - -`CoreScrollbarThumb` has been renamed to `ScrollbarThumb`. - -`ScrollbarThumb` nodes are now laid out after `ui_layout_system` by `update_scrollbar_thumb`. `ScrollbarThumb` entities do -not have a `Node` component. The only layout options are for borders, which can be set using `ScrollbarThumb`'s new -`border` and `border_radius` fields. diff --git a/crates/bevy_ui_widgets/src/scrollbar.rs b/crates/bevy_ui_widgets/src/scrollbar.rs index 19c10c1a9e..348511bf83 100644 --- a/crates/bevy_ui_widgets/src/scrollbar.rs +++ b/crates/bevy_ui_widgets/src/scrollbar.rs @@ -76,7 +76,7 @@ pub struct Scrollbar { /// size and scroll position. #[derive(Component, FromTemplate, Debug, Default)] #[require( - CoreScrollbarDragState, + ScrollbarDragState, ComputedNode, ComputedUiTargetCamera, ComputedUiRenderTargetInfo, @@ -119,7 +119,7 @@ impl Scrollbar { /// inserted on the thumb entity. #[derive(Component, Default, Reflect)] #[reflect(Component, Default)] -pub struct CoreScrollbarDragState { +pub struct ScrollbarDragState { /// Whether the scrollbar is currently being dragged. pub dragging: bool, /// The value of the scrollbar when dragging started. @@ -187,7 +187,7 @@ fn scrollbar_on_pointer_down( fn scrollbar_on_drag_start( mut ev: On>, - mut q_thumb: Query<(&ChildOf, &mut CoreScrollbarDragState), With>, + mut q_thumb: Query<(&ChildOf, &mut ScrollbarDragState), With>, q_scrollbar: Query<&Scrollbar>, q_scroll_area: Query<&ScrollPosition>, ) { @@ -207,7 +207,7 @@ fn scrollbar_on_drag_start( fn scrollbar_on_drag( mut ev: On>, - mut q_thumb: Query<(&ChildOf, &mut CoreScrollbarDragState), With>, + mut q_thumb: Query<(&ChildOf, &mut ScrollbarDragState), With>, mut q_scrollbar: Query<(&ComputedNode, &Scrollbar)>, mut q_scroll_pos: Query<(&mut ScrollPosition, &ComputedNode), Without>, ui_scale: Res, @@ -249,7 +249,7 @@ fn scrollbar_on_drag( fn scrollbar_on_drag_end( mut ev: On>, - mut q_thumb: Query<&mut CoreScrollbarDragState, With>, + mut q_thumb: Query<&mut ScrollbarDragState, With>, ) { if let Ok(mut drag) = q_thumb.get_mut(ev.entity) { ev.propagate(false); @@ -261,7 +261,7 @@ fn scrollbar_on_drag_end( fn scrollbar_on_drag_cancel( mut ev: On>, - mut q_thumb: Query<&mut CoreScrollbarDragState, With>, + mut q_thumb: Query<&mut ScrollbarDragState, With>, ) { if let Ok(mut drag) = q_thumb.get_mut(ev.entity) { ev.propagate(false); diff --git a/crates/bevy_ui_widgets/src/slider.rs b/crates/bevy_ui_widgets/src/slider.rs index 8965e77ee6..77fc6ca5a3 100644 --- a/crates/bevy_ui_widgets/src/slider.rs +++ b/crates/bevy_ui_widgets/src/slider.rs @@ -96,7 +96,7 @@ pub enum TrackClick { #[derive(Component, FromTemplate, Debug, Default, Clone)] #[require( AccessibilityNode(accesskit::Node::new(Role::Slider)), - CoreSliderDragState, + SliderDragState, SliderValue, SliderRange, SliderStep @@ -238,7 +238,7 @@ impl SliderPrecision { /// Component used to manage the state of a slider during dragging. #[derive(Component, Default, Reflect)] #[reflect(Component)] -pub struct CoreSliderDragState { +pub struct SliderDragState { /// Whether the slider is currently being dragged. pub dragging: bool, @@ -362,11 +362,7 @@ pub(crate) fn slider_on_pointer_down( pub(crate) fn slider_on_drag_start( mut drag_start: On>, mut q_slider: Query< - ( - &SliderValue, - &mut CoreSliderDragState, - Has, - ), + (&SliderValue, &mut SliderDragState, Has), With, >, ) { @@ -388,7 +384,7 @@ pub(crate) fn slider_on_drag( &SliderRange, Option<&SliderPrecision>, &UiGlobalTransform, - &CoreSliderDragState, + &SliderDragState, Has, ), With, @@ -432,7 +428,7 @@ pub(crate) fn slider_on_drag_end( &SliderRange, Option<&SliderPrecision>, &UiGlobalTransform, - &mut CoreSliderDragState, + &mut SliderDragState, Has, ), With, @@ -478,7 +474,7 @@ fn emit_slider_drag_value_change( range: &SliderRange, precision: Option<&SliderPrecision>, transform: &UiGlobalTransform, - drag: &CoreSliderDragState, + drag: &SliderDragState, q_thumb: &Query<&ComputedNode, With>, q_children: &Query<&Children>, ui_scale: &UiScale, diff --git a/examples/ui/scroll_and_overflow/scrollbars.rs b/examples/ui/scroll_and_overflow/scrollbars.rs index 82c1ea9899..26fa3e8cef 100644 --- a/examples/ui/scroll_and_overflow/scrollbars.rs +++ b/examples/ui/scroll_and_overflow/scrollbars.rs @@ -5,7 +5,7 @@ use bevy::{ input_focus::tab_navigation::{TabGroup, TabNavigationPlugin}, picking::hover::Hovered, prelude::*, - ui_widgets::{ControlOrientation, CoreScrollbarDragState, Scrollbar, ScrollbarThumb}, + ui_widgets::{ControlOrientation, Scrollbar, ScrollbarDragState, ScrollbarThumb}, }; fn main() { @@ -159,10 +159,10 @@ fn text_row(caption: &str) -> impl Bundle { // Update the color of the scrollbar thumb. fn update_scrollbar_thumb( mut q_thumb: Query< - (&mut BackgroundColor, &Hovered, &CoreScrollbarDragState), + (&mut BackgroundColor, &Hovered, &ScrollbarDragState), ( With, - Or<(Changed, Changed)>, + Or<(Changed, Changed)>, ), >, ) { diff --git a/examples/ui/widgets/standard_widgets.rs b/examples/ui/widgets/standard_widgets.rs index f1f19fbb9a..71b6f79012 100644 --- a/examples/ui/widgets/standard_widgets.rs +++ b/examples/ui/widgets/standard_widgets.rs @@ -18,9 +18,9 @@ use bevy::{ ui_widgets::{ checkbox_self_update, observe, popover::{Popover, PopoverAlign, PopoverPlacement, PopoverSide}, - Activate, Button, Checkbox, CoreSliderDragState, MenuAction, MenuButton, MenuEvent, - MenuItem, MenuPopup, RadioButton, RadioGroup, Slider, SliderRange, SliderThumb, - SliderValue, TrackClick, ValueChange, + Activate, Button, Checkbox, MenuAction, MenuButton, MenuEvent, MenuItem, MenuPopup, + RadioButton, RadioGroup, Slider, SliderDragState, SliderRange, SliderThumb, SliderValue, + TrackClick, ValueChange, }, }; @@ -453,7 +453,7 @@ fn update_slider_style( &SliderValue, &SliderRange, &Hovered, - &CoreSliderDragState, + &SliderDragState, Has, ), ( @@ -461,7 +461,7 @@ fn update_slider_style( Changed, Changed, Changed, - Changed, + Changed, Added, )>, With, @@ -484,12 +484,7 @@ fn update_slider_style( fn update_slider_style2( sliders: Query< - ( - Entity, - &Hovered, - &CoreSliderDragState, - Has, - ), + (Entity, &Hovered, &SliderDragState, Has), With, >, children: Query<&Children>, diff --git a/examples/ui/widgets/vertical_slider.rs b/examples/ui/widgets/vertical_slider.rs index 1d1dfab354..ae7326675a 100644 --- a/examples/ui/widgets/vertical_slider.rs +++ b/examples/ui/widgets/vertical_slider.rs @@ -5,7 +5,7 @@ use bevy::{ picking::hover::Hovered, prelude::*, ui_widgets::{ - observe, slider_self_update, CoreSliderDragState, Slider, SliderRange, SliderThumb, + observe, slider_self_update, Slider, SliderDragState, SliderRange, SliderThumb, SliderValue, TrackClick, }, }; @@ -257,14 +257,14 @@ fn update_slider_visuals( &SliderValue, &SliderRange, &Hovered, - &CoreSliderDragState, + &SliderDragState, Has, ), ( Or<( Changed, Changed, - Changed, + Changed, )>, With, ),