zaxis/components/disclosure/
style.rs1use crate::{ControlStyle, Padding, TweenOptions};
2
3#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DisclosureStyle {
6 pub surface: ControlStyle,
7 pub height: Option<f32>,
8 pub padding: Option<Padding>,
9 pub chevron_size: Option<f32>,
10 pub chevron_stroke: Option<f32>,
11 pub icon_size: Option<f32>,
12 pub icon_gap: Option<f32>,
13 pub font_size: Option<f32>,
14 pub font_weight: Option<crate::FontWeight>,
15 pub motion: Option<TweenOptions>,
16}
17impl DisclosureStyle {
18 pub fn height(mut self, value: f32) -> Self {
19 self.height = Some(super::dimension(value));
20 self
21 }
22 pub fn padding(mut self, value: Padding) -> Self {
23 self.padding = Some(value);
24 self
25 }
26 pub fn surface(mut self, value: ControlStyle) -> Self {
27 self.surface = value;
28 self
29 }
30 pub fn chevron(mut self, size: f32, stroke: f32) -> Self {
31 self.chevron_size = Some(super::dimension(size));
32 self.chevron_stroke = Some(super::dimension(stroke));
33 self
34 }
35 pub fn icon(mut self, size: f32, gap: f32) -> Self {
36 self.icon_size = Some(super::dimension(size));
37 self.icon_gap = Some(super::dimension(gap));
38 self
39 }
40 pub fn motion(mut self, value: TweenOptions) -> Self {
41 self.motion = Some(value);
42 self
43 }
44 pub(crate) fn merge(&mut self, rhs: &Self) {
45 self.surface.merge(rhs.surface);
46 macro_rules! set { ($($f:ident),*) => { $(if rhs.$f.is_some() { self.$f = rhs.$f.clone(); })* }; }
47 set!(
48 height,
49 padding,
50 chevron_size,
51 chevron_stroke,
52 icon_size,
53 icon_gap,
54 font_size,
55 font_weight,
56 motion
57 );
58 }
59}
60
61#[derive(Clone, Debug, Default, PartialEq)]
62pub struct CollapsingStyle {
63 pub header: DisclosureStyle,
64 pub content_padding: Option<Padding>,
65 pub spacing: Option<f32>,
66 pub animate_height: Option<bool>,
67 pub motion: Option<TweenOptions>,
68}
69impl CollapsingStyle {
70 pub fn header(mut self, value: DisclosureStyle) -> Self {
71 self.header = value;
72 self
73 }
74 pub fn content_padding(mut self, value: Padding) -> Self {
75 self.content_padding = Some(value);
76 self
77 }
78 pub fn spacing(mut self, value: f32) -> Self {
79 self.spacing = Some(super::dimension(value));
80 self
81 }
82 pub fn animate_height(mut self, value: bool) -> Self {
83 self.animate_height = Some(value);
84 self
85 }
86 pub fn motion(mut self, value: TweenOptions) -> Self {
87 self.motion = Some(value);
88 self
89 }
90 pub(crate) fn merge(&mut self, rhs: &Self) {
91 self.header.merge(&rhs.header);
92 macro_rules! set { ($($f:ident),*) => { $(if rhs.$f.is_some() { self.$f = rhs.$f.clone(); })* }; }
93 set!(content_padding, spacing, animate_height, motion);
94 }
95}
96
97#[derive(Clone, Debug, Default, PartialEq)]
98pub struct TreeStyle {
99 pub row: DisclosureStyle,
100 pub indent: Option<f32>,
101 pub guides: Option<crate::Border>,
103 pub scroll: Option<crate::ScrollStyle>,
104}
105impl TreeStyle {
106 pub fn row(mut self, value: DisclosureStyle) -> Self {
107 self.row = value;
108 self
109 }
110 pub fn indent(mut self, value: f32) -> Self {
111 self.indent = Some(super::dimension(value));
112 self
113 }
114 pub fn guides(mut self, value: crate::Border) -> Self {
115 self.guides = Some(value);
116 self
117 }
118 pub fn scroll(mut self, value: crate::ScrollStyle) -> Self {
119 self.scroll = Some(value);
120 self
121 }
122 pub(crate) fn merge(&mut self, rhs: &Self) {
123 self.row.merge(&rhs.row);
124 if rhs.indent.is_some() {
125 self.indent = rhs.indent;
126 }
127 if rhs.guides.is_some() {
128 self.guides = rhs.guides;
129 }
130 if rhs.scroll.is_some() {
131 self.scroll = rhs.scroll;
132 }
133 }
134}