Skip to main content

bevy_ui_widgets/
lib.rs

1//! This crate provides a set of standard widgets for Bevy UI, such as buttons, checkboxes, and sliders.
2//! These widgets have no inherent styling, it's the responsibility of the user to add styling
3//! appropriate for their game or application.
4//!
5//! ## State Management
6//!
7//! The typical way that UI widgets are used in games is that they often display a view of live
8//! data in the engine - they aren't just passive form fields to fill in and then submit.
9//! For example, a "color picker" might have multiple ways to edit an RGB value, including
10//! sliders, a color plane, a color wheel, hex input, or swatches of recent colors. Interacting with
11//! any of these widgets not only updates the RGB model, but also updates all of the other widgets.
12//!
13//! For this reason, almost all of the widgets use **external** state management: this means that
14//! the widgets do not automatically update their own internal state, but instead rely on the app
15//! to update the widget state (as well as any other related game state) in response to a change
16//! event emitted by the widget.
17//!
18//! These widgets emit a [`ValueChange`] event which carries the proposed new state; the app should respond
19//! to this event by updating its own internal model, and by updating the widget state. The general
20//! convention is that the widget state is contained in a specific state-bearing component
21//! (like [`SliderValue`]), and the widget detects when this component is inserted or replaced.
22//!
23//! This design pattern draws from the classic "MVC" (Model / View / Controller) style of
24//! widget design, which is also used by React.js for
25//! [controlled](https://medium.com/@rupalsinghal/controlled-vs-uncontrolled-components-in-react-the-complete-guide-you-cant-afford-to-miss-fbf6ea28b0fd)
26//! widgets.
27//!
28//! There are a few exceptions to this rule:
29//! * Buttons and menu items don't have any state, so they emit an [`Activate`] event instead.
30//!   (The hover and pressed states don't count, because they are purely visual / stylistic).
31//! * Text input widgets have a large and expensive state, so they handle their own state updates.
32//! * Scrollbars don't emit events, they modify the scroll position of the target entity
33//!   directly.
34//!
35//! For users who don't want to bother with writing a state update handler, these widgets provide
36//! a "self update" observer function: for example, the [`checkbox_self_update`] observer will
37//! listen for the [`ValueChange`] event and update the checkbox state. This effectively converts
38//! it into an "uncontrolled" widget, in React.js terms.
39//!
40//! ## Best practices for event propagation
41//!
42//! Generally, when a widget handles an event,
43//! propagation of that event to parent entities should be stopped. Events which are not of
44//! interest to the widget should be allowed to propagate.
45//! This "consume what you use" principle is important when writing your custom widgets, and
46//! understanding the behavior of existing widgets.
47//!
48//! For more guidance on this, see the documentation for [`EntityEvent`].
49
50mod button;
51mod checkbox;
52mod dialog;
53mod list;
54mod menu;
55mod modal;
56mod observe;
57pub mod popover;
58mod radio;
59mod scrollarea;
60mod scrollbar;
61mod slider;
62mod tabs;
63mod text_input;
64
65use bevy_input_focus::pointer_focus::PointerFocusPlugin;
66pub use button::*;
67pub use checkbox::*;
68pub use dialog::*;
69pub use list::*;
70pub use menu::*;
71pub use modal::*;
72pub use observe::*;
73pub use radio::*;
74pub use scrollarea::*;
75pub use scrollbar::*;
76pub use slider::*;
77pub use tabs::*;
78pub use text_input::*;
79
80use bevy_app::{PluginGroup, PluginGroupBuilder};
81use bevy_ecs::{entity::Entity, event::EntityEvent, reflect::ReflectEvent};
82use bevy_reflect::Reflect;
83
84use crate::popover::PopoverPlugin;
85
86/// A plugin group that registers the observers for all of the widgets in this crate. If you don't want to
87/// use all of the widgets, you can import the individual widget plugins instead.
88#[derive(#[automatically_derived]
impl ::core::default::Default for UiWidgetsPlugins {
    #[inline]
    fn default() -> Self { Self }
}Default)]
89pub struct UiWidgetsPlugins;
90
91impl PluginGroup for UiWidgetsPlugins {
92    fn build(self) -> PluginGroupBuilder {
93        PluginGroupBuilder::start::<Self>()
94            .add(ButtonPlugin)
95            .add(CheckboxPlugin)
96            .add(TextInputPlugin)
97            .add(ListBoxPlugin)
98            .add(MenuPlugin)
99            .add(DialogPlugin)
100            .add(ModalDialogPlugin)
101            .add(PopoverPlugin)
102            .add(RadioGroupPlugin)
103            .add(ScrollAreaPlugin)
104            .add(ScrollbarPlugin)
105            .add(SliderPlugin)
106            .add(TabPlugin)
107            .add(PointerFocusPlugin)
108    }
109}
110
111/// Notification sent by a button or menu item.
112#[derive(#[automatically_derived]
impl ::core::marker::Copy for Activate { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Activate { }
#[automatically_derived]
impl ::core::clone::Clone for Activate {
    #[inline]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Entity>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Activate {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Activate",
            "entity", &&self.entity)
    }
}Debug, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for Activate { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Activate {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.entity == other.entity }
}PartialEq, impl bevy_ecs::event::Event for Activate where Self: ::core::marker::Send +
    ::core::marker::Sync + 'static {
    type Trigger<'a> = bevy_ecs::event::EntityTrigger;
}
impl bevy_ecs::event::EntityEvent for Activate where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    fn event_target(&self) -> bevy_ecs::entity::Entity {
        bevy_ecs::entity::ContainsEntity::entity(&self.entity)
    }
}EntityEvent, const _: () =
    {
        impl bevy_reflect::GetTypeRegistration for Activate where  {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectEvent, Self,
                    _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <Entity as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl bevy_reflect::Typed for Activate where  {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::NonGenericTypeInfoCell =
                    bevy_reflect::utility::NonGenericTypeInfoCell::new();
                CELL.get_or_set(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[bevy_reflect::NamedField::new::<Entity>("entity")]))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl bevy_reflect::TypePath for Activate where  {
            fn type_path() -> &'static str { "bevy_ui_widgets::Activate" }
            fn short_type_path() -> &'static str { "Activate" }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("Activate")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_ui_widgets".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_ui_widgets")
            }
        }
        impl bevy_reflect::Reflect for Activate where  {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        #[allow(non_upper_case_globals)]
        const _: () =
            {
                static __INVENTORY: ::inventory::Node =
                    ::inventory::Node {
                        value: &{
                                bevy_reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<Activate
                                        as
                                        bevy_reflect::__macro_exports::auto_register::RegisterForReflection>::__register)
                            },
                        next: ::inventory::__private::UnsafeCell::new(::inventory::__private::Option::None),
                    };
                #[link_section = ".text.startup"]
                unsafe extern "C" fn __ctor() {
                    unsafe {
                        ::inventory::ErasedNode::submit(__INVENTORY.value,
                            &__INVENTORY)
                    }
                }
                #[used]
                #[link_section = ".init_array"]
                static __CTOR: unsafe extern "C" fn() = __ctor;
            };
        impl bevy_reflect::structs::Struct for Activate where  {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name {
                    "entity" => ::core::option::Option::Some(&self.entity),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name {
                    "entity" => ::core::option::Option::Some(&mut self.entity),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&self.entity),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&mut self.entity),
                    _ => ::core::option::Option::None,
                }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index {
                    0usize => ::core::option::Option::Some("entity"),
                    _ => ::core::option::Option::None,
                }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name {
                    "entity" => ::core::option::Option::Some(0usize),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_len(&self) -> usize { 1usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                ->
                    ::core::result::Result<bevy_reflect::structs::DynamicStruct,
                    bevy_reflect::ReflectCloneError> {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic.insert_boxed("entity",
                    bevy_reflect::PartialReflect::to_dynamic(&self.entity)?);
                ::core::result::Result::Ok(dynamic)
            }
        }
        impl bevy_reflect::PartialReflect for Activate where  {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            #[inline]
            #[allow(unreachable_code, reason =
            "Ignored fields without a `clone` attribute will early-return with an error")]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(Self {
                            entity: <Entity as
                                        bevy_reflect::PartialReflect>::reflect_clone_and_take(&self.entity)?,
                        }))
            }
        }
        impl bevy_reflect::FromReflect for Activate where  {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let __this =
                        Self {
                            entity: <Entity as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "entity")?)?,
                        };
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
113#[reflect(Event)]
114pub struct Activate {
115    /// The activated entity.
116    pub entity: Entity,
117}
118
119/// Notification sent by a widget that edits a scalar value.
120#[derive(#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for ValueChange<T> { }Copy, #[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for ValueChange<T> {
    #[inline]
    fn clone(&self) -> Self {
        Self {
            source: ::core::clone::Clone::clone(&self.source),
            value: ::core::clone::Clone::clone(&self.value),
            is_final: ::core::clone::Clone::clone(&self.is_final),
        }
    }
}Clone, #[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for ValueChange<T> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "ValueChange",
            "source", &self.source, "value", &self.value, "is_final",
            &&self.is_final)
    }
}Debug, #[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::marker::StructuralPartialEq for
    ValueChange<T> {
}
#[automatically_derived]
impl<T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for ValueChange<T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.is_final == other.is_final && self.source == other.source &&
            self.value == other.value
    }
}PartialEq, impl<T> bevy_ecs::event::Event for ValueChange<T> where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    type Trigger<'a> = bevy_ecs::event::EntityTrigger;
}
impl<T> bevy_ecs::event::EntityEvent for ValueChange<T> where
    Self: ::core::marker::Send + ::core::marker::Sync + 'static {
    fn event_target(&self) -> bevy_ecs::entity::Entity {
        bevy_ecs::entity::ContainsEntity::entity(&self.source)
    }
}EntityEvent, const _: () =
    {
        impl<T> bevy_reflect::GetTypeRegistration for ValueChange<T> where
            ValueChange<T>: ::core::any::Any + ::core::marker::Send +
            ::core::marker::Sync, T: bevy_reflect::TypePath,
            T: bevy_reflect::FromReflect + bevy_reflect::TypePath +
            bevy_reflect::MaybeTyped +
            bevy_reflect::__macro_exports::RegisterForReflection {
            fn get_type_registration() -> bevy_reflect::TypeRegistration {
                let mut registration =
                    bevy_reflect::TypeRegistration::of::<Self>();
                registration.insert(<bevy_reflect::ReflectFromPtr as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.insert(<bevy_reflect::ReflectFromReflect as
                            bevy_reflect::CreateTypeData<Self>>::create_type_data(()));
                registration.register_type_data_with::<ReflectEvent, Self,
                    _>(());
                registration
            }
            #[inline(never)]
            fn register_type_dependencies(registry:
                    &mut bevy_reflect::TypeRegistry) {
                <Entity as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <T as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
                <bool as
                        bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
            }
        }
        impl<T> bevy_reflect::Typed for ValueChange<T> where
            ValueChange<T>: ::core::any::Any + ::core::marker::Send +
            ::core::marker::Sync, T: bevy_reflect::TypePath,
            T: bevy_reflect::FromReflect + bevy_reflect::TypePath +
            bevy_reflect::MaybeTyped +
            bevy_reflect::__macro_exports::RegisterForReflection {
            #[inline(never)]
            fn type_info() -> &'static bevy_reflect::TypeInfo {
                static CELL: bevy_reflect::utility::GenericTypeInfoCell =
                    bevy_reflect::utility::GenericTypeInfoCell::new();
                CELL.get_or_insert::<Self,
                    _>(#[inline(never)] ||
                        {
                            bevy_reflect::TypeInfo::Struct(bevy_reflect::structs::StructInfo::new::<Self>(&[bevy_reflect::NamedField::new::<Entity>("source"),
                                                    bevy_reflect::NamedField::new::<T>("value"),
                                                    bevy_reflect::NamedField::new::<bool>("is_final")]).with_generics(bevy_reflect::Generics::from_iter([bevy_reflect::GenericInfo::Type(bevy_reflect::TypeParamInfo::new::<T>(bevy_reflect::__macro_exports::alloc_utils::Cow::Borrowed("T")))])))
                        })
            }
        }
        #[allow(deprecated, reason =
        "derives on a deprecated type shouldn't be considered a usage")]
        impl<T> bevy_reflect::TypePath for ValueChange<T> where
            ValueChange<T>: ::core::any::Any + ::core::marker::Send +
            ::core::marker::Sync, T: bevy_reflect::TypePath {
            fn type_path() -> &'static str {
                static CELL: bevy_reflect::utility::GenericTypePathCell =
                    bevy_reflect::utility::GenericTypePathCell::new();
                CELL.get_or_insert::<Self,
                    _>(#[inline(never)] ||
                        {
                            ::core::ops::Add::<&str>::add(::core::ops::Add::<&str>::add(bevy_reflect::__macro_exports::alloc_utils::ToString::to_string("bevy_ui_widgets::ValueChange<"),
                                    <T as bevy_reflect::TypePath>::type_path()), ">")
                        })
            }
            fn short_type_path() -> &'static str {
                static CELL: bevy_reflect::utility::GenericTypePathCell =
                    bevy_reflect::utility::GenericTypePathCell::new();
                CELL.get_or_insert::<Self,
                    _>(#[inline(never)] ||
                        {
                            ::core::ops::Add::<&str>::add(::core::ops::Add::<&str>::add(bevy_reflect::__macro_exports::alloc_utils::ToString::to_string("ValueChange<"),
                                    <T as bevy_reflect::TypePath>::short_type_path()), ">")
                        })
            }
            fn type_ident() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("ValueChange")
            }
            fn crate_name() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_ui_widgets".split(':').next().unwrap())
            }
            fn module_path() -> ::core::option::Option<&'static str> {
                ::core::option::Option::Some("bevy_ui_widgets")
            }
        }
        impl<T> bevy_reflect::Reflect for ValueChange<T> where
            ValueChange<T>: ::core::any::Any + ::core::marker::Send +
            ::core::marker::Sync, T: bevy_reflect::TypePath,
            T: bevy_reflect::FromReflect + bevy_reflect::TypePath +
            bevy_reflect::MaybeTyped +
            bevy_reflect::__macro_exports::RegisterForReflection {
            #[inline]
            fn into_any(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
                self
            }
            #[inline]
            fn as_any(&self) -> &dyn ::core::any::Any { self }
            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
            #[inline]
            fn into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
                self
            }
            #[inline]
            fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
            #[inline]
            fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
                self
            }
            #[inline]
            fn set(&mut self,
                value:
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
                ->
                    ::core::result::Result<(),
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
                *self = <dyn bevy_reflect::Reflect>::take(value)?;
                ::core::result::Result::Ok(())
            }
        }
        impl<T> bevy_reflect::structs::Struct for ValueChange<T> where
            ValueChange<T>: ::core::any::Any + ::core::marker::Send +
            ::core::marker::Sync, T: bevy_reflect::TypePath,
            T: bevy_reflect::FromReflect + bevy_reflect::TypePath +
            bevy_reflect::MaybeTyped +
            bevy_reflect::__macro_exports::RegisterForReflection {
            fn field(&self, name: &str)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match name {
                    "source" => ::core::option::Option::Some(&self.source),
                    "value" => ::core::option::Option::Some(&self.value),
                    "is_final" => ::core::option::Option::Some(&self.is_final),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_mut(&mut self, name: &str)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match name {
                    "source" => ::core::option::Option::Some(&mut self.source),
                    "value" => ::core::option::Option::Some(&mut self.value),
                    "is_final" =>
                        ::core::option::Option::Some(&mut self.is_final),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at(&self, index: usize)
                -> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&self.source),
                    1usize => ::core::option::Option::Some(&self.value),
                    2usize => ::core::option::Option::Some(&self.is_final),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_at_mut(&mut self, index: usize)
                ->
                    ::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
                match index {
                    0usize => ::core::option::Option::Some(&mut self.source),
                    1usize => ::core::option::Option::Some(&mut self.value),
                    2usize => ::core::option::Option::Some(&mut self.is_final),
                    _ => ::core::option::Option::None,
                }
            }
            fn name_at(&self, index: usize) -> ::core::option::Option<&str> {
                match index {
                    0usize => ::core::option::Option::Some("source"),
                    1usize => ::core::option::Option::Some("value"),
                    2usize => ::core::option::Option::Some("is_final"),
                    _ => ::core::option::Option::None,
                }
            }
            fn index_of_name(&self, name: &str)
                -> ::core::option::Option<usize> {
                match name {
                    "source" => ::core::option::Option::Some(0usize),
                    "value" => ::core::option::Option::Some(1usize),
                    "is_final" => ::core::option::Option::Some(2usize),
                    _ => ::core::option::Option::None,
                }
            }
            fn field_len(&self) -> usize { 3usize }
            fn iter_fields(&self) -> bevy_reflect::structs::FieldIter {
                bevy_reflect::structs::FieldIter::new(self)
            }
            fn to_dynamic_struct(&self)
                ->
                    ::core::result::Result<bevy_reflect::structs::DynamicStruct,
                    bevy_reflect::ReflectCloneError> {
                let mut dynamic: bevy_reflect::structs::DynamicStruct =
                    ::core::default::Default::default();
                dynamic.set_represented_type(bevy_reflect::PartialReflect::get_represented_type_info(self));
                dynamic.insert_boxed("source",
                    bevy_reflect::PartialReflect::to_dynamic(&self.source)?);
                dynamic.insert_boxed("value",
                    bevy_reflect::PartialReflect::to_dynamic(&self.value)?);
                dynamic.insert_boxed("is_final",
                    bevy_reflect::PartialReflect::to_dynamic(&self.is_final)?);
                ::core::result::Result::Ok(dynamic)
            }
        }
        impl<T> bevy_reflect::PartialReflect for ValueChange<T> where
            ValueChange<T>: ::core::any::Any + ::core::marker::Send +
            ::core::marker::Sync, T: bevy_reflect::TypePath,
            T: bevy_reflect::FromReflect + bevy_reflect::TypePath +
            bevy_reflect::MaybeTyped +
            bevy_reflect::__macro_exports::RegisterForReflection {
            #[inline]
            fn get_represented_type_info(&self)
                -> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
                ::core::option::Option::Some(<Self as
                            bevy_reflect::Typed>::type_info())
            }
            #[inline]
            fn try_apply(&mut self, value: &dyn bevy_reflect::PartialReflect)
                -> ::core::result::Result<(), bevy_reflect::ApplyError> {
                if let bevy_reflect::ReflectRef::Struct(struct_value) =
                        bevy_reflect::PartialReflect::reflect_ref(value) {
                    for (name, value) in
                        bevy_reflect::structs::Struct::iter_fields(struct_value) {
                        if let ::core::option::Option::Some(v) =
                                bevy_reflect::structs::Struct::field_mut(self, name) {
                            bevy_reflect::PartialReflect::try_apply(v, value)?;
                        }
                    }
                } else {
                    return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
                                from_kind: bevy_reflect::PartialReflect::reflect_kind(value),
                                to_kind: bevy_reflect::ReflectKind::Struct,
                            });
                }
                ::core::result::Result::Ok(())
            }
            #[inline]
            fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
                bevy_reflect::ReflectKind::Struct
            }
            #[inline]
            fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
                bevy_reflect::ReflectRef::Struct(self)
            }
            #[inline]
            fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
                bevy_reflect::ReflectMut::Struct(self)
            }
            #[inline]
            fn reflect_owned(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                -> bevy_reflect::ReflectOwned {
                bevy_reflect::ReflectOwned::Struct(self)
            }
            #[inline]
            fn try_into_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
                ::core::result::Result::Ok(self)
            }
            #[inline]
            fn try_as_reflect(&self)
                -> ::core::option::Option<&dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn try_as_reflect_mut(&mut self)
                -> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
                ::core::option::Option::Some(self)
            }
            #[inline]
            fn into_partial_reflect(self:
                    bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
                ->
                    bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
                self
            }
            #[inline]
            fn as_partial_reflect(&self)
                -> &dyn bevy_reflect::PartialReflect {
                self
            }
            #[inline]
            fn as_partial_reflect_mut(&mut self)
                -> &mut dyn bevy_reflect::PartialReflect {
                self
            }
            fn reflect_partial_eq(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<bool> {
                (bevy_reflect::structs::struct_partial_eq)(self, value)
            }
            fn reflect_partial_cmp(&self,
                value: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<::core::cmp::Ordering> {
                (bevy_reflect::structs::struct_partial_cmp)(self, value)
            }
            #[inline]
            #[allow(unreachable_code, reason =
            "Ignored fields without a `clone` attribute will early-return with an error")]
            fn reflect_clone(&self)
                ->
                    ::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
                    bevy_reflect::ReflectCloneError> {
                ::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(Self {
                            source: <Entity as
                                        bevy_reflect::PartialReflect>::reflect_clone_and_take(&self.source)?,
                            value: <T as
                                        bevy_reflect::PartialReflect>::reflect_clone_and_take(&self.value)?,
                            is_final: <bool as
                                        bevy_reflect::PartialReflect>::reflect_clone_and_take(&self.is_final)?,
                        }))
            }
        }
        impl<T> bevy_reflect::FromReflect for ValueChange<T> where
            ValueChange<T>: ::core::any::Any + ::core::marker::Send +
            ::core::marker::Sync, T: bevy_reflect::TypePath,
            T: bevy_reflect::FromReflect + bevy_reflect::TypePath +
            bevy_reflect::MaybeTyped +
            bevy_reflect::__macro_exports::RegisterForReflection {
            fn from_reflect(reflect: &dyn bevy_reflect::PartialReflect)
                -> ::core::option::Option<Self> {
                if let bevy_reflect::ReflectRef::Struct(__ref_struct) =
                        bevy_reflect::PartialReflect::reflect_ref(reflect) {
                    let __this =
                        Self {
                            source: <Entity as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "source")?)?,
                            value: <T as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "value")?)?,
                            is_final: <bool as
                                        bevy_reflect::FromReflect>::from_reflect(bevy_reflect::structs::Struct::field(__ref_struct,
                                            "is_final")?)?,
                        };
                    ::core::option::Option::Some(__this)
                } else { ::core::option::Option::None }
            }
        }
    };Reflect)]
121#[reflect(Event)]
122pub struct ValueChange<T> {
123    /// The id of the widget that produced this value.
124    #[event_target]
125    pub source: Entity,
126    /// The new value.
127    pub value: T,
128    /// If false, it means that we are in the middle of an interaction (slider being dragged,
129    /// user typing), while if true it means that the user's interaction is finished (mouse button
130    /// released, drag ended, input lost focus).
131    pub is_final: bool,
132}