From 692216042307c0ff0d792d1bba6928e499a65d1f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 18 Feb 2020 02:28:15 +0100 Subject: Pull `Checkbox` default constants from its `Renderer` --- native/src/widget/checkbox.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 669437bc..b36d10a4 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -26,18 +26,20 @@ use crate::{ /// /// ![Checkbox drawn by `iced_wgpu`](https://github.com/hecrj/iced/blob/7760618fb112074bc40b148944521f312152012a/docs/images/checkbox.png?raw=true) #[allow(missing_debug_implementations)] -pub struct Checkbox { +pub struct Checkbox { is_checked: bool, on_toggle: Box Message>, label: String, - size: u16, width: Length, + size: u16, spacing: u16, text_size: u16, style: Renderer::Style, } -impl Checkbox { +impl + Checkbox +{ /// Creates a new [`Checkbox`]. /// /// It expects: @@ -56,10 +58,10 @@ impl Checkbox { is_checked, on_toggle: Box::new(f), label: String::from(label), - size: 20, width: Length::Shrink, - spacing: 15, - text_size: 20, + size: ::DEFAULT_SIZE, + spacing: Renderer::DEFAULT_SPACING, + text_size: ::DEFAULT_SIZE, style: Renderer::Style::default(), } } @@ -135,7 +137,8 @@ where .push( Text::new(&self.label) .width(self.width) - .size(self.text_size)) + .size(self.text_size), + ) .layout(renderer, limits) } @@ -217,10 +220,15 @@ pub trait Renderer: crate::Renderer { /// The style supported by this renderer. type Style: Default; - /// Returns the default size of a [`Checkbox`]. + /// The default size of a [`Checkbox`]. + /// + /// [`Checkbox`]: struct.Checkbox.html + const DEFAULT_SIZE: u16; + + /// The default spacing of a [`Checkbox`]. /// /// [`Checkbox`]: struct.Checkbox.html - fn default_size(&self) -> u32; + const DEFAULT_SPACING: u16; /// Draws a [`Checkbox`]. /// -- cgit