You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: scrollbar.rs
    path of file: ./repos/vizia/crates/vizia_core/src/views
    
    the code of the file until where you have to start completion: use crate::context::TreeProps;
use crate::prelude::*;
use crate::views::Orientation;

pub struct Scrollbar<L1> {
    value: L1,
    orientation: Orientation,

    reference_points: Option<(f32, f32)>,
    dragging: bool,

    on_changing: Option<Box<dyn Fn(&mut EventContext, f32)>>,

    scroll_to_cursor: bool,
}

enum ScrollBarEvent {
    SetScrollToCursor(bool),
}

impl<L1: Lens<Target = f32>> Scrollbar<L1> {
    pub fn new<F, L2: Lens<Target = f32>>(
        cx: &
    
    fn event(&mut self, cx: &mut EventContext, event: &mut Event) {
        event.map(|scrollbar_event, _| match scrollbar_event {
            ScrollBarEvent::SetScrollToCursor(flag) => {
                self.scroll_to_cursor = *flag;
            }
        });

        event.map(|window_event, meta| {
            let pos = match &self.orientation {
                Orientation::Horizontal => cx.mouse.cursorx,
                Orientation::Vertical => cx.mouse.cursory,
            };
            match window_event {
                WindowEvent::MouseDown(MouseButton::Left) => {
                    if meta.target != cx.current() {
                        self.reference_points = Some((pos, self.value.get(cx)));
                        cx.capture();
                        cx.set_active(true);
                        self.dragging = true;
                        cx.with_current(Entity::root(), |cx| {
                            cx.set_pointer_events(false);
                        });
                    } else if self.scroll_to_cursor {
                        cx.capture();
                        cx.set_active(true);
                        self.dragging = true;
                        cx.with_current(Entity::root(), |cx| {
                            cx.set_pointer_events(false);
                        });
                        let thumb_bounds = self.thumb_bounds(cx);
                        let bounds = cx.bounds();
                        let sx = bounds.w - thumb_bounds.w;
                        let sy = bounds.h - thumb_bounds.h;
                        match self.orientation {
                            Orientation::Horizontal => {
                                let px = cx.mouse.cursorx - cx.bounds().x - thumb_bounds.w / 2.0;
                                let x = (px / sx).clamp(0.0, 1.0);
                                if let Some(callback) = &self.on_changing {
                                    (callback)(cx, x);
                                }
                            }

                            Orientation::Vertical => {
                                let py = cx.mouse.cursory - cx.bounds().y - thumb_bounds.h / 2.0;
                                let y = (py / sy).clamp(0.0, 1.0);
                                if let Some(callback) = &self.on_changing {
                                    (callback)(cx, y);
                                }
                            }
                        }
                    } else {
                        let (_, jump) = self.container_and_thumb_size(cx);
                        // let (tx, ty, tw, th) = self.thumb_bounds(cx);
                        let t = self.thumb_bounds(cx);
                        let physical_delta = match &self.orientation {
                            Orientation::Horizontal => {
                                if cx.mouse.cursorx < t.x {
                                    -jump
                                } else if cx.mouse.cursorx >= t.x + t.w {
                                    jump
                                } else {
                                    return;
                                }
                            }
                            Orientation::Vertical => {
                                if cx.mouse.cursory < t.y {
                                    -jump
                                } else if cx.mouse.cursory >= t.y + t.h {
                                    jump
                                } else {
                                    return;
                                }
                            }
                        };
                        let changed =
                            self.compute_new_value(cx, physical_delta, self.value.get(cx));
                        self.change(cx, changed);
                    }
                }

                WindowEvent::MouseUp(MouseButton::Left) => {
                    self.reference_points = None;
                    cx.focus_with_visibility(false);
                    cx.release();
                    cx.set_active(false);
                    self.dragging = false;
                    cx.with_current(Entity::root(), |cx| {
                        cx.set_pointer_events(true);
                    });
                }

                WindowEvent::MouseMove(_, _) => {
                    if self.dragging {
                        if let Some((mouse_ref, value_ref)) = self.reference_points {
                            let physical_delta = pos - mouse_ref;
                            let changed = self.compute_new_value(cx, physical_delta, value_ref);
                            self.change(cx, changed);
                        } else if self.scroll_to_cursor {
                            let thumb_bounds = self.thumb_bounds(cx);
                            let bounds = cx.bounds();
                            let sx = bounds.w - thumb_bounds.w;
                            let sy = bounds.h - thumb_bounds.h;
                            match self.orientation {
                                Orientation::Horizontal => {
                                    let px =
                                        cx.mouse.cursorx - cx.bounds().x - thumb_bounds.w / 2.0;
                                    let x = (px / sx).clamp(0.0, 1.0);
                                    if let Some(callback) = &self.on_changing {
                                        (callback)(cx, x);
                                    }
                                }

                                Orientation::Vertical => {
                                    let py =
                                        cx.mouse.cursory - cx.bounds().y - thumb_bounds.h / 2.0;
                                    let y = (py / sy).clamp(0.0, 1.0);
                                    if let Some(callback) = &self.on_changing {
                                        (callback)(cx, y);
                                    }
                                }
                            }
                        }
                    }
                }

                _ => {}
            }
        });
    }