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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use super::*;
#[derive(Debug, Clone)]
pub(crate) struct StyleContext {
pub point_size: Option<PointSize>,
pub point_color: Option<PointColor>,
pub line_color: Option<LineColor>,
pub line_width: Option<LineWidth>,
}
impl StyleResolver {
pub fn point_size(&self) -> PointSize {
self.local.point_size.unwrap_or(self.theme.point_size.unwrap_or(PointSize::default()))
}
pub fn point_color(&self) -> PointColor {
self.local.point_color.unwrap_or(self.theme.point_color.unwrap_or(PointColor::default()))
}
pub fn line_color(&self) -> LineColor {
self.local.line_color.unwrap_or(self.theme.line_color.unwrap_or(LineColor::default()))
}
pub fn line_width(&self) -> LineWidth {
self.local.line_width.unwrap_or(self.theme.line_width.unwrap_or(LineWidth::default()))
}
}
impl GraphicsStyle for PointSize {
fn set_local_style(&self, context: &mut StyleResolver) {
context.local.point_size = Some(self.clone());
}
}
impl GraphicsStyle for PointColor {
fn set_local_style(&self, context: &mut StyleResolver) {
context.local.point_color = Some(self.clone());
}
}
impl GraphicsStyle for LineColor {
fn set_local_style(&self, context: &mut StyleResolver) {
context.local.line_color = Some(self.clone());
}
}
impl GraphicsStyle for LineWidth {
fn set_local_style(&self, context: &mut StyleResolver) {
context.local.line_width = Some(self.clone());
}
}