feat(segmented-button): add maximum_button_width property
This commit is contained in:
parent
372fd4bab7
commit
2ccd3682b4
2 changed files with 7 additions and 1 deletions
|
|
@ -87,6 +87,8 @@ where
|
||||||
pub(super) button_height: u16,
|
pub(super) button_height: u16,
|
||||||
/// Spacing between icon and text in button.
|
/// Spacing between icon and text in button.
|
||||||
pub(super) button_spacing: u16,
|
pub(super) button_spacing: u16,
|
||||||
|
/// Maximum width of a button.
|
||||||
|
pub(super) maximum_button_width: u16,
|
||||||
/// Minimum width of a button.
|
/// Minimum width of a button.
|
||||||
pub(super) minimum_button_width: u16,
|
pub(super) minimum_button_width: u16,
|
||||||
/// Spacing for each indent.
|
/// Spacing for each indent.
|
||||||
|
|
@ -139,7 +141,8 @@ where
|
||||||
button_padding: [0, 0, 0, 0],
|
button_padding: [0, 0, 0, 0],
|
||||||
button_height: 32,
|
button_height: 32,
|
||||||
button_spacing: 0,
|
button_spacing: 0,
|
||||||
minimum_button_width: 150,
|
minimum_button_width: u16::MIN,
|
||||||
|
maximum_button_width: u16::MAX,
|
||||||
indent_spacing: 16,
|
indent_spacing: 16,
|
||||||
font_active: None,
|
font_active: None,
|
||||||
font_hovered: None,
|
font_hovered: None,
|
||||||
|
|
@ -368,6 +371,7 @@ where
|
||||||
|
|
||||||
// Add button padding to the max size found
|
// Add button padding to the max size found
|
||||||
width += f32::from(self.button_padding[0]) + f32::from(self.button_padding[2]);
|
width += f32::from(self.button_padding[0]) + f32::from(self.button_padding[2]);
|
||||||
|
width = width.min(f32::from(self.maximum_button_width));
|
||||||
|
|
||||||
(width, f32::from(self.button_height))
|
(width, f32::from(self.button_height))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ where
|
||||||
let space_xs = theme.cosmic().space_xs();
|
let space_xs = theme.cosmic().space_xs();
|
||||||
|
|
||||||
SegmentedButton::new(model)
|
SegmentedButton::new(model)
|
||||||
|
.minimum_button_width(76)
|
||||||
|
.maximum_button_width(250)
|
||||||
.button_height(44)
|
.button_height(44)
|
||||||
.button_padding([space_s, space_xs, space_s, space_xs])
|
.button_padding([space_s, space_xs, space_s, space_xs])
|
||||||
.style(crate::theme::SegmentedButton::TabBar)
|
.style(crate::theme::SegmentedButton::TabBar)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue