use roost_ui::events::OnEvent;
use roost_ui::drawable::Align;
use roost_ui::{Context, Component};
use roost_ui::layouts::Column;
use crate::interactions;
use crate::components::{Text, TextSize, ExpandableText, TextStyle, Circle, Rectangle};
use crate::plugin::PelicanUI;
#[derive(Debug, Component)]
pub struct Slider(Column, Option<Text>, Option<ExpandableText>, interactions::Slider); impl OnEvent for Slider {}
impl Slider {
pub fn new(
ctx: &mut Context,
start: f32,
label: Option<&str>,
description: Option<&str>,
on_change: impl FnMut(&mut Context, f32) + 'static,
) -> Self {
let colors = ctx.get::<PelicanUI>().get().0.theme().colors;
let background = Rectangle::new(colors.outline.primary, 3.0, None);
let foreground = Rectangle::new(colors.brand, 3.0, None);
let handle = Circle::new(18.0, colors.brand, false);
Slider(Column::start(8.0),
label.map(|l| Text::new(ctx, l, TextSize::H5, TextStyle::Heading, Align::Left, None)),
description.map(|t| ExpandableText::new(ctx, t, TextSize::Md, TextStyle::Primary, Align::Left, None)),
interactions::Slider::new(ctx, start, background, foreground, handle, on_change),
)
}
}