summaryrefslogtreecommitdiffstats
path: root/style/src/svg.rs
blob: 3fe5546b10944915cc0fec730eae02c19b3fbd75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Change the appearance of a svg.

use iced_core::Color;

/// The appearance of an SVG.
#[derive(Debug, Default, Clone, Copy)]
pub struct Appearance {
    /// The [`Color`] filter of an SVG.
    ///
    /// Useful for coloring a symbolic icon.
    ///
    /// `None` keeps the original color.
    pub color: Option<Color>,
}

/// The stylesheet of a svg.
pub trait StyleSheet {
    /// The supported style of the [`StyleSheet`].
    type Style: Default;

    /// Produces the [`Appearance`] of the svg.
    fn appearance(&self, style: &Self::Style) -> Appearance;

    /// Produces the hovered [`Appearance`] of a svg content.
    fn hovered(&self, style: &Self::Style) -> Appearance {
        self.appearance(style)
    }
}