From 01f74bdf852143f7b750a64486928a8aba7f6e06 Mon Sep 17 00:00:00 2001 From: electria Date: Fri, 14 Aug 2026 09:18:09 -0700 Subject: [PATCH] feat: filter method cycling it doesn't work :( --- src/app/mod.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index d4f5ced..b36c466 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -42,6 +42,8 @@ enum Message { struct State { images: BTreeMap, + filter: widget::image::FilterMethod, + columns: usize, key: usize, @@ -53,10 +55,8 @@ impl State { fn new() -> (Self, Task) { ( Self { - images: BTreeMap::new(), columns: 3, - key: 0, - error: None, + ..Default::default() }, Task::done(Message::OpenPath(Some( env::args() @@ -178,6 +178,13 @@ impl State { self.columns = (self.columns - 1).clamp(1, 10) } + keyboard::Key::Character("f") => { + self.filter = match self.filter { + widget::image::FilterMethod::Linear => widget::image::FilterMethod::Nearest, + widget::image::FilterMethod::Nearest => widget::image::FilterMethod::Linear, + } + } + keyboard::Key::Character("q") => { return window::latest().and_then(window::close); } @@ -195,7 +202,7 @@ impl State { widget::container( widget::sensor(maybe_image.handle().map_or_else( || Element::from(widget::space()), - |handle| widget::image(handle).into(), + |handle| widget::image(handle).filter_method(self.filter).into(), )) .key(self.key) .anticipate(500)