summaryrefslogtreecommitdiffstats
path: root/style/src/button.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-12-02 18:53:21 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-12-02 18:53:21 +0100
commit4029a1cdaaac1abbdcc141b20469a49670cd99b6 (patch)
tree71fa9d9c4aa1f02ce05771db43a4bb7bc6570e77 /style/src/button.rs
parent676d8efe03ebdbeeb95aef96b8097395b788b1ab (diff)
parent8b55e9b9e6ba0b83038dd491dd34d95b4f9a381b (diff)
downloadiced-4029a1cdaaac1abbdcc141b20469a49670cd99b6.tar.gz
iced-4029a1cdaaac1abbdcc141b20469a49670cd99b6.tar.bz2
iced-4029a1cdaaac1abbdcc141b20469a49670cd99b6.zip
Merge branch 'master' into non-uniform-border-radius-for-quads
Diffstat (limited to 'style/src/button.rs')
-rw-r--r--style/src/button.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/style/src/button.rs b/style/src/button.rs
index c63a6b71..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<Background>,
+ /// 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,11 +33,14 @@ impl std::default::Default for Appearance {
/// A set of rules that dictate the style of a button.
pub trait StyleSheet {
- type Style: Default + Copy;
+ /// The supported style of the [`StyleSheet`].
+ type Style: Default;
- fn active(&self, style: Self::Style) -> Appearance;
+ /// Produces the active [`Appearance`] of a button.
+ fn active(&self, style: &Self::Style) -> Appearance;
- fn hovered(&self, style: Self::Style) -> Appearance {
+ /// Produces the hovered [`Appearance`] of a button.
+ fn hovered(&self, style: &Self::Style) -> Appearance {
let active = self.active(style);
Appearance {
@@ -40,14 +49,16 @@ pub trait StyleSheet {
}
}
- fn pressed(&self, style: Self::Style) -> Appearance {
+ /// Produces the pressed [`Appearance`] of a button.
+ fn pressed(&self, style: &Self::Style) -> Appearance {
Appearance {
shadow_offset: Vector::default(),
..self.active(style)
}
}
- fn disabled(&self, style: Self::Style) -> Appearance {
+ /// Produces the disabled [`Appearance`] of a button.
+ fn disabled(&self, style: &Self::Style) -> Appearance {
let active = self.active(style);
Appearance {