Expand description
This crate provides a set of standard widgets for Bevy UI, such as buttons, checkboxes, and sliders. These widgets have no inherent styling, it’s the responsibility of the user to add styling appropriate for their game or application.
§Warning: Experimental
This crate is currently experimental and under active development. The API is likely to change substantially: be prepared to migrate your code.
We are actively seeking feedback on the design and implementation of this crate, so please file issues or create PRs if you have any comments or suggestions.
§State Management
Most of the widgets use external state management: this means that the widgets do not automatically update their own internal state, but instead rely on the app to update the widget state (as well as any other related game state) in response to a change event emitted by the widget. The primary motivation for this is to avoid two-way data binding in scenarios where the user interface is showing a live view of dynamic data coming from deeper within the game engine.
Structs§
- Activate
- Notification sent by a button or menu item.
- AddObserver
- Helper struct that adds an observer when inserted as a
Bundle. - Button
- Headless button widget. This widget maintains a “pressed” state, which is used to
indicate whether the button is currently being pressed by the user. It emits an
Activateevent when the button is un-pressed. - Button
Plugin - Plugin that adds the observers for the
Buttonwidget. - Checkbox
- Headless widget implementation for checkboxes. The
Checkedcomponent represents the current state of the checkbox. The widget will emit aValueChange<bool>event when clicked, or when theEnterorSpacekey is pressed while the checkbox is focused. - Checkbox
Plugin - Plugin that adds the observers for the
Checkboxwidget. - Core
Scrollbar Drag State - Component used to manage the state of a scrollbar during dragging. This component is inserted on the thumb entity.
- Core
Scrollbar Thumb - Marker component to indicate that the entity is a scrollbar thumb (the moving, draggable part of the scrollbar). This should be a child of the scrollbar entity.
- Core
Slider Drag State - Component used to manage the state of a slider during dragging.
- Radio
Button - Headless widget implementation for radio buttons. These should be enclosed within a
RadioGroupwidget, which is responsible for the mutual exclusion logic. - Radio
Group - Headless widget implementation for a “radio button group”. This component is used to group
multiple
RadioButtoncomponents together, allowing them to behave as a single unit. It implements the tab navigation logic and keyboard shortcuts for radio buttons. - Radio
Group Plugin - Plugin that adds the observers for the
RadioGroupwidget. - Scrollbar
- A headless scrollbar widget, which can be used to build custom scrollbars.
- Scrollbar
Plugin - Plugin that adds the observers for the
Scrollbarwidget. - SetChecked
- Event which can be triggered on a checkbox to set the checked state. This can be used to control the checkbox via gamepad buttons or other inputs.
- SetSlider
Value - An
EntityEventthat can be triggered on a slider to modify its value (using theon_changecallback). This can be used to control the slider via gamepad buttons or other inputs. The value will be clamped when the event is processed. - Slider
- A headless slider widget, which can be used to build custom sliders. Sliders have a value
(represented by the
SliderValuecomponent) and a range (represented bySliderRange). An optional step size can be specified viaSliderStep, and you can control the rounding during dragging withSliderPrecision. - Slider
Plugin - Plugin that adds the observers for the
Sliderwidget. - Slider
Precision - A component which controls the rounding of the slider value during dragging.
- Slider
Range - A component which represents the allowed range of the slider value. Defaults to 0.0..=1.0.
- Slider
Step - Defines the amount by which to increment or decrement the slider value when using keyboard shortcuts. Defaults to 1.0.
- Slider
Thumb - Marker component that identifies which descendant element is the slider thumb.
- Slider
Value - A component which stores the current value of the slider.
- Toggle
Checked - Event which can be triggered on a checkbox to toggle the checked state. This can be used to control the checkbox via gamepad buttons or other inputs.
- UiWidgets
Plugins - A plugin group that registers the observers for all of the widgets in this crate. If you don’t want to use all of the widgets, you can import the individual widget plugins instead.
- Value
Change - Notification sent by a widget that edits a scalar value.
Enums§
- Control
Orientation - Used to select the orientation of a scrollbar, slider, or other oriented control.
- Slider
Value Change - The type of slider value change to apply in
SetSliderValue. - Track
Click - Defines how the slider should behave when you click on the track (not the thumb).
Functions§
- checkbox_
self_ update - Observer function which updates the checkbox value in response to a
ValueChangeevent. This can be used to make the checkbox automatically update its own state when clicked, as opposed to managing the checkbox state externally. - observe
- Adds an observer as a bundle effect.
- slider_
self_ update - Observer function which updates the slider value in response to a
ValueChangeevent. This can be used to make the slider automatically update its own state when dragged, as opposed to managing the slider state externally.