Crate bevy_ui_widgets

Crate bevy_ui_widgets 

Source
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 Activate event when the button is un-pressed.
ButtonPlugin
Plugin that adds the observers for the Button widget.
Checkbox
Headless widget implementation for checkboxes. The Checked component represents the current state of the checkbox. The widget will emit a ValueChange<bool> event when clicked, or when the Enter or Space key is pressed while the checkbox is focused.
CheckboxPlugin
Plugin that adds the observers for the Checkbox widget.
CoreScrollbarDragState
Component used to manage the state of a scrollbar during dragging. This component is inserted on the thumb entity.
CoreScrollbarThumb
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.
CoreSliderDragState
Component used to manage the state of a slider during dragging.
RadioButton
Headless widget implementation for radio buttons. These should be enclosed within a RadioGroup widget, which is responsible for the mutual exclusion logic.
RadioGroup
Headless widget implementation for a “radio button group”. This component is used to group multiple RadioButton components together, allowing them to behave as a single unit. It implements the tab navigation logic and keyboard shortcuts for radio buttons.
RadioGroupPlugin
Plugin that adds the observers for the RadioGroup widget.
Scrollbar
A headless scrollbar widget, which can be used to build custom scrollbars.
ScrollbarPlugin
Plugin that adds the observers for the Scrollbar widget.
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.
SetSliderValue
An EntityEvent that can be triggered on a slider to modify its value (using the on_change callback). 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 SliderValue component) and a range (represented by SliderRange). An optional step size can be specified via SliderStep, and you can control the rounding during dragging with SliderPrecision.
SliderPlugin
Plugin that adds the observers for the Slider widget.
SliderPrecision
A component which controls the rounding of the slider value during dragging.
SliderRange
A component which represents the allowed range of the slider value. Defaults to 0.0..=1.0.
SliderStep
Defines the amount by which to increment or decrement the slider value when using keyboard shortcuts. Defaults to 1.0.
SliderThumb
Marker component that identifies which descendant element is the slider thumb.
SliderValue
A component which stores the current value of the slider.
ToggleChecked
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.
UiWidgetsPlugins
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.
ValueChange
Notification sent by a widget that edits a scalar value.

Enums§

ControlOrientation
Used to select the orientation of a scrollbar, slider, or other oriented control.
SliderValueChange
The type of slider value change to apply in SetSliderValue.
TrackClick
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 ValueChange event. 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 ValueChange event. This can be used to make the slider automatically update its own state when dragged, as opposed to managing the slider state externally.