summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/layout/src/main.rs5
-rw-r--r--widget/src/container.rs38
2 files changed, 26 insertions, 17 deletions
diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs
index d0827fad..f39e24f9 100644
--- a/examples/layout/src/main.rs
+++ b/examples/layout/src/main.rs
@@ -1,3 +1,4 @@
+use iced::border;
use iced::keyboard;
use iced::mouse;
use iced::widget::{
@@ -85,7 +86,7 @@ impl Layout {
let palette = theme.extended_palette();
container::Style::default()
- .with_border(palette.background.strong.color, 4.0)
+ .border(border::color(palette.background.strong.color).width(4))
})
.padding(4);
@@ -240,7 +241,7 @@ fn application<'a>() -> Element<'a, Message> {
let palette = theme.extended_palette();
container::Style::default()
- .with_border(palette.background.strong.color, 1)
+ .border(border::color(palette.background.strong.color).width(1))
});
let sidebar = container(
diff --git a/widget/src/container.rs b/widget/src/container.rs
index 5680bc30..d65bb086 100644
--- a/widget/src/container.rs
+++ b/widget/src/container.rs
@@ -546,46 +546,54 @@ pub struct Style {
}
impl Style {
- /// Updates the border of the [`Style`] with the given [`Color`] and `width`.
- pub fn with_border(
- self,
- color: impl Into<Color>,
- width: impl Into<Pixels>,
- ) -> Self {
+ /// Updates the text color of the [`Style`].
+ pub fn color(self, color: impl Into<Color>) -> Self {
Self {
- border: Border {
- color: color.into(),
- width: width.into().0,
- ..Border::default()
- },
+ text_color: Some(color.into()),
+ ..self
+ }
+ }
+
+ /// Updates the border of the [`Style`].
+ pub fn border(self, border: impl Into<Border>) -> Self {
+ Self {
+ border: border.into(),
..self
}
}
/// Updates the background of the [`Style`].
- pub fn with_background(self, background: impl Into<Background>) -> Self {
+ pub fn background(self, background: impl Into<Background>) -> Self {
Self {
background: Some(background.into()),
..self
}
}
+
+ /// Updates the shadow of the [`Style`].
+ pub fn shadow(self, shadow: impl Into<Shadow>) -> Self {
+ Self {
+ shadow: shadow.into(),
+ ..self
+ }
+ }
}
impl From<Color> for Style {
fn from(color: Color) -> Self {
- Self::default().with_background(color)
+ Self::default().background(color)
}
}
impl From<Gradient> for Style {
fn from(gradient: Gradient) -> Self {
- Self::default().with_background(gradient)
+ Self::default().background(gradient)
}
}
impl From<gradient::Linear> for Style {
fn from(gradient: gradient::Linear) -> Self {
- Self::default().with_background(gradient)
+ Self::default().background(gradient)
}
}