Begin work on a rotator UI

This commit is contained in:
2025-08-25 18:07:53 -05:00
parent e362df8682
commit 45e44ef8b1
2 changed files with 47 additions and 5 deletions

View File

@@ -21,7 +21,11 @@ fn main() {
.register_type::<resources::UiTheme>() .register_type::<resources::UiTheme>()
.add_systems( .add_systems(
Startup, Startup,
(setup, assets::load_assets, widgets::spawn_cutter_machine_ui), (
setup,
assets::load_assets,
widgets::spawn_rotator_machine_ui,
),
) )
.run(); .run();
} }

View File

@@ -44,7 +44,46 @@ pub fn spawn_cutter_machine_ui(mut commands: Commands) {
BackgroundColor(DARK_GRAY.into()), BackgroundColor(DARK_GRAY.into()),
Pickable::default(), Pickable::default(),
)) ))
.with_children(spawn_machine_button); .with_children(|cmds| spawn_machine_button(cmds, "CUT"));
});
}
pub fn spawn_rotator_machine_ui(mut commands: Commands) {
commands
.spawn((machine_ui_base("Rotating Machine"),))
.with_children(|commands| {
commands.spawn((
Node {
padding: UiRect::all(Px(10.0)),
..Default::default()
},
BackgroundColor(GREEN.into()),
Pickable::default(),
children![(Text::new("Uses: <n>"), TextColor(BLACK.into()))],
));
// Center panel (placeholder for input-output rotation)
commands.spawn((
Node::default(),
BackgroundColor(BLUE.into()),
Pickable::default(),
children![
Text::new("Card rotation side-by-side placeholder"),
TextColor(MAGENTA.into()),
]
));
// Right panel for the rotation controls
commands
.spawn((
Node {
align_items: AlignItems::End,
..Default::default()
},
BackgroundColor(DARK_GRAY.into()),
Pickable::default(),
))
.with_children(|cmds| spawn_machine_button(cmds, "TURN"));
}); });
} }
@@ -94,9 +133,8 @@ fn machine_ui_base(header: impl Into<String>) -> impl Bundle {
) )
} }
// TODO: Pass in button text
// TODO: Hook up action handling (callback? Observer? Some other weird component?) // TODO: Hook up action handling (callback? Observer? Some other weird component?)
fn spawn_machine_button(commands: &mut ChildSpawnerCommands) { fn spawn_machine_button(commands: &mut ChildSpawnerCommands, text: impl Into<String>) {
let mut builder = commands.spawn(( let mut builder = commands.spawn((
Button, Button,
Node { Node {
@@ -116,7 +154,7 @@ fn spawn_machine_button(commands: &mut ChildSpawnerCommands) {
BorderColor(DARK_RED.into()), BorderColor(DARK_RED.into()),
BorderRadius::MAX, BorderRadius::MAX,
children![ children![
Text::new("CUT"), Text::new(text),
TextColor(WHITE.into()), TextColor(WHITE.into()),
TextShadow::default(), TextShadow::default(),
], ],