From 1797e15b8cb2a2e804b9e715c62fa5a149c8ad4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 22 Jan 2020 11:17:07 +0100 Subject: [PATCH] Add default padding to `Button` --- native/src/renderer/null.rs | 2 ++ native/src/widget/button.rs | 7 ++++++- wgpu/src/renderer/widget/button.rs | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index df261cdc..3e02e73a 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -138,6 +138,8 @@ impl text_input::Renderer for Null { } impl button::Renderer for Null { + const DEFAULT_PADDING: u16 = 0; + type Style = (); fn draw( diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index 51b02172..5b0d3e41 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -61,7 +61,7 @@ where height: Length::Shrink, min_width: 0, min_height: 0, - padding: 0, + padding: Renderer::DEFAULT_PADDING, style: Renderer::Style::default(), } } @@ -249,6 +249,11 @@ where /// [`Button`]: struct.Button.html /// [renderer]: ../../renderer/index.html pub trait Renderer: crate::Renderer + Sized { + /// The default padding of a [`Button`]. + /// + /// [`Button`]: struct.Button.html + const DEFAULT_PADDING: u16; + /// The style supported by this renderer. type Style: Default; diff --git a/wgpu/src/renderer/widget/button.rs b/wgpu/src/renderer/widget/button.rs index a9209f64..0de5bf5c 100644 --- a/wgpu/src/renderer/widget/button.rs +++ b/wgpu/src/renderer/widget/button.rs @@ -4,6 +4,8 @@ use iced_native::{ }; impl iced_native::button::Renderer for Renderer { + const DEFAULT_PADDING: u16 = 5; + type Style = Box; fn draw(