diff --git a/examples/cosmic/src/window/demo.rs b/examples/cosmic/src/window/demo.rs index 72e53754..842e0c44 100644 --- a/examples/cosmic/src/window/demo.rs +++ b/examples/cosmic/src/window/demo.rs @@ -520,7 +520,7 @@ impl State { .on_input(Message::InputChanged) .into(), self.color_picker_model - .picker_button(Message::ColorPickerUpdate) + .picker_button(Message::ColorPickerUpdate, None) .width(Length::Fixed(128.0)) .height(Length::Fixed(128.0)) .into(), diff --git a/examples/design-demo b/examples/design-demo index 13b5a947..ed4af4e6 160000 --- a/examples/design-demo +++ b/examples/design-demo @@ -1 +1 @@ -Subproject commit 13b5a947df963232cafb938de62e81b1df0dbac8 +Subproject commit ed4af4e6431e30702f6de8031f3a3a11b82da3f0 diff --git a/src/widget/color_picker/mod.rs b/src/widget/color_picker/mod.rs index cf700332..e4348f1e 100644 --- a/src/widget/color_picker/mod.rs +++ b/src/widget/color_picker/mod.rs @@ -122,10 +122,12 @@ impl ColorPickerModel { pub fn picker_button<'a, Message: 'static, T: Fn(ColorPickerUpdate) -> Message>( &self, f: T, + icon_portion: Option, ) -> crate::widget::Button<'a, Message, crate::Renderer> { color_button( Some(f(ColorPickerUpdate::ToggleColorPicker)), self.applied_color, + Length::FillPortion(icon_portion.unwrap_or(12)), ) } @@ -358,7 +360,8 @@ where .leading_icon( color_button( None, - Some(Color::from(palette::Srgb::from_color(self.active_color))) + Some(Color::from(palette::Srgb::from_color(self.active_color))), + Length::FillPortion(12) ) .into() ) @@ -415,6 +418,7 @@ where color_button( Some(on_update(ColorPickerUpdate::ActiveColor(hsv))), Some(*c), + Length::FillPortion(12), ) .into() }) @@ -744,6 +748,7 @@ fn color_to_string(c: palette::Hsv, is_hex: bool) -> String { fn color_button<'a, Message: 'static>( on_press: Option, color: Option, + icon_portion: Length, ) -> crate::widget::Button<'a, Message, crate::Renderer> { let spacing = THEME.with(|t| t.borrow().cosmic().spacing); @@ -751,27 +756,23 @@ fn color_button<'a, Message: 'static>( Element::from(vertical_space(Length::Fixed(f32::from(spacing.space_s)))) } else { Element::from(column![ - vertical_space(Length::FillPortion(1)), - vertical_space(Length::FillPortion(1)), + vertical_space(Length::FillPortion(6)), row![ - horizontal_space(Length::FillPortion(1)), - horizontal_space(Length::FillPortion(1)), + horizontal_space(Length::FillPortion(6)), Icon::from( icon::from_name("list-add-symbolic") .prefer_svg(true) .symbolic(true) .size(64) ) - .width(Length::FillPortion(2)) + .width(icon_portion) .height(Length::Fill) .content_fit(iced_core::ContentFit::Contain), - horizontal_space(Length::FillPortion(1)), - horizontal_space(Length::FillPortion(1)), + horizontal_space(Length::FillPortion(6)), ] - .height(Length::FillPortion(2)) + .height(icon_portion) .width(Length::Fill), - vertical_space(Length::FillPortion(1)), - vertical_space(Length::FillPortion(1)), + vertical_space(Length::FillPortion(6)), ]) }) .width(Length::Fixed(f32::from(spacing.space_s)))