From 51f41ac9ee1bc8c03a7f3cc9657ff298436c03b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= Date: Fri, 7 Feb 2025 01:44:01 +0100 Subject: [PATCH] improv(preview_view): set max height for previews This sets the max height of the previews to THUMBNAIL_SIZE, to match text previews. Prevents the previews from becoming too large when the desktop details window is resized horizontally. --- src/app.rs | 5 ++++- src/tab.rs | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/app.rs b/src/app.rs index 6cd4596..8baf493 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1274,7 +1274,9 @@ impl App { } fn desktop_view_options(&self) -> Element { - let cosmic_theme::Spacing { space_l, .. } = theme::active().cosmic().spacing; + let cosmic_theme::Spacing { + space_m, space_l, .. + } = theme::active().cosmic().spacing; let config = self.config.desktop; let mut children = Vec::new(); @@ -1349,6 +1351,7 @@ impl App { widget::column::with_children(children) .padding([0, space_l, space_l, space_l]) + .spacing(space_m) .into() } diff --git a/src/tab.rs b/src/tab.rs index c73ef3f..46c0398 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -1400,11 +1400,11 @@ impl Item { let mut column = widget::column().spacing(space_m); - column = column.push(widget::row::with_children(vec![ - widget::horizontal_space().into(), - self.preview(sizes), - widget::horizontal_space().into(), - ])); + column = column.push( + widget::container(self.preview(sizes)) + .center_x(Length::Fill) + .max_height(THUMBNAIL_SIZE as f32), + ); let mut details = widget::column().spacing(space_xxxs); details = details.push(widget::text::heading(self.name.clone())); @@ -3922,15 +3922,13 @@ impl Tab { } Element::from(dnd_grid) }), - mouse_area::MouseArea::new( - widget::container(widget::column::with_children(children)).width(Length::Fill), - ) - .on_press(|_| Message::Click(None)) - .on_drag(Message::Drag) - .on_drag_end(|_| Message::DragEnd(None)) - .show_drag_rect(true) - .on_release(|_| Message::ClickRelease(None)) - .into(), + mouse_area::MouseArea::new(widget::column::with_children(children).width(Length::Fill)) + .on_press(|_| Message::Click(None)) + .on_drag(Message::Drag) + .on_drag_end(|_| Message::DragEnd(None)) + .show_drag_rect(true) + .on_release(|_| Message::ClickRelease(None)) + .into(), true, ) }