From 81ecc4a67f7982c6300a4d5e8ec4e8aac8cbd881 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 10 Jan 2024 02:58:40 +0100 Subject: Add basic controls to `layout` example --- style/src/container.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'style/src/container.rs') diff --git a/style/src/container.rs b/style/src/container.rs index ec543ae4..490a9dab 100644 --- a/style/src/container.rs +++ b/style/src/container.rs @@ -1,5 +1,5 @@ //! Change the appearance of a container. -use iced_core::{Background, BorderRadius, Color}; +use crate::core::{Background, BorderRadius, Color, Pixels}; /// The appearance of a container. #[derive(Debug, Clone, Copy)] @@ -16,6 +16,30 @@ pub struct Appearance { pub border_color: Color, } +impl Appearance { + /// Derives a new [`Appearance`] with a border of the given [`Color`] and + /// `width`. + pub fn with_border( + self, + color: impl Into, + width: impl Into, + ) -> Self { + Self { + border_color: color.into(), + border_width: width.into().0, + ..self + } + } + + /// Derives a new [`Appearance`] with the given [`Background`]. + pub fn with_background(self, background: impl Into) -> Self { + Self { + background: Some(background.into()), + ..self + } + } +} + impl std::default::Default for Appearance { fn default() -> Self { Self { -- cgit