Introduce Border struct analogous to Shadow

This commit is contained in:
Héctor Ramón Jiménez 2024-01-20 13:29:25 +01:00
parent 4d502012b3
commit 25f182f933
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
44 changed files with 382 additions and 424 deletions

View file

@ -1,19 +1,15 @@
//! Change the appearance of a container.
use crate::core::{Background, BorderRadius, Color, Pixels};
use crate::core::{Background, Border, Color, Pixels};
/// The appearance of a container.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Default)]
pub struct Appearance {
/// The text [`Color`] of the container.
pub text_color: Option<Color>,
/// The [`Background`] of the container.
pub background: Option<Background>,
/// The border radius of the container.
pub border_radius: BorderRadius,
/// The border width of the container.
pub border_width: f32,
/// The border [`Color`] of the container.
pub border_color: Color,
/// The [`Border`] of the container.
pub border: Border,
}
impl Appearance {
@ -25,8 +21,11 @@ impl Appearance {
width: impl Into<Pixels>,
) -> Self {
Self {
border_color: color.into(),
border_width: width.into().0,
border: Border {
color: color.into(),
width: width.into().0,
..Border::default()
},
..self
}
}
@ -40,18 +39,6 @@ impl Appearance {
}
}
impl std::default::Default for Appearance {
fn default() -> Self {
Self {
text_color: None,
background: None,
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
}
}
/// A set of rules that dictate the [`Appearance`] of a container.
pub trait StyleSheet {
/// The supported style of the [`StyleSheet`].