From 18fb74f20092b2703a90afdb01f39754445998da Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 9 Nov 2022 04:05:31 +0100 Subject: Introduce `Custom` variants for every style in the built-in `Theme` --- style/src/button.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'style/src/button.rs') diff --git a/style/src/button.rs b/style/src/button.rs index c63a6b71..858a9ab2 100644 --- a/style/src/button.rs +++ b/style/src/button.rs @@ -27,11 +27,11 @@ impl std::default::Default for Appearance { /// A set of rules that dictate the style of a button. pub trait StyleSheet { - type Style: Default + Copy; + type Style: Default; - fn active(&self, style: Self::Style) -> Appearance; + fn active(&self, style: &Self::Style) -> Appearance; - fn hovered(&self, style: Self::Style) -> Appearance { + fn hovered(&self, style: &Self::Style) -> Appearance { let active = self.active(style); Appearance { @@ -40,14 +40,14 @@ pub trait StyleSheet { } } - fn pressed(&self, style: Self::Style) -> Appearance { + fn pressed(&self, style: &Self::Style) -> Appearance { Appearance { shadow_offset: Vector::default(), ..self.active(style) } } - fn disabled(&self, style: Self::Style) -> Appearance { + fn disabled(&self, style: &Self::Style) -> Appearance { let active = self.active(style); Appearance { -- cgit From 4b3d0fb08d5b2e84c1061fa601b71363b6719f59 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 10 Nov 2022 01:10:28 +0100 Subject: Write documentation for `iced_style` --- style/src/button.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'style/src/button.rs') diff --git a/style/src/button.rs b/style/src/button.rs index 858a9ab2..a564a2b7 100644 --- a/style/src/button.rs +++ b/style/src/button.rs @@ -1,14 +1,20 @@ -//! Allow your users to perform actions by pressing a button. +//! Change the apperance of a button. use iced_core::{Background, Color, Vector}; /// The appearance of a button. #[derive(Debug, Clone, Copy)] pub struct Appearance { + /// The amount of offset to apply to the shadow of the button. pub shadow_offset: Vector, + /// The [`Background`] of the button. pub background: Option, + /// The border radius of the button. pub border_radius: f32, + /// The border width of the button. pub border_width: f32, + /// The border [`Color`] of the button. pub border_color: Color, + /// The text [`Color`] of the button. pub text_color: Color, } @@ -27,10 +33,13 @@ impl std::default::Default for Appearance { /// A set of rules that dictate the style of a button. pub trait StyleSheet { + /// The supported style of the [`StyleSheet`]. type Style: Default; + /// Produces the active [`Appearance`] of a button. fn active(&self, style: &Self::Style) -> Appearance; + /// Produces the hovered [`Appearance`] of a button. fn hovered(&self, style: &Self::Style) -> Appearance { let active = self.active(style); @@ -40,6 +49,7 @@ pub trait StyleSheet { } } + /// Produces the pressed [`Appearance`] of a button. fn pressed(&self, style: &Self::Style) -> Appearance { Appearance { shadow_offset: Vector::default(), @@ -47,6 +57,7 @@ pub trait StyleSheet { } } + /// Produces the disabled [`Appearance`] of a button. fn disabled(&self, style: &Self::Style) -> Appearance { let active = self.active(style); -- cgit