feat: use widget::image::Viewer to allow zooming and panning

This commit is contained in:
electria 2026-06-30 23:00:08 -07:00
commit e703be030e
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -1,7 +1,7 @@
use std::{env, ffi::OsStr, fs};
use iced::{
Color, Element, Renderer, Subscription, Task, Theme, color, event,
Color, Element, Length, Renderer, Subscription, Task, Theme, color, event,
keyboard::{self, Key, key},
theme, widget, window,
};
@ -52,7 +52,10 @@ impl State {
}
fn view(&self) -> Element<'_, Message, Theme, Renderer> {
if let Some(allocation) = self.image_display.as_ref() {
widget::image(allocation.handle()).expand(true).into()
widget::image::viewer(allocation.handle().clone())
.width(Length::Fill)
.height(Length::Fill)
.into()
} else {
widget::space().into()
}