diff options
author | 2019-12-09 21:59:31 +0100 | |
---|---|---|
committer | 2019-12-09 21:59:31 +0100 | |
commit | c1b9f6652517dcbf5ffd83b5db4a624f9a5b0da4 (patch) | |
tree | 40250d83f761f10352ba7bf26a801a415c8da452 /native/src/widget/button.rs | |
parent | f942fc3b68ecbbe136c54922109c7e2e4732735b (diff) | |
download | iced-c1b9f6652517dcbf5ffd83b5db4a624f9a5b0da4.tar.gz iced-c1b9f6652517dcbf5ffd83b5db4a624f9a5b0da4.tar.bz2 iced-c1b9f6652517dcbf5ffd83b5db4a624f9a5b0da4.zip |
Add `Button::height` and `Button::min_height`
Diffstat (limited to 'native/src/widget/button.rs')
-rw-r--r-- | native/src/widget/button.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index 3348c58c..67b49dc6 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -33,7 +33,9 @@ pub struct Button<'a, Message, Renderer> { content: Element<'a, Message, Renderer>, on_press: Option<Message>, width: Length, + height: Length, min_width: u32, + min_height: u32, padding: u16, background: Option<Background>, border_radius: u16, @@ -54,7 +56,9 @@ impl<'a, Message, Renderer> Button<'a, Message, Renderer> { content: content.into(), on_press: None, width: Length::Shrink, + height: Length::Shrink, min_width: 0, + min_height: 0, padding: 0, background: None, border_radius: 0, @@ -69,6 +73,14 @@ impl<'a, Message, Renderer> Button<'a, Message, Renderer> { self } + /// Sets the height of the [`Button`]. + /// + /// [`Button`]: struct.Button.html + pub fn height(mut self, height: Length) -> Self { + self.height = height; + self + } + /// Sets the minimum width of the [`Button`]. /// /// [`Button`]: struct.Button.html @@ -77,6 +89,14 @@ impl<'a, Message, Renderer> Button<'a, Message, Renderer> { self } + /// Sets the minimum height of the [`Button`]. + /// + /// [`Button`]: struct.Button.html + pub fn min_height(mut self, min_height: u32) -> Self { + self.min_height = min_height; + self + } + /// Sets the padding of the [`Button`]. /// /// [`Button`]: struct.Button.html @@ -139,7 +159,7 @@ where } fn height(&self) -> Length { - Length::Shrink + self.height } fn layout( @@ -150,8 +170,9 @@ where let padding = f32::from(self.padding); let limits = limits .min_width(self.min_width) + .min_height(self.min_height) .width(self.width) - .height(Length::Shrink) + .height(self.height) .pad(padding); let mut content = self.content.layout(renderer, &limits); |