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: virtual_list.rs
    path of file: ./repos/vizia/crates/vizia_core/src/views
    
    the code of the file until where you have to start completion: use std::ops::Range;

use crate::prelude::*;

#[derive(Lens)]
pub struct VirtualList {
    offset: usize,
    num_items: usize,
    item_height: f32,
    visible_items: Vec<usize>,
    scrolly: f32,
    scroll_to_cursor: bool,
    on_change: Option<Box<dyn Fn(&mut EventContext, Range<usize>)>>,
}

pub enum VirtualListEvent {
    SetNumItems(usize),
    SetScrollY(f32),
}

impl VirtualList {
    pub fn new<V: View, L, T>(
        cx: &mut Context,
        list: L,
        height: f32,
        item: impl Fn(&mut Context, usize, Index<L, T>) -> Handle<V> + 'static,
    ) -> Handle<Self>
    where
        L: Lens,
        <L as Lens>::Target: std::ops::Deref<Target = [T]>,
        T: Data +
    
    fn event(&mut self, cx: &mut EventContext, event: &mut Event) {
        event.map(|virtual_list_event, _| match virtual_list_event {
            VirtualListEvent::SetNumItems(num_items) => {
                if self.num_items != *num_items {
                    self.num_items = *num_items;
                    self.recalc(cx);
                    // Bit of a hack until scrollview is changed to take a lens for x/y
                    cx.emit_custom(
                        Event::new(ScrollEvent::SetY(0.0))
                            .propagate(Propagation::Subtree)
                            .origin(cx.current)
                            .target(cx.current),
                    );
                }
                // self.visible_items.clear();
                // for i in 0..*num_items {
                //     self.visible_items.push(i);
                // }
            }

            VirtualListEvent::SetScrollY(scrolly) => {
                self.scrolly = *scrolly;
                let current = cx.current();
                let dpi = cx.scale_factor();
                let container_height = cx.cache.get_height(current) / dpi;
                let total_height = self.num_items as f32 * self.item_height;
                let offsety = ((total_height - container_height) * *scrolly).round() * dpi;
                self.offset = (offsety / self.item_height / dpi).ceil() as usize;
                self.offset = self.offset.saturating_sub(1);

                let num_items =
                    ((container_height + self.item_height) / self.item_height).ceil() as usize;

                let start = self.offset;
                let end = (self.offset + num_items).clamp(0, self.num_items);
                self.visible_items.clear();
                for i in start..end {
                    self.visible_items.push(i);
                }

                if let Some(callback) = &self.on_change {
                    (callback)(cx, start..end)
                }
            }
        });

        event.map(|window_event, _| match window_event {
            WindowEvent::GeometryChanged(geo) => {
                if geo.contains(GeoChanged::WIDTH_CHANGED)
                    || geo.contains(GeoChanged::HEIGHT_CHANGED)
                {
                    self.recalc(cx);
                }
            }

            _ => {}
        });
    }