RE ADD CONTEXT

This commit is contained in:
2025-12-15 21:50:53 -05:00
parent dc2be7f688
commit 0b8a93c5ce
39 changed files with 925 additions and 713 deletions

View File

@@ -5,21 +5,21 @@ pub struct Image {
handle: TextureHandle,
}
impl Widget for Image {
fn draw(&mut self, painter: &mut Painter) {
impl<State: 'static> Widget<State> for Image {
fn draw(&mut self, painter: &mut Painter<State>) {
painter.texture(&self.handle);
}
fn desired_width(&mut self, _: &mut SizeCtx) -> Len {
fn desired_width(&mut self, _: &mut SizeCtx<State>) -> Len {
Len::abs(self.handle.size().x)
}
fn desired_height(&mut self, _: &mut SizeCtx) -> Len {
fn desired_height(&mut self, _: &mut SizeCtx<State>) -> Len {
Len::abs(self.handle.size().y)
}
}
pub fn image(image: impl LoadableImage) -> impl WidgetFn<Image> {
pub fn image<State: 'static>(image: impl LoadableImage) -> impl WidgetFn<State, Image> {
let image = image.get_image().expect("Failed to load image");
move |ui| Image {
handle: ui.add_texture(image),