From fd7ddf7ff520fc52493480e929397faefeaf2469 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 5 Oct 2023 11:09:46 -0400 Subject: [PATCH] refactor: used FixedPortion for layout of the settings item This makes sure that the control always has at least the specified portion of the available space --- src/widget/settings/item.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/widget/settings/item.rs b/src/widget/settings/item.rs index d39e2a73..2ee928b3 100644 --- a/src/widget/settings/item.rs +++ b/src/widget/settings/item.rs @@ -8,6 +8,8 @@ use crate::{ Element, }; use derive_setters::Setters; +use iced_core::Length; +use iced_widget::container; /// A settings item aligned in a row #[must_use] @@ -70,15 +72,20 @@ impl<'a, Message: 'static> Item<'a, Message> { let column = column::with_capacity(2) .spacing(2) .push(text(self.title)) - .push(text(description).size(10)); + .push(text(description).size(10)) + .width(Length::FillPortion(12)); contents.push(column.into()); } else { contents.push(text(self.title).into()); } - contents.push(horizontal_space(iced::Length::Fill).into()); - contents.push(widget.into()); + contents.push( + container(widget.into()) + .width(Length::FillPortion(4)) + .align_x(iced_core::alignment::Horizontal::Right) + .into(), + ); item_row(contents) }