Make grid sizing strategy explicit and more intuitive

This commit is contained in:
Héctor Ramón Jiménez 2025-04-10 15:39:10 +02:00
parent 504d9c2959
commit 687750e026
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 74 additions and 28 deletions

View file

@ -22,6 +22,10 @@ use std::collections::HashMap;
fn main() -> iced::Result {
iced::application(Gallery::new, Gallery::update, Gallery::view)
.window_size((
Preview::WIDTH as f32 * 4.0,
Preview::HEIGHT as f32 * 2.5,
))
.subscription(Gallery::subscription)
.theme(Gallery::theme)
.run()
@ -183,7 +187,7 @@ impl Gallery {
let gallery = grid(images)
.fluid(Preview::WIDTH)
.ratio(Preview::WIDTH as f32 / Preview::HEIGHT as f32)
.height(grid::aspect_ratio(Preview::WIDTH, Preview::HEIGHT))
.spacing(10);
let content = container(scrollable(gallery).spacing(10)).padding(10);
@ -225,7 +229,7 @@ fn card<'a>(
horizontal_space().into()
};
let card = mouse_area(container(image).height(Fill).style(container::dark))
let card = mouse_area(container(image).style(container::dark))
.on_enter(Message::ThumbnailHovered(metadata.id, true))
.on_exit(Message::ThumbnailHovered(metadata.id, false));
@ -245,10 +249,7 @@ fn card<'a>(
}
fn placeholder<'a>() -> Element<'a, Message> {
container(horizontal_space())
.height(Fill)
.style(container::dark)
.into()
container(horizontal_space()).style(container::dark).into()
}
enum Preview {