Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/bevy_core_widgets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bevy_input_focus = { path = "../bevy_input_focus", version = "0.17.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.17.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.17.0-dev" }
bevy_picking = { path = "../bevy_picking", version = "0.17.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev" }
bevy_ui = { path = "../bevy_ui", version = "0.17.0-dev" }

# other
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_core_widgets/src/callback.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bevy_ecs::system::{Commands, SystemId, SystemInput};
use bevy_ecs::world::{DeferredWorld, World};
use bevy_reflect::{prelude::ReflectDefault, Reflect};

/// A callback defines how we want to be notified when a widget changes state. Unlike an event
/// or observer, callbacks are intended for "point-to-point" communication that cuts across the
Expand Down Expand Up @@ -27,7 +28,8 @@ use bevy_ecs::world::{DeferredWorld, World};
/// // Later, when we want to execute the callback:
/// app.world_mut().commands().notify(&callback);
/// ```
#[derive(Default, Debug)]
#[derive(Default, Debug, Reflect)]
#[reflect(Default)]
pub enum Callback<I: SystemInput = ()> {
/// Invoke a one-shot system
System(SystemId<I>),
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_core_widgets/src/core_radio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ use bevy_ecs::{
component::Component,
observer::On,
query::With,
reflect::ReflectComponent,
system::{Commands, Query},
};
use bevy_input::keyboard::{KeyCode, KeyboardInput};
use bevy_input::ButtonState;
use bevy_input_focus::FocusedInput;
use bevy_picking::events::{Click, Pointer};
use bevy_reflect::Reflect;
use bevy_ui::{Checkable, Checked, InteractionDisabled};

use crate::{Activate, Callback, Notify};
Expand Down Expand Up @@ -48,6 +50,8 @@ pub struct CoreRadioGroup {
/// See <https://www.w3.org/WAI/ARIA/apg/patterns/radio>/
#[derive(Component, Debug)]
#[require(AccessibilityNode(accesskit::Node::new(Role::RadioButton)), Checkable)]
#[derive(Reflect)]
#[reflect(Component)]
pub struct CoreRadio;

fn radio_group_on_key_input(
Expand Down
13 changes: 10 additions & 3 deletions crates/bevy_core_widgets/src/core_scrollbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ use bevy_ecs::{
hierarchy::{ChildOf, Children},
observer::On,
query::{With, Without},
reflect::ReflectComponent,
system::{Query, Res},
};
use bevy_math::Vec2;
use bevy_picking::events::{Cancel, Drag, DragEnd, DragStart, Pointer, Press};
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_ui::{
ComputedNode, ComputedNodeTarget, Node, ScrollPosition, UiGlobalTransform, UiScale, Val,
};

/// Used to select the orientation of a scrollbar, slider, or other oriented control.
// TODO: Move this to a more central place.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Reflect)]
#[reflect(PartialEq, Clone, Default)]
pub enum ControlOrientation {
/// Horizontal orientation (stretching from left to right)
Horizontal,
Expand Down Expand Up @@ -45,7 +48,8 @@ pub enum ControlOrientation {
/// The application is free to position the scrollbars relative to the scrolling container however
/// it wants: it can overlay them on top of the scrolling content, or use a grid layout to displace
/// the content to make room for the scrollbars.
#[derive(Component, Debug)]
#[derive(Component, Debug, Reflect)]
#[reflect(Component)]
pub struct CoreScrollbar {
/// Entity being scrolled.
pub target: Entity,
Expand All @@ -62,6 +66,8 @@ pub struct CoreScrollbar {
/// the scrollbar). This should be a child of the scrollbar entity.
#[derive(Component, Debug)]
#[require(CoreScrollbarDragState)]
#[derive(Reflect)]
#[reflect(Component)]
pub struct CoreScrollbarThumb;

impl CoreScrollbar {
Expand All @@ -83,7 +89,8 @@ impl CoreScrollbar {

/// Component used to manage the state of a scrollbar during dragging. This component is
/// inserted on the thumb entity.
#[derive(Component, Default)]
#[derive(Component, Default, Reflect)]
#[reflect(Component, Default)]
pub struct CoreScrollbarDragState {
/// Whether the scrollbar is currently being dragged.
pub dragging: bool,
Expand Down
13 changes: 10 additions & 3 deletions crates/bevy_core_widgets/src/core_slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use bevy_ecs::{
component::Component,
observer::On,
query::With,
reflect::ReflectComponent,
system::{Commands, Query},
};
use bevy_input::keyboard::{KeyCode, KeyboardInput};
Expand All @@ -21,12 +22,14 @@ use bevy_input_focus::FocusedInput;
use bevy_log::warn_once;
use bevy_math::ops;
use bevy_picking::events::{Drag, DragEnd, DragStart, Pointer, Press};
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_ui::{ComputedNode, ComputedNodeTarget, InteractionDisabled, UiGlobalTransform, UiScale};

use crate::{Callback, Notify, ValueChange};

/// Defines how the slider should behave when you click on the track (not the thumb).
#[derive(Debug, Default, PartialEq, Clone, Copy)]
#[derive(Debug, Default, PartialEq, Clone, Copy, Reflect)]
#[reflect(Clone, PartialEq, Default)]
pub enum TrackClick {
/// Clicking on the track lets you drag to edit the value, just like clicking on the thumb.
#[default]
Expand Down Expand Up @@ -181,6 +184,8 @@ impl Default for SliderRange {
/// shortcuts. Defaults to 1.0.
#[derive(Component, Debug, PartialEq, Clone)]
#[component(immutable)]
#[derive(Reflect)]
#[reflect(Component)]
pub struct SliderStep(pub f32);

impl Default for SliderStep {
Expand All @@ -198,7 +203,8 @@ impl Default for SliderStep {
/// The value in this component represents the number of decimal places of desired precision, so a
/// value of 2 would round to the nearest 1/100th. A value of -3 would round to the nearest
/// thousand.
#[derive(Component, Debug, Default, Clone, Copy)]
#[derive(Component, Debug, Default, Clone, Copy, Reflect)]
#[reflect(Component, Default)]
pub struct SliderPrecision(pub i32);

impl SliderPrecision {
Expand All @@ -209,7 +215,8 @@ impl SliderPrecision {
}

/// Component used to manage the state of a slider during dragging.
#[derive(Component, Default)]
#[derive(Component, Default, Reflect)]
#[reflect(Component)]
pub struct CoreSliderDragState {
/// Whether the slider is currently being dragged.
pub dragging: bool,
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_feathers/src/alpha_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use bevy_ecs::{
component::Component,
lifecycle::Add,
observer::On,
reflect::ReflectComponent,
resource::Resource,
system::{Query, Res},
world::FromWorld,
};
use bevy_reflect::TypePath;
use bevy_reflect::{prelude::ReflectDefault, Reflect, TypePath};
use bevy_render::render_resource::{AsBindGroup, ShaderRef};
use bevy_ui_render::ui_material::{MaterialNode, UiMaterial};

Expand All @@ -34,7 +35,8 @@ impl FromWorld for AlphaPatternResource {
}

/// Marker that tells us we want to fill in the [`MaterialNode`] with the alpha material.
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Default)]
pub(crate) struct AlphaPattern;

/// Observer to fill in the material handle (since we don't have access to the materials asset
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_feathers/src/controls/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ use bevy_ecs::{
hierarchy::{ChildOf, Children},
lifecycle::RemovedComponents,
query::{Added, Changed, Has, Or},
reflect::ReflectComponent,
schedule::IntoScheduleConfigs,
spawn::{SpawnRelated, SpawnableList},
system::{Commands, In, Query},
};
use bevy_input_focus::tab_navigation::TabIndex;
use bevy_picking::{hover::Hovered, PickingSystems};
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_ui::{AlignItems, InteractionDisabled, JustifyContent, Node, Pressed, UiRect, Val};

use crate::{
Expand All @@ -27,7 +29,8 @@ use crate::{

/// Color variants for buttons. This also functions as a component used by the dynamic styling
/// system to identify which entities are buttons.
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
pub enum ButtonVariant {
/// The standard button appearance
#[default]
Expand Down
11 changes: 8 additions & 3 deletions crates/bevy_feathers/src/controls/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ use bevy_ecs::{
hierarchy::{ChildOf, Children},
lifecycle::RemovedComponents,
query::{Added, Changed, Has, Or, With},
reflect::ReflectComponent,
schedule::IntoScheduleConfigs,
spawn::{Spawn, SpawnRelated, SpawnableList},
system::{Commands, In, Query},
};
use bevy_input_focus::tab_navigation::TabIndex;
use bevy_math::Rot2;
use bevy_picking::{hover::Hovered, PickingSystems};
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_render::view::Visibility;
use bevy_ui::{
AlignItems, BorderRadius, Checked, Display, FlexDirection, InteractionDisabled, JustifyContent,
Expand All @@ -38,15 +40,18 @@ pub struct CheckboxProps {
}

/// Marker for the checkbox frame (contains both checkbox and label)
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct CheckboxFrame;

/// Marker for the checkbox outline
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct CheckboxOutline;

/// Marker for the checkbox check mark
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct CheckboxMark;

/// Template function to spawn a checkbox.
Expand Down
11 changes: 8 additions & 3 deletions crates/bevy_feathers/src/controls/color_swatch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use bevy_asset::Handle;
use bevy_color::Alpha;
use bevy_ecs::{bundle::Bundle, children, component::Component, spawn::SpawnRelated};
use bevy_ecs::{
bundle::Bundle, children, component::Component, reflect::ReflectComponent, spawn::SpawnRelated,
};
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_ui::{BackgroundColor, BorderRadius, Node, PositionType, Val};
use bevy_ui_render::ui_material::MaterialNode;

Expand All @@ -11,13 +14,15 @@ use crate::{
};

/// Marker identifying a color swatch.
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
pub struct ColorSwatch;

/// Marker identifying the color swatch foreground, the piece that actually displays the color
/// in front of the alpha pattern. This exists so that users can reach in and change the color
/// dynamically.
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
pub struct ColorSwatchFg;

/// Template function to spawn a color swatch.
Expand Down
8 changes: 6 additions & 2 deletions crates/bevy_feathers/src/controls/radio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ use bevy_ecs::{
hierarchy::{ChildOf, Children},
lifecycle::RemovedComponents,
query::{Added, Changed, Has, Or, With},
reflect::ReflectComponent,
schedule::IntoScheduleConfigs,
spawn::{Spawn, SpawnRelated, SpawnableList},
system::{Commands, Query},
};
use bevy_input_focus::tab_navigation::TabIndex;
use bevy_picking::{hover::Hovered, PickingSystems};
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_render::view::Visibility;
use bevy_ui::{
AlignItems, BorderRadius, Checked, Display, FlexDirection, InteractionDisabled, JustifyContent,
Expand All @@ -30,11 +32,13 @@ use crate::{
};

/// Marker for the radio outline
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct RadioOutline;

/// Marker for the radio check mark
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct RadioMark;

/// Template function to spawn a radio.
Expand Down
7 changes: 6 additions & 1 deletion crates/bevy_feathers/src/controls/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ use bevy_ecs::{
hierarchy::Children,
lifecycle::RemovedComponents,
query::{Added, Changed, Has, Or, Spawned, With},
reflect::ReflectComponent,
schedule::IntoScheduleConfigs,
spawn::SpawnRelated,
system::{In, Query, Res},
};
use bevy_input_focus::tab_navigation::TabIndex;
use bevy_picking::PickingSystems;
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_ui::{
widget::Text, AlignItems, BackgroundGradient, ColorStop, Display, FlexDirection, Gradient,
InteractionDisabled, InterpolationColorSpace, JustifyContent, LinearGradient, Node, UiRect,
Expand Down Expand Up @@ -58,10 +60,13 @@ impl Default for SliderProps {

#[derive(Component, Default, Clone)]
#[require(CoreSlider)]
#[derive(Reflect)]
#[reflect(Component, Clone, Default)]
struct SliderStyle;

/// Marker for the text
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct SliderValueText;

/// Spawn a new slider widget.
Expand Down
8 changes: 6 additions & 2 deletions crates/bevy_feathers/src/controls/toggle_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ use bevy_ecs::{
hierarchy::Children,
lifecycle::RemovedComponents,
query::{Added, Changed, Has, Or, With},
reflect::ReflectComponent,
schedule::IntoScheduleConfigs,
spawn::SpawnRelated,
system::{Commands, In, Query},
world::Mut,
};
use bevy_input_focus::tab_navigation::TabIndex;
use bevy_picking::{hover::Hovered, PickingSystems};
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_ui::{BorderRadius, Checked, InteractionDisabled, Node, PositionType, UiRect, Val};

use crate::{
Expand All @@ -34,11 +36,13 @@ pub struct ToggleSwitchProps {
}

/// Marker for the toggle switch outline
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct ToggleSwitchOutline;

/// Marker for the toggle switch slide
#[derive(Component, Default, Clone)]
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Clone, Default)]
struct ToggleSwitchSlide;

/// Template function to spawn a toggle switch.
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_feathers/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy_ecs::{
entity::Entity,
hierarchy::ChildOf,
query::{With, Without},
reflect::ReflectComponent,
reflect::{ReflectComponent, ReflectResource},
resource::Resource,
schedule::IntoScheduleConfigs,
system::{Commands, Query, Res},
Expand All @@ -19,7 +19,8 @@ use bevy_winit::cursor::CustomCursor;

/// A resource that specifies the cursor icon to be used when the mouse is not hovering over
/// any other entity. This is used to set the default cursor icon for the window.
#[derive(Resource, Debug, Clone, Default)]
#[derive(Resource, Debug, Clone, Default, Reflect)]
#[reflect(Resource, Debug, Default)]
pub struct DefaultCursor(pub EntityCursor);

/// A component that specifies the cursor shape to be used when the pointer hovers over an entity.
Expand Down
Loading
Loading