summaryrefslogtreecommitdiffstats
path: root/style/src/theme.rs
diff options
context:
space:
mode:
Diffstat (limited to 'style/src/theme.rs')
-rw-r--r--style/src/theme.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs
index dde0df5d..271d9a29 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -16,6 +16,7 @@ use crate::radio;
use crate::rule;
use crate::scrollable;
use crate::slider;
+use crate::svg;
use crate::text;
use crate::text_input;
use crate::toggler;
@@ -823,6 +824,44 @@ impl rule::StyleSheet for fn(&Theme) -> rule::Appearance {
}
}
+/**
+ * Svg
+ */
+#[derive(Default)]
+pub enum Svg {
+ /// No filtering to the rendered SVG.
+ #[default]
+ Default,
+ /// A custom style.
+ Custom(Box<dyn svg::StyleSheet<Style = Theme>>),
+}
+
+impl Svg {
+ /// Creates a custom [`Svg`] style.
+ pub fn custom_fn(f: fn(&Theme) -> svg::Appearance) -> Self {
+ Self::Custom(Box::new(f))
+ }
+}
+
+impl svg::StyleSheet for Theme {
+ type Style = Svg;
+
+ fn appearance(&self, style: &Self::Style) -> svg::Appearance {
+ match style {
+ Svg::Default => Default::default(),
+ Svg::Custom(custom) => custom.appearance(self),
+ }
+ }
+}
+
+impl svg::StyleSheet for fn(&Theme) -> svg::Appearance {
+ type Style = Theme;
+
+ fn appearance(&self, style: &Self::Style) -> svg::Appearance {
+ (self)(style)
+ }
+}
+
/// The style of a scrollable.
#[derive(Default)]
pub enum Scrollable {