use crate::{
widgets::{Widget, WidgetConfig},
Assets,
};
use quicksilver::prelude::{Img, Rectangle, Transform, Vector, Window};
pub struct Image {
pub image: String,
pub location: Rectangle,
}
impl WidgetConfig<(), Image> for Image {
fn to_widget(self) -> (Image, ()) {
(self, ())
}
}
impl Widget for Image {
fn contains(&self, _: &Vector) -> bool {
false
}
fn is_focusable(&self, _: &Vector) -> bool {
false
}
fn render(&self, assets: &dyn Assets, window: &mut Window, z: u32) {
let image = assets.get_image(&self.image);
window.draw_ex(&self.location, Img(&image), Transform::IDENTITY, z);
}
}