diff options
author | 2022-02-11 23:33:03 +0700 | |
---|---|---|
committer | 2022-02-11 23:33:03 +0700 | |
commit | dd3e74e74de3a416d9d2dcfee051d78ba03dc540 (patch) | |
tree | 9a64ee049c54b3e1fba2b7b433c6bff206b1eb83 /pure/src | |
parent | ecb3df8e018930c407e469ce2b8f4208a9d15426 (diff) | |
download | iced-dd3e74e74de3a416d9d2dcfee051d78ba03dc540.tar.gz iced-dd3e74e74de3a416d9d2dcfee051d78ba03dc540.tar.bz2 iced-dd3e74e74de3a416d9d2dcfee051d78ba03dc540.zip |
Complete `Button` in `iced_pure`
Diffstat (limited to '')
-rw-r--r-- | pure/src/widget/button.rs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/pure/src/widget/button.rs b/pure/src/widget/button.rs index 89acb7f5..b9561b09 100644 --- a/pure/src/widget/button.rs +++ b/pure/src/widget/button.rs @@ -35,8 +35,38 @@ impl<'a, Message, Renderer> Button<'a, Message, Renderer> { } } - pub fn on_press(mut self, on_press: Message) -> Self { - self.on_press = Some(on_press); + /// Sets the width of the [`Button`]. + pub fn width(mut self, width: Length) -> Self { + self.width = width; + self + } + + /// Sets the height of the [`Button`]. + pub fn height(mut self, height: Length) -> Self { + self.height = height; + self + } + + /// Sets the [`Padding`] of the [`Button`]. + pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self { + self.padding = padding.into(); + self + } + + /// Sets the message that will be produced when the [`Button`] is pressed. + /// + /// Unless `on_press` is called, the [`Button`] will be disabled. + pub fn on_press(mut self, msg: Message) -> Self { + self.on_press = Some(msg); + self + } + + /// Sets the style of the [`Button`]. + pub fn style( + mut self, + style_sheet: impl Into<Box<dyn StyleSheet + 'a>>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } } |