diff --git a/bin/ui-wtf.rs b/bin/ui-wtf.rs index 066512e..d46734a 100644 --- a/bin/ui-wtf.rs +++ b/bin/ui-wtf.rs @@ -18,175 +18,11 @@ fn main() { )) // .init_resource::() .add_systems(Startup, init_ui2) - .add_systems(Update, toggle) - .add_systems(PostUpdate, selection) // .add_systems(Startup, init_ui) // .add_systems(Update, (cursors, container)) .run(); } -#[derive(Debug, Bundle)] -struct UiKitContainer { - node_bundle: NodeBundle, - select: Select, -} - -#[derive(Copy, Clone)] -enum UiKitPosition { - Top, - Left, - Right, -} - -impl UiKitContainer { - fn new(position: UiKitPosition) -> Self { - let style = match position { - UiKitPosition::Top => Style { - border: UiRect::all(Val::Px(1.0)), - top: Val::Percent(102.0), - left: Val::Px(-2.0), - flex_direction: FlexDirection::Column, - align_items: AlignItems::FlexStart, - display: Display::None, - ..default() - }, - UiKitPosition::Left => Style { - border: UiRect::all(Val::Px(1.0)), - left: Val::Percent(100.0), - top: Val::Px(-2.0), - flex_direction: FlexDirection::Column, - justify_items: JustifyItems::Start, - display: Display::None, - ..default() - }, - UiKitPosition::Right => Style { - border: UiRect::all(Val::Px(1.0)), - right: Val::Percent(104.0), - top: Val::Px(-2.0), - flex_direction: FlexDirection::Column, - justify_items: JustifyItems::Start, - display: Display::None, - ..default() - }, - }; - UiKitContainer { - node_bundle: NodeBundle { - style, - background_color: BackgroundColor(Color::PURPLE), - border_color: BorderColor(Color::BLACK), - ..default() - }, - select: Select::None, - } - } -} - -#[derive(Debug, Bundle)] -struct UiKitButton { - button_bundle: ButtonBundle, - select: Select, -} - -impl UiKitButton { - fn new(color: Color) -> Self { - UiKitButton { - button_bundle: ButtonBundle { - style: Style { - border: UiRect::all(Val::Px(1.0)), - width: Val::Px(100.0), - height: Val::Px(50.0), - flex_direction: FlexDirection::Column, - ..default() - }, - background_color: BackgroundColor(color), - border_color: BorderColor(Color::BLACK), - ..default() - }, - select: Select::None, - } - } -} - -#[derive(Debug, Component, Copy, Clone)] -enum Select { - Active, - None, -} - -/// When an item is selected/de-selected change it's display accordingly -fn selection( - mut events: Query<(&mut BackgroundColor, &Select, &Children), (Changed