2022-11-10 01:10:28 +01:00
|
|
|
//! Change the appearance of a container.
|
2020-01-01 14:16:10 +01:00
|
|
|
use iced_core::{Background, Color};
|
|
|
|
|
|
|
|
|
|
/// The appearance of a container.
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2022-06-07 04:11:24 +02:00
|
|
|
pub struct Appearance {
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The text [`Color`] of the container.
|
2020-01-01 14:16:10 +01:00
|
|
|
pub text_color: Option<Color>,
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The [`Background`] of the container.
|
2020-01-01 14:16:10 +01:00
|
|
|
pub background: Option<Background>,
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The border radius of the container.
|
2020-11-23 00:31:50 +01:00
|
|
|
pub border_radius: f32,
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The border width of the container.
|
2020-11-23 00:31:50 +01:00
|
|
|
pub border_width: f32,
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The border [`Color`] of the container.
|
2020-01-05 18:38:03 +01:00
|
|
|
pub border_color: Color,
|
2020-01-01 14:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
2022-06-07 04:11:24 +02:00
|
|
|
impl std::default::Default for Appearance {
|
2020-01-05 19:34:38 +01:00
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
text_color: None,
|
|
|
|
|
background: None,
|
2020-11-23 00:31:50 +01:00
|
|
|
border_radius: 0.0,
|
|
|
|
|
border_width: 0.0,
|
2020-01-05 19:34:38 +01:00
|
|
|
border_color: Color::TRANSPARENT,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-07 04:11:24 +02:00
|
|
|
/// A set of rules that dictate the [`Appearance`] of a container.
|
2020-01-01 14:16:10 +01:00
|
|
|
pub trait StyleSheet {
|
2022-11-10 01:10:28 +01:00
|
|
|
/// The supported style of the [`StyleSheet`].
|
2022-11-09 04:05:31 +01:00
|
|
|
type Style: Default;
|
2021-10-31 17:02:59 +07:00
|
|
|
|
2022-06-07 04:11:24 +02:00
|
|
|
/// Produces the [`Appearance`] of a container.
|
2022-11-09 04:05:31 +01:00
|
|
|
fn appearance(&self, style: &Self::Style) -> Appearance;
|
2020-01-01 14:16:10 +01:00
|
|
|
}
|