summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
Diffstat (limited to 'widget')
-rw-r--r--widget/src/button.rs2
-rw-r--r--widget/src/container.rs26
-rw-r--r--widget/src/overlay/menu.rs2
-rw-r--r--widget/src/progress_bar.rs4
-rw-r--r--widget/src/radio.rs2
-rw-r--r--widget/src/rule.rs2
-rw-r--r--widget/src/scrollable.rs4
-rw-r--r--widget/src/slider.rs4
-rw-r--r--widget/src/vertical_slider.rs4
9 files changed, 34 insertions, 16 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs
index 12716acd..9ce856bb 100644
--- a/widget/src/button.rs
+++ b/widget/src/button.rs
@@ -543,7 +543,7 @@ fn styled(pair: palette::Pair) -> Appearance {
Appearance {
background: Some(Background::Color(pair.color)),
text_color: pair.text,
- border: Border::with_radius(2),
+ border: Border::rounded(2),
..Appearance::default()
}
}
diff --git a/widget/src/container.rs b/widget/src/container.rs
index 5e16312c..81b9a29e 100644
--- a/widget/src/container.rs
+++ b/widget/src/container.rs
@@ -1,6 +1,7 @@
//! Decorate content and apply alignment.
use crate::core::alignment::{self, Alignment};
use crate::core::event::{self, Event};
+use crate::core::gradient::{self, Gradient};
use crate::core::layout;
use crate::core::mouse;
use crate::core::overlay;
@@ -510,8 +511,7 @@ pub struct Appearance {
}
impl Appearance {
- /// Derives a new [`Appearance`] with a border of the given [`Color`] and
- /// `width`.
+ /// Updates the border of the [`Appearance`] with the given [`Color`] and `width`.
pub fn with_border(
self,
color: impl Into<Color>,
@@ -527,7 +527,7 @@ impl Appearance {
}
}
- /// Derives a new [`Appearance`] with the given [`Background`].
+ /// Updates the background of the [`Appearance`].
pub fn with_background(self, background: impl Into<Background>) -> Self {
Self {
background: Some(background.into()),
@@ -566,6 +566,24 @@ impl DefaultStyle for Appearance {
}
}
+impl DefaultStyle for Color {
+ fn default_style() -> Style<Self> {
+ |color, _status| Appearance::default().with_background(*color)
+ }
+}
+
+impl DefaultStyle for Gradient {
+ fn default_style() -> Style<Self> {
+ |gradient, _status| Appearance::default().with_background(*gradient)
+ }
+}
+
+impl DefaultStyle for gradient::Linear {
+ fn default_style() -> Style<Self> {
+ |gradient, _status| Appearance::default().with_background(*gradient)
+ }
+}
+
/// A transparent [`Container`].
pub fn transparent<Theme>(_theme: &Theme, _status: Status) -> Appearance {
Appearance::default()
@@ -577,7 +595,7 @@ pub fn box_(theme: &Theme, _status: Status) -> Appearance {
Appearance {
background: Some(palette.background.weak.color.into()),
- border: Border::with_radius(2),
+ border: Border::rounded(2),
..Appearance::default()
}
}
diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs
index e855fc14..746407c6 100644
--- a/widget/src/overlay/menu.rs
+++ b/widget/src/overlay/menu.rs
@@ -539,7 +539,7 @@ where
width: bounds.width - appearance.border.width * 2.0,
..bounds
},
- border: Border::with_radius(appearance.border.radius),
+ border: Border::rounded(appearance.border.radius),
..renderer::Quad::default()
},
appearance.selected_background,
diff --git a/widget/src/progress_bar.rs b/widget/src/progress_bar.rs
index f945a7b5..7b0ea63f 100644
--- a/widget/src/progress_bar.rs
+++ b/widget/src/progress_bar.rs
@@ -134,7 +134,7 @@ where
width: active_progress_width,
..bounds
},
- border: Border::with_radius(appearance.border.radius),
+ border: Border::rounded(appearance.border.radius),
..renderer::Quad::default()
},
appearance.bar,
@@ -230,6 +230,6 @@ fn styled(
Appearance {
background: background.into(),
bar: bar.into(),
- border: Border::with_radius(2),
+ border: Border::rounded(2),
}
}
diff --git a/widget/src/radio.rs b/widget/src/radio.rs
index e8f1eb1f..34c3b3a0 100644
--- a/widget/src/radio.rs
+++ b/widget/src/radio.rs
@@ -328,7 +328,7 @@ where
width: bounds.width - dot_size,
height: bounds.height - dot_size,
},
- border: Border::with_radius(dot_size / 2.0),
+ border: Border::rounded(dot_size / 2.0),
..renderer::Quad::default()
},
appearance.dot_color,
diff --git a/widget/src/rule.rs b/widget/src/rule.rs
index 384baed4..8580d4c7 100644
--- a/widget/src/rule.rs
+++ b/widget/src/rule.rs
@@ -118,7 +118,7 @@ where
renderer.fill_quad(
renderer::Quad {
bounds,
- border: Border::with_radius(appearance.radius),
+ border: Border::rounded(appearance.radius),
..renderer::Quad::default()
},
appearance.color,
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index 8d2b2057..6cd2048f 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -1692,10 +1692,10 @@ pub fn default(theme: &Theme, status: Status) -> Appearance {
let scrollbar = Scrollbar {
background: Some(palette.background.weak.color.into()),
- border: Border::with_radius(2),
+ border: Border::rounded(2),
scroller: Scroller {
color: palette.background.strong.color,
- border: Border::with_radius(2),
+ border: Border::rounded(2),
},
};
diff --git a/widget/src/slider.rs b/widget/src/slider.rs
index 6449b18e..c37607a8 100644
--- a/widget/src/slider.rs
+++ b/widget/src/slider.rs
@@ -392,7 +392,7 @@ where
width: offset + handle_width / 2.0,
height: style.rail.width,
},
- border: Border::with_radius(style.rail.border_radius),
+ border: Border::rounded(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.0,
@@ -406,7 +406,7 @@ where
width: bounds.width - offset - handle_width / 2.0,
height: style.rail.width,
},
- border: Border::with_radius(style.rail.border_radius),
+ border: Border::rounded(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.1,
diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs
index 103c3b7d..67a9f4e6 100644
--- a/widget/src/vertical_slider.rs
+++ b/widget/src/vertical_slider.rs
@@ -397,7 +397,7 @@ where
width: style.rail.width,
height: offset + handle_width / 2.0,
},
- border: Border::with_radius(style.rail.border_radius),
+ border: Border::rounded(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.1,
@@ -411,7 +411,7 @@ where
width: style.rail.width,
height: bounds.height - offset - handle_width / 2.0,
},
- border: Border::with_radius(style.rail.border_radius),
+ border: Border::rounded(style.rail.border_radius),
..renderer::Quad::default()
},
style.rail.colors.0,