Skip to main content

euv_core/style/sheet/
struct.rs

1use super::*;
2
3/// Complete compiled style value combining layout, paint, and typography with zero heap allocations.
4#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
5pub struct Style {
6    /// Layout geometry properties.
7    #[get(type(copy))]
8    pub(crate) layout: LayoutStyle,
9    /// Visual paint properties.
10    #[get(type(copy))]
11    pub(crate) paint: PaintStyle,
12    /// Typography properties.
13    #[get(type(copy))]
14    pub(crate) text: TextStyle,
15}
16
17/// Responsive style bundle resolving deterministically for compact, medium, and expanded viewports.
18#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
19pub struct ResponsiveStyle {
20    /// Base style applied across all breakpoints.
21    #[get(type(copy))]
22    pub(crate) base: Style,
23    /// Optional style override when viewport is `Breakpoint::Compact`.
24    #[new(skip)]
25    #[get(skip)]
26    pub(crate) compact: Option<Style>,
27    /// Optional style override when viewport is `Breakpoint::Medium`.
28    #[new(skip)]
29    #[get(skip)]
30    pub(crate) medium: Option<Style>,
31}
32
33/// Keyless `style!` property wrapper setting layout box width.
34#[repr(transparent)]
35#[derive(Clone, Copy, Debug, Default, PartialEq)]
36pub struct Width(pub Length);
37
38/// Keyless `style!` property wrapper setting layout box height.
39#[repr(transparent)]
40#[derive(Clone, Copy, Debug, Default, PartialEq)]
41pub struct Height(pub Length);
42
43/// Keyless `style!` property wrapper setting minimum layout width constraint.
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, Default, PartialEq)]
46pub struct MinWidth(pub Length);
47
48/// Keyless `style!` property wrapper setting minimum layout height constraint.
49#[repr(transparent)]
50#[derive(Clone, Copy, Debug, Default, PartialEq)]
51pub struct MinHeight(pub Length);
52
53/// Keyless `style!` property wrapper setting maximum layout width constraint.
54#[repr(transparent)]
55#[derive(Clone, Copy, Debug, Default, PartialEq)]
56pub struct MaxWidth(pub Length);
57
58/// Keyless `style!` property wrapper setting maximum layout height constraint.
59#[repr(transparent)]
60#[derive(Clone, Copy, Debug, Default, PartialEq)]
61pub struct MaxHeight(pub Length);
62
63/// Keyless `style!` property wrapper setting initial flex main-axis basis length.
64#[repr(transparent)]
65#[derive(Clone, Copy, Debug, Default, PartialEq)]
66pub struct FlexBasis(pub Length);
67
68/// Keyless `style!` property wrapper setting explicit `width / height` aspect ratio.
69#[repr(transparent)]
70#[derive(Clone, Copy, Debug, Default, PartialEq)]
71pub struct AspectRatio(pub f32);
72
73/// Keyless `style!` property wrapper setting inner box padding edges.
74#[repr(transparent)]
75#[derive(Clone, Copy, Debug, Default, PartialEq)]
76pub struct Padding(pub Edges);
77
78/// Keyless `style!` property wrapper setting outer box margin edges.
79#[repr(transparent)]
80#[derive(Clone, Copy, Debug, Default, PartialEq)]
81pub struct Margin(pub Edges);
82
83/// Keyless `style!` property wrapper setting uniform row and column gap in logical pixels.
84#[repr(transparent)]
85#[derive(Clone, Copy, Debug, Default, PartialEq)]
86pub struct Gap(pub f32);
87
88/// Keyless `style!` property wrapper setting vertical row gap in logical pixels.
89#[repr(transparent)]
90#[derive(Clone, Copy, Debug, Default, PartialEq)]
91pub struct RowGap(pub f32);
92
93/// Keyless `style!` property wrapper setting horizontal column gap in logical pixels.
94#[repr(transparent)]
95#[derive(Clone, Copy, Debug, Default, PartialEq)]
96pub struct ColumnGap(pub f32);
97
98/// Keyless `style!` property wrapper setting flex grow factor.
99#[repr(transparent)]
100#[derive(Clone, Copy, Debug, Default, PartialEq)]
101pub struct FlexGrow(pub f32);
102
103/// Keyless `style!` property wrapper setting flex shrink factor.
104#[repr(transparent)]
105#[derive(Clone, Copy, Debug, Default, PartialEq)]
106pub struct FlexShrink(pub f32);
107
108/// Keyless `style!` property wrapper setting stacking order `z_index`.
109#[repr(transparent)]
110#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
111pub struct ZIndex(pub i32);
112
113/// Keyless `style!` property wrapper configuring `Display::Grid` with equal-width column count.
114#[repr(transparent)]
115#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
116pub struct GridColumns(pub u16);
117
118/// Keyless `style!` property wrapper setting `(top, right, bottom, left)` positioned offsets.
119#[derive(Clone, Copy, Debug, Default, PartialEq)]
120pub struct Inset(
121    pub Option<f32>,
122    pub Option<f32>,
123    pub Option<f32>,
124    pub Option<f32>,
125);
126
127/// Keyless `style!` property wrapper setting solid background fill color.
128#[repr(transparent)]
129#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
130pub struct Background(pub Color);
131
132/// Keyless `style!` property wrapper setting uniform corner radius in logical pixels.
133#[repr(transparent)]
134#[derive(Clone, Copy, Debug, Default, PartialEq)]
135pub struct Radius(pub f32);
136
137/// Keyless `style!` property wrapper setting focus-ring stroke border.
138#[repr(transparent)]
139#[derive(Clone, Copy, Debug, Default, PartialEq)]
140pub struct FocusRing(pub Border);
141
142/// Keyless `style!` property wrapper setting visual opacity in `[0.0, 1.0]`.
143#[repr(transparent)]
144#[derive(Clone, Copy, Debug, Default, PartialEq)]
145pub struct Opacity(pub f32);
146
147/// Keyless `style!` property wrapper controlling scroll-delta propagation blocking.
148#[repr(transparent)]
149#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
150pub struct StopScrollPropagation(pub bool);
151
152/// Keyless `style!` property wrapper controlling pointer/click event bubbling blocking.
153#[repr(transparent)]
154#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
155pub struct StopEventPropagation(pub bool);
156
157/// Keyless `style!` property wrapper setting foreground text color.
158#[repr(transparent)]
159#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
160pub struct TextColor(pub Color);
161
162/// Keyless `style!` property wrapper setting font size in logical pixels.
163#[repr(transparent)]
164#[derive(Clone, Copy, Debug, Default, PartialEq)]
165pub struct FontSize(pub f32);
166
167/// Keyless `style!` property wrapper setting line-height multiplier.
168#[repr(transparent)]
169#[derive(Clone, Copy, Debug, Default, PartialEq)]
170pub struct LineHeight(pub f32);
171
172/// Keyless `style!` property wrapper setting inter-glyph letter spacing in logical pixels.
173#[repr(transparent)]
174#[derive(Clone, Copy, Debug, Default, PartialEq)]
175pub struct LetterSpacing(pub f32);
176
177/// Keyless `style!` property wrapper enabling or disabling italic text slant.
178#[repr(transparent)]
179#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
180pub struct Italic(pub bool);
181
182/// Keyless `style!` property wrapper enabling or disabling text underline decoration.
183#[repr(transparent)]
184#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
185pub struct Underline(pub bool);
186
187/// Keyless `style!` property wrapper enabling or disabling text strikethrough decoration.
188#[repr(transparent)]
189#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
190pub struct Strikethrough(pub bool);
191
192/// Keyless `style!` property wrapper enabling or disabling interactive text selection.
193#[repr(transparent)]
194#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
195pub struct Selectable(pub bool);
196
197/// Keyless `style!` property wrapper setting text selection highlight tint color.
198#[repr(transparent)]
199#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
200pub struct SelectionColor(pub Color);