Crate bevy_aoui_widgets

Source
Expand description

UI, events and dsl for the bevy_aoui crate.

This crate does not have a stable API and subject to change.

§Event System

Since AoUI presumably sits on top of the bevy app, we provide an event system for detecting cursor activity exclusively for AoUI widgets. Cursor events not catched by our system can be handled by other systems.

We offer a component insertion based core event system for library developers as well as a oneshot system based event handler system for end users.

§Widgets

We currently offer a few simple widgets.

  • Shape: a vector shape renderer using bevy_prototype_lyon.
  • InputBox: a single line text input.
  • Button: a widget that provides click detection and propagation.

§DSL

We offer a DSL for streamlining widget construction.

Before you start, always import the prelude for syntax consistancy.

use bevy_aoui_widgets::dsl::prelude::*;

Each “widget” has a struct and its corresponding macro.

sprite! ((commands, ..) {
    dim: [400, 400],
    sprite: assets.load("Ferris.png"),
});

This translates to

Sprite {
    dim: [400, 400].dinto(),
    sprite: assets.load("Ferris.png").dinto(),
    ..Default::default(),
}.spawn_with(&mut commands);

Where dinto is our own Into, DslInto, where all the syntax magic happens.

Add children like so, notice you don’t need to manually pass in the context (commands, ..)

sprite! ((commands, ..) {
    dim: [400, 400],
    sprite: assets.load("Ferris.png"),
    child: textbox! {
        ...
    }
});

Check our our book or examples for more info.

Modules§

anim
dsl
events
widgets

Macros§

button
Construct a button.
circle
Construct a circle with bevy_prototype_lyon.
color
Color constrution macro, see colorthis.
compact
Construct a compact layout.
fixed_grid
Construct a fixed grid layout.
fixed_table
Construct a fixed table layout.
flex_table
Construct a flex table layout.
frame
Construct an empty sprite.
handler
Create a handler for a certain event.
hbox
Construct a horizotal left to right compact layout.
hspan
Construct a horizontal left to right span layout.
inputbox
Construct a textbox.
linebreak
Construct a dummy entity for linebreak in a layout.
marker
Construct marker components by name.
meta_dsl
The core macro for our DSL.
oneshot
Construct a oneshot event dynamically as a &'static OnceLock<SystemId>
paragraph
Construct a paragtaph layout.
rectangle
Construct a rectangle with bevy_prototype_lyon.
shape
Construct a shape with bevy_prototype_lyon.
size2
Construct a Size2 through CSS like syntax.
sized_grid
Construct a sized grid layout.
sized_table
Construct a sized table layout.
span
Construct a span layout.
sprite
Construct an image based sprite.
textbox
Construct a textbox.
vbox
Construct a vertical top to bottom compact layout.
vspan
Construct a vertical top to bottom span layout.
widget_extension
Create a widget extension based on the definition of Frame

Structs§

AoUIExtensionsPlugin
Plugin for both widgets and events.
Submit
Submit something that should be handled with serde.