zuma-like/src/ui/spawners/slider.rs

36 lines
877 B
Rust
Raw Normal View History

2026-04-10 20:28:55 +03:00
use bevy::prelude::*;
pub fn spawn_slider(
commands: &mut Commands,
root: Entity,
){
let slider = commands
.spawn((
Node {
display: Display::Flex,
width: Val::Percent(30.0),
height: Val::Percent(3.0),
border: UiRect{
left: Val::Px(2.0),
right: Val::Px(2.0),
top: Val::Px(2.0),
bottom: Val::Px(2.0),
},
..default()
},
BackgroundColor(Color::srgb_u8(216, 223, 233)),
)).id();
let thumb = commands.spawn((
Node{
height: Val::Percent(100.0),
aspect_ratio: Some(1.0),
..default()
},
BackgroundColor(Color::srgb_u8(1, 226, 106)),
)).id();
commands.entity(slider).add_child(thumb);
commands.entity(root).add_child(slider);
}