From 45e44ef8b1e67e82421d8c5f2bfb550735e8a4c2 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Mon, 25 Aug 2025 18:07:53 -0500 Subject: [PATCH] Begin work on a rotator UI --- src/main.rs | 6 +++++- src/widgets.rs | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2cf466b..14c8c06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,11 @@ fn main() { .register_type::() .add_systems( Startup, - (setup, assets::load_assets, widgets::spawn_cutter_machine_ui), + ( + setup, + assets::load_assets, + widgets::spawn_rotator_machine_ui, + ), ) .run(); } diff --git a/src/widgets.rs b/src/widgets.rs index fd08390..80d5cc3 100644 --- a/src/widgets.rs +++ b/src/widgets.rs @@ -44,7 +44,46 @@ pub fn spawn_cutter_machine_ui(mut commands: Commands) { BackgroundColor(DARK_GRAY.into()), 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: "), 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) -> impl Bundle { ) } -// TODO: Pass in button text // 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) { let mut builder = commands.spawn(( Button, Node { @@ -116,7 +154,7 @@ fn spawn_machine_button(commands: &mut ChildSpawnerCommands) { BorderColor(DARK_RED.into()), BorderRadius::MAX, children![ - Text::new("CUT"), + Text::new(text), TextColor(WHITE.into()), TextShadow::default(), ],