charming_fork_zephyr/element/
emphasis.rs

1use serde::Serialize;
2
3use super::{item_style::ItemStyle, AreaStyle, Label};
4
5#[derive(Serialize)]
6#[serde(rename_all = "snake_case")]
7pub enum EmphasisFocus {
8    None,
9    #[serde(rename = "self")]
10    Self_,
11    Series,
12    Ancestor,
13    Descendant,
14    Relative,
15    Adjacency,
16}
17
18#[derive(Serialize)]
19#[serde(rename_all = "camelCase")]
20pub struct Emphasis {
21    #[serde(skip_serializing_if = "Option::is_none")]
22    focus: Option<EmphasisFocus>,
23
24    #[serde(skip_serializing_if = "Option::is_none")]
25    item_style: Option<ItemStyle>,
26
27    #[serde(skip_serializing_if = "Option::is_none")]
28    area_style: Option<AreaStyle>,
29
30    #[serde(skip_serializing_if = "Option::is_none")]
31    label: Option<Label>,
32}
33
34impl Emphasis {
35    pub fn new() -> Self {
36        Self {
37            focus: None,
38            item_style: None,
39            area_style: None,
40            label: None,
41        }
42    }
43
44    pub fn focus<E: Into<EmphasisFocus>>(mut self, emphasis: E) -> Self {
45        self.focus = Some(emphasis.into());
46        self
47    }
48
49    pub fn item_style<I: Into<ItemStyle>>(mut self, item_style: I) -> Self {
50        self.item_style = Some(item_style.into());
51        self
52    }
53
54    pub fn area_style<A: Into<AreaStyle>>(mut self, area_style: A) -> Self {
55        self.area_style = Some(area_style.into());
56        self
57    }
58
59    pub fn label<L: Into<Label>>(mut self, label: L) -> Self {
60        self.label = Some(label.into());
61        self
62    }
63}