summaryrefslogtreecommitdiffstats
path: root/style/src/rule.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-01 01:56:46 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-01 01:56:46 +0200
commitc275fde67a7f5d1d5789540dc7905250a2f01fe7 (patch)
treee3ebeeebaeb69ff415b30d3720b00a8c0abf2d32 /style/src/rule.rs
parent6f69df3d415bfc922ce15539746026843bd410e6 (diff)
downloadiced-c275fde67a7f5d1d5789540dc7905250a2f01fe7.tar.gz
iced-c275fde67a7f5d1d5789540dc7905250a2f01fe7.tar.bz2
iced-c275fde67a7f5d1d5789540dc7905250a2f01fe7.zip
Implement theme styling for `Rule`
Diffstat (limited to '')
-rw-r--r--style/src/rule.rs74
1 files changed, 21 insertions, 53 deletions
diff --git a/style/src/rule.rs b/style/src/rule.rs
index 12a40f7d..af334912 100644
--- a/style/src/rule.rs
+++ b/style/src/rule.rs
@@ -1,6 +1,27 @@
//! Display a horizontal or vertical rule for dividing content.
use iced_core::Color;
+/// The appearance of a rule.
+#[derive(Debug, Clone, Copy)]
+pub struct Appearance {
+ /// The color of the rule.
+ pub color: Color,
+ /// The width (thickness) of the rule line.
+ pub width: u16,
+ /// The radius of the line corners.
+ pub radius: f32,
+ /// The [`FillMode`] of the rule.
+ pub fill_mode: FillMode,
+}
+
+/// A set of rules that dictate the style of a rule.
+pub trait StyleSheet {
+ type Style: Default + Copy;
+
+ /// Produces the style of a rule.
+ fn style(&self, style: Self::Style) -> Appearance;
+}
+
/// The fill mode of a rule.
#[derive(Debug, Clone, Copy)]
pub enum FillMode {
@@ -64,56 +85,3 @@ impl FillMode {
}
}
}
-
-/// The appearance of a rule.
-#[derive(Debug, Clone, Copy)]
-pub struct Style {
- /// The color of the rule.
- pub color: Color,
- /// The width (thickness) of the rule line.
- pub width: u16,
- /// The radius of the line corners.
- pub radius: f32,
- /// The [`FillMode`] of the rule.
- pub fill_mode: FillMode,
-}
-
-impl std::default::Default for Style {
- fn default() -> Self {
- Style {
- color: [0.6, 0.6, 0.6, 0.6].into(),
- width: 1,
- radius: 0.0,
- fill_mode: FillMode::Full,
- }
- }
-}
-
-/// A set of rules that dictate the style of a rule.
-pub trait StyleSheet {
- /// Produces the style of a rule.
- fn style(&self) -> Style;
-}
-
-struct Default;
-
-impl StyleSheet for Default {
- fn style(&self) -> Style {
- Style::default()
- }
-}
-
-impl<'a> std::default::Default for Box<dyn StyleSheet + 'a> {
- fn default() -> Self {
- Box::new(Default)
- }
-}
-
-impl<'a, T> From<T> for Box<dyn StyleSheet + 'a>
-where
- T: 'a + StyleSheet,
-{
- fn from(style: T) -> Self {
- Box::new(style)
- }
-}