From 2eacdaeb8f6eca5dfbdd7812d50afdf549c29310 Mon Sep 17 00:00:00 2001 From: electria Date: Sun, 9 Aug 2026 13:31:06 -0700 Subject: [PATCH] feat: keybinds to change number of columns --- src/app/mod.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index d986140..4d51ac0 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -23,6 +23,8 @@ enum Message { struct State { images: HashMap>, + columns: usize, + error: Option, } @@ -36,6 +38,7 @@ impl State { builder.select("supportedImages"); Self { + columns: 3, error: None, images: WalkBuilder::new( env::args() @@ -87,6 +90,13 @@ impl State { }; } + keyboard::Key::Character("=" | "+") => { + self.columns = (self.columns + 1).clamp(1, 10) + } + keyboard::Key::Character("-" | "_") => { + self.columns = (self.columns - 1).clamp(1, 10) + } + keyboard::Key::Character("q") => { return window::latest().and_then(window::close); } @@ -98,8 +108,8 @@ impl State { } fn view(&self) -> Element<'_, Message, Theme, Renderer> { widget::column([ - widget::scrollable(widget::grid(self.images.iter().map( - |(path, opt_handle)| { + widget::scrollable( + widget::grid(self.images.iter().map(|(path, opt_handle)| { widget::button( widget::container( widget::sensor(opt_handle.as_ref().map_or_else( @@ -114,8 +124,9 @@ impl State { .style(widget::button::subtle) .on_press(Message::OpenImage(path.clone())) .into() - }, - ))) + })) + .columns(self.columns), + ) .height(Length::Fill) .into(), self.error