summaryrefslogtreecommitdiffstats
path: root/style/src/button.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-26 23:07:34 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-26 23:07:34 +0200
commitcf0230072c01ea9523f4d98a3656f5c975b3f347 (patch)
treeed24c6b90c6e319129e5fe963d50593846aaab72 /style/src/button.rs
parent7f3b7075db68a215f4331b4bfba1c8ddd1c4d7f3 (diff)
downloadiced-cf0230072c01ea9523f4d98a3656f5c975b3f347.tar.gz
iced-cf0230072c01ea9523f4d98a3656f5c975b3f347.tar.bz2
iced-cf0230072c01ea9523f4d98a3656f5c975b3f347.zip
Rename `Variant` to `Style` and `Style` to `Appearance`
Diffstat (limited to 'style/src/button.rs')
-rw-r--r--style/src/button.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/style/src/button.rs b/style/src/button.rs
index 9f00185c..c63a6b71 100644
--- a/style/src/button.rs
+++ b/style/src/button.rs
@@ -3,7 +3,7 @@ use iced_core::{Background, Color, Vector};
/// The appearance of a button.
#[derive(Debug, Clone, Copy)]
-pub struct Style {
+pub struct Appearance {
pub shadow_offset: Vector,
pub background: Option<Background>,
pub border_radius: f32,
@@ -12,7 +12,7 @@ pub struct Style {
pub text_color: Color,
}
-impl std::default::Default for Style {
+impl std::default::Default for Appearance {
fn default() -> Self {
Self {
shadow_offset: Vector::default(),
@@ -27,30 +27,30 @@ impl std::default::Default for Style {
/// A set of rules that dictate the style of a button.
pub trait StyleSheet {
- type Variant;
+ type Style: Default + Copy;
- fn active(&self, variant: Self::Variant) -> Style;
+ fn active(&self, style: Self::Style) -> Appearance;
- fn hovered(&self, variant: Self::Variant) -> Style {
- let active = self.active(variant);
+ fn hovered(&self, style: Self::Style) -> Appearance {
+ let active = self.active(style);
- Style {
+ Appearance {
shadow_offset: active.shadow_offset + Vector::new(0.0, 1.0),
..active
}
}
- fn pressed(&self, variant: Self::Variant) -> Style {
- Style {
+ fn pressed(&self, style: Self::Style) -> Appearance {
+ Appearance {
shadow_offset: Vector::default(),
- ..self.active(variant)
+ ..self.active(style)
}
}
- fn disabled(&self, variant: Self::Variant) -> Style {
- let active = self.active(variant);
+ fn disabled(&self, style: Self::Style) -> Appearance {
+ let active = self.active(style);
- Style {
+ Appearance {
shadow_offset: Vector::default(),
background: active.background.map(|background| match background {
Background::Color(color) => Background::Color(Color {