use sfml::window::{Key, Event};
use sfml::graphics::{
    CircleShape, Color, Drawable, RectangleShape, RenderStates, RenderTarget, RenderWindow, Shape,
    Transformable,
};

pub struct Slider<'a> {
    value: f32,
    left_button: RectangleShape<'a>,
    right_button: RectangleShape<'a>,
}

impl<'a> Slider<'a> {

    pub fn new(y_position: f32, value: Option<f32>) -> Self {

        let val = match value {
            Some(v) => v,
            None => 0.0,
        };

        let mut slider = Slider {
            value: val,
            left_button: RectangleShape::new(),
            right_button: RectangleShape::new(),
        };

        slider.left_button.set_position((0.0,y_position));
        slider.right_button.set_position((50.0,y_position));

        slider.left_button.set_size((20.0, 30.0));
        slider.right_button.set_size((20.0, 30.0));

        slider.left_button.set_fill_color(&sfml::graphics::Color::GREEN);
        slider.right_button.set_fill_color(&sfml::graphics::Color::GREEN);

        slider
    }

}

impl<'s> Drawable for Slider<'s> {
    fn draw<'a: 'shader, 'texture, 'shader, 'shader_texture>(
        &'a self,
        render_target: &mut RenderTarget,
        _: RenderStates<'texture, 'shader, 'shader_texture>,
    ) {
        render_target.draw(&self.left_button);
        render_target.draw(&self.right_button)
    }
}