feat: filter method cycling

it doesn't work :(
This commit is contained in:
electria 2026-08-14 09:18:09 -07:00
commit 01f74bdf85
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -42,6 +42,8 @@ enum Message {
struct State { struct State {
images: BTreeMap<PathBuf, MaybeImage>, images: BTreeMap<PathBuf, MaybeImage>,
filter: widget::image::FilterMethod,
columns: usize, columns: usize,
key: usize, key: usize,
@ -53,10 +55,8 @@ impl State {
fn new() -> (Self, Task<Message>) { fn new() -> (Self, Task<Message>) {
( (
Self { Self {
images: BTreeMap::new(),
columns: 3, columns: 3,
key: 0, ..Default::default()
error: None,
}, },
Task::done(Message::OpenPath(Some( Task::done(Message::OpenPath(Some(
env::args() env::args()
@ -178,6 +178,13 @@ impl State {
self.columns = (self.columns - 1).clamp(1, 10) 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") => { keyboard::Key::Character("q") => {
return window::latest().and_then(window::close); return window::latest().and_then(window::close);
} }
@ -195,7 +202,7 @@ impl State {
widget::container( widget::container(
widget::sensor(maybe_image.handle().map_or_else( widget::sensor(maybe_image.handle().map_or_else(
|| Element::from(widget::space()), || Element::from(widget::space()),
|handle| widget::image(handle).into(), |handle| widget::image(handle).filter_method(self.filter).into(),
)) ))
.key(self.key) .key(self.key)
.anticipate(500) .anticipate(500)