Compare commits
3 Commits
9fb374059a
...
9411e57759
| Author | SHA1 | Date | |
|---|---|---|---|
| 9411e57759 | |||
| a489cdc5e8 | |||
| 5f617a67f6 |
@@ -36,7 +36,7 @@ pub struct UiTheme {
|
||||
}
|
||||
|
||||
impl FromWorld for UiTheme {
|
||||
fn from_world(world: &mut World) -> Self {
|
||||
fn from_world(_world: &mut World) -> Self {
|
||||
Self {
|
||||
pane_bg: SLATE_100.into(),
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ impl RotatingMachine {
|
||||
Pickable::default(),
|
||||
))
|
||||
.with_children(|cmds| {
|
||||
let button_cmds = cmds.spawn(BigRedButton::bundle("TURN"));
|
||||
let _button_cmds = cmds.spawn(BigRedButton::bundle("TURN"));
|
||||
// TODO: Attach on-press observer to the button.
|
||||
});
|
||||
});
|
||||
|
||||
@@ -95,8 +95,11 @@ impl BigRedButton {
|
||||
///
|
||||
/// I haven't figure out what will receive the on-press events, so I'm moving
|
||||
/// the problem. It will not be the button's job to hook up the event notice.
|
||||
///
|
||||
/// TODO: Pass in the UiTheme struct
|
||||
fn bundle(text: impl Into<String>) -> impl Bundle {
|
||||
(
|
||||
// TODO: Remove `Button`? Add `Button` to the `CloseButton` bundle?
|
||||
Button,
|
||||
BigRedButton,
|
||||
Node {
|
||||
@@ -182,8 +185,11 @@ pub struct CloseButton(Entity);
|
||||
|
||||
impl CloseButton {
|
||||
/// Spawn a button that will despawn the top-most node when pressed.
|
||||
///
|
||||
/// TODO: Pass in the UiTheme struct
|
||||
fn bundle(target: Entity) -> impl Bundle {
|
||||
(
|
||||
// TODO: Add `Button`? Remove `Button` from the BigRedButton bundle?
|
||||
CloseButton(target),
|
||||
Node {
|
||||
width: Px(20.0),
|
||||
@@ -208,7 +214,7 @@ impl CloseButton {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn hover_start(
|
||||
fn hover_start(
|
||||
event: Trigger<Pointer<Over>>,
|
||||
// Get button background and border colors so we can change them.
|
||||
// Filter for *changed* interactions, and only entities with a [`Button`]
|
||||
@@ -222,7 +228,7 @@ impl CloseButton {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hover_stop(
|
||||
fn hover_stop(
|
||||
event: Trigger<Pointer<Out>>,
|
||||
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<CloseButton>>,
|
||||
ui_theme: Res<UiTheme>,
|
||||
@@ -233,7 +239,7 @@ impl CloseButton {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn press_start(
|
||||
fn press_start(
|
||||
event: Trigger<Pointer<Pressed>>,
|
||||
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<CloseButton>>,
|
||||
ui_theme: Res<UiTheme>,
|
||||
@@ -244,7 +250,7 @@ impl CloseButton {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn press_stop(
|
||||
fn press_stop(
|
||||
event: Trigger<Pointer<Released>>,
|
||||
mut commands: Commands,
|
||||
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor, &CloseButton)>,
|
||||
|
||||
Reference in New Issue
Block a user