summaryrefslogtreecommitdiffstats
path: root/style/src/container.rs
diff options
context:
space:
mode:
Diffstat (limited to 'style/src/container.rs')
-rw-r--r--style/src/container.rs39
1 files changed, 6 insertions, 33 deletions
diff --git a/style/src/container.rs b/style/src/container.rs
index 2f411611..184310fa 100644
--- a/style/src/container.rs
+++ b/style/src/container.rs
@@ -3,7 +3,7 @@ use iced_core::{Background, Color};
/// The appearance of a container.
#[derive(Debug, Clone, Copy)]
-pub struct Style {
+pub struct Appearance {
pub text_color: Option<Color>,
pub background: Option<Background>,
pub border_radius: f32,
@@ -11,7 +11,7 @@ pub struct Style {
pub border_color: Color,
}
-impl std::default::Default for Style {
+impl std::default::Default for Appearance {
fn default() -> Self {
Self {
text_color: None,
@@ -23,37 +23,10 @@ impl std::default::Default for Style {
}
}
-/// A set of rules that dictate the style of a container.
+/// A set of rules that dictate the [`Appearance`] of a container.
pub trait StyleSheet {
- /// Produces the style of a container.
- fn style(&self) -> Style;
-}
-
-struct Default;
-
-impl StyleSheet for Default {
- fn style(&self) -> Style {
- Style {
- text_color: None,
- background: None,
- border_radius: 0.0,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- }
- }
-}
-
-impl<'a> std::default::Default for Box<dyn StyleSheet + 'a> {
- fn default() -> Self {
- Box::new(Default)
- }
-}
+ type Style: Default + Copy;
-impl<'a, T> From<T> for Box<dyn StyleSheet + 'a>
-where
- T: StyleSheet + 'a,
-{
- fn from(style_sheet: T) -> Self {
- Box::new(style_sheet)
- }
+ /// Produces the [`Appearance`] of a container.
+ fn appearance(&self, style: Self::Style) -> Appearance;
}