1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::widgets::{Widget, WidgetConfig};
use quicksilver::geom::Rectangle;
use quicksilver::graphics::Graphics;
use quicksilver::mint::Vector2;
use quicksilver::{lifecycle::Window, Result};
//use quicksilver::prelude::{Img, Rectangle, Transform, Vector, Window};
///A simple unfocusable, uninteractable image.
pub struct Image {
    ///name of the image that needs to be rendered
    pub image: quicksilver::graphics::Image,
    ///location and size that will be used to render the image
    pub location: Rectangle,
}
impl WidgetConfig<(), Image> for Image {
    fn to_widget(self) -> (Image, ()) {
        (self, ())
    }
}
impl Widget for Image {
    fn contains(&self, _: &Vector2<f32>) -> bool {
        false
    }
    fn is_focusable(&self, _: &Vector2<f32>) -> bool {
        false
    }
    fn render(&mut self, gfx: &mut Graphics, _: &Window) -> Result<()> {
        gfx.draw_image(&self.image, self.location);
        Ok(())
    }
}