fn draw(&mut self, widget_id: u32, c: &mut Canvas<Window>) {
        match &mut self.cache[widget_id as usize] {
            SystemWidget::Base(ref mut widget) => {
                let widget_origin = *widget.get_origin();
                let widget_size = *widget.get_size();

                eprintln!(
                    "[WidgetCache::draw] Base: Drawing ID {} to x {} y {} w {} h {}",
                    widget_id, widget_origin.x, widget_origin.y, widget_size.w, widget_size.h
                );

                match widget.draw(c) {
                    Some(texture) => c
                        .copy(texture, None, make_rect(widget_origin, widget_size))
                        .unwrap(),

                    None => eprintln!("[WidgetCache::draw] BASE: No texture presented."),
                };

                widget.set_invalidated(false);
            }

            SystemWidget::Box(ref mut widget) => {
                let widget_origin = *widget.get_origin();
                let widget_size = *widget.get_size();

                eprintln!(
                    "[WidgetCache::draw] Box: Drawing ID {} to x {} y {} w {} h {}",
                    widget_id, widget_origin.x, widget_origin.y, widget_size.w, widget_size.h
                );

                match widget.draw(c) {
                    Some(texture) => c
                        .copy(texture, None, make_rect(widget_origin, widget_size))
                        .unwrap(),

                    None => eprintln!("[WidgetCache::draw] BOX: No texture presented."),
                };

                widget.set_invalidated(false);
            }

            SystemWidget::Button(ref mut widget) => {
                let widget_origin = *widget.get_origin();
                let widget_size = *widget.get_size();

                eprintln!(
                    "[WidgetCache::draw] Button: Drawing ID {} to x {} y {} w {} h {}",
                    widget_id, widget_origin.x, widget_origin.y, widget_size.w, widget_size.h
                );

                match widget.draw(c) {
                    Some(texture) => c
                        .copy(texture, None, make_rect(widget_origin, widget_size))
                        .unwrap(),

                    None => eprintln!("[WidgetCache::draw] BUTTON: No texture presented."),
                };

                widget.set_invalidated(false);
            }

            _default => {
                // Do nothing
                eprintln!("[WidgetCache::draw] I'm sent a widget that I can't draw yet!");
            }
        }
    }
/// Draws an object to the screen by calling a `Widget`'s draw function, which draws to a
/// `TextureStore`.  Once the `TextureStore` has been rendered, it is copied to the
/// `Canvas` at the widget's origin and size coordinates.
Draws an object to the screen by calling a `Widget`'s draw function, which draws to a
`TextureStore`.  Once the `TextureStore` has been rendered, it is copied to the
`Canvas` at the widget's origin and size coordinates.
Draws an object to the screen by calling a ` Widget ` ' s draw function which draws to a ` TextureStore ` . Once the ` TextureStore ` has been rendered it is copied to the ` Canvas ` at the widget ' s origin and size coordinates .
fn draw(&mut self, widget_id: u32, c: &mut Canvas<Window>) {
        match &mut self.cache[widget_id as usize] {
            SystemWidget::Base(ref mut widget) => {
                let widget_origin = *widget.get_origin();
                let widget_size = *widget.get_size();
                eprintln!(
                    "[WidgetCache::draw] Base: Drawing ID {} to x {} y {} w {} h {}",
                    widget_id, widget_origin.x, widget_origin.y, widget_size.w, widget_size.h
                );
                match widget.draw(c) {
                    Some(texture) => c
                        .copy(texture, None, make_rect(widget_origin, widget_size))
                        .unwrap(),
                    None => eprintln!("[WidgetCache::draw] BASE: No texture presented."),
                };
                widget.set_invalidated(false);
            }
            SystemWidget::Box(ref mut widget) => {
                let widget_origin = *widget.get_origin();
                let widget_size = *widget.get_size();
                eprintln!(
                    "[WidgetCache::draw] Box: Drawing ID {} to x {} y {} w {} h {}",
                    widget_id, widget_origin.x, widget_origin.y, widget_size.w, widget_size.h
                );
                match widget.draw(c) {
                    Some(texture) => c
                        .copy(texture, None, make_rect(widget_origin, widget_size))
                        .unwrap(),
                    None => eprintln!("[WidgetCache::draw] BOX: No texture presented."),
                };
                widget.set_invalidated(false);
            }
            SystemWidget::Button(ref mut widget) => {
                let widget_origin = *widget.get_origin();
                let widget_size = *widget.get_size();
                eprintln!(
                    "[WidgetCache::draw] Button: Drawing ID {} to x {} y {} w {} h {}",
                    widget_id, widget_origin.x, widget_origin.y, widget_size.w, widget_size.h
                );
                match widget.draw(c) {
                    Some(texture) => c
                        .copy(texture, None, make_rect(widget_origin, widget_size))
                        .unwrap(),
                    None => eprintln!("[WidgetCache::draw] BUTTON: No texture presented."),
                };
                widget.set_invalidated(false);
            }
            _default => {
                // Do nothing
                eprintln!("[WidgetCache::draw] I'm sent a widget that I can't draw yet!");
            }
        }
    }
fn draw ( & mut self , widget_id : u32 , c : & mut Canvas < Window > ) { match & mut self . cache [ widget_id as usize ] { SystemWidget :: Base ( ref mut widget ) => { let widget_origin = * widget . get_origin ( ) ; let widget_size = * widget . get_size ( ) ; eprintln ! ( " " widget_id widget_origin x widget_origin y widget_size w widget_size h ) ; match widget . draw ( c ) { Some ( texture ) => c . copy ( texture , None , make_rect ( widget_origin , widget_size ) ) . unwrap ( ) , None => eprintln ! ( " " ) , } ; widget . set_invalidated ( false ) ; } SystemWidget :: Box ( ref mut widget ) => { let widget_origin = * widget . get_origin ( ) ; let widget_size = * widget . get_size ( ) ; eprintln ! ( " " widget_id widget_origin x widget_origin y widget_size w widget_size h ) ; match widget . draw ( c ) { Some ( texture ) => c . copy ( texture , None , make_rect ( widget_origin , widget_size ) ) . unwrap ( ) , None => eprintln ! ( " " ) , } ; widget . set_invalidated ( false ) ; } SystemWidget :: Button ( ref mut widget ) => { let widget_origin = * widget . get_origin ( ) ; let widget_size = * widget . get_size ( ) ; eprintln ! ( " " widget_id widget_origin x widget_origin y widget_size w widget_size h ) ; match widget . draw ( c ) { Some ( texture ) => c . copy ( texture , None , make_rect ( widget_origin , widget_size ) ) . unwrap ( ) , None => eprintln ! ( " " ) , } ; widget . set_invalidated ( false ) ; } _default => { // Do nothing eprintln ! ( " " ) ; } } }
Draws an object to the screen by calling a `Widget`'s draw function, which draws to a
`TextureStore`.
Draws an object to the screen by calling a ` Widget ` ' s draw function which draws to a ` TextureStore ` .
&mut self
widget_id
u32
c
&mut Canvas<Window>
&mut self
widget_id
u32
c
&mut Canvas<Window>