feat: f to switch FilterMethod

useful to scale pixelart images nicely.

This makes me consider expanding the status bar to include info;
partially because I don't use window decorations usually
(so I don't see the info in the title)
This commit is contained in:
electria 2026-07-30 19:19:23 -07:00
commit f279c3aa15
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -20,6 +20,7 @@ enum Message {
struct State { struct State {
image: Option<RgbaImage>, image: Option<RgbaImage>,
image_display: Option<widget::image::Allocation>, image_display: Option<widget::image::Allocation>,
image_filter: widget::image::FilterMethod,
error: Option<String>, error: Option<String>,
} }
@ -40,6 +41,7 @@ impl State {
widget::column([ widget::column([
if let Some(allocation) = self.image_display.as_ref() { if let Some(allocation) = self.image_display.as_ref() {
widget::image::viewer(allocation.handle().clone()) widget::image::viewer(allocation.handle().clone())
.filter_method(self.image_filter)
.width(Length::Fill) .width(Length::Fill)
.height(Length::Fill) .height(Length::Fill)
.into() .into()
@ -107,6 +109,12 @@ impl State {
} }
}; };
} }
Key::Character("f") => {
self.image_filter = match self.image_filter {
widget::image::FilterMethod::Linear => widget::image::FilterMethod::Nearest,
widget::image::FilterMethod::Nearest => widget::image::FilterMethod::Linear,
}
}
Key::Character("s") => { Key::Character("s") => {
self.save_image(); self.save_image();