Skip to main content

euv_core/style/paint_prop/
struct.rs

1use super::*;
2
3/// Box border stroke specification.
4#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
5pub struct Border {
6    /// Border stroke width in logical pixels.
7    #[get(type(copy))]
8    pub(crate) width: f32,
9    /// Border stroke color.
10    #[get(type(copy))]
11    pub(crate) color: Color,
12}
13
14/// Box drop-shadow specification.
15#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
16pub struct Shadow {
17    /// Horizontal offset in logical pixels.
18    #[get(type(copy))]
19    pub(crate) offset_x: f32,
20    /// Vertical offset in logical pixels.
21    #[get(type(copy))]
22    pub(crate) offset_y: f32,
23    /// Blur radius in logical pixels.
24    #[get(type(copy))]
25    pub(crate) blur_radius: f32,
26    /// Spread radius in logical pixels.
27    #[get(type(copy))]
28    pub(crate) spread_radius: f32,
29    /// Shadow tint color.
30    #[get(type(copy))]
31    pub(crate) color: Color,
32}
33
34/// Two-stop linear gradient specification.
35#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
36pub struct LinearGradient {
37    /// Gradient angle in degrees (`0.0` = top-to-bottom, `90.0` = left-to-right).
38    #[get(type(copy))]
39    pub(crate) angle_deg: f32,
40    /// Start color at stop `0.0`.
41    #[get(type(copy))]
42    pub(crate) start_color: Color,
43    /// End color at stop `1.0`.
44    #[get(type(copy))]
45    pub(crate) end_color: Color,
46}
47
48/// 2D visual transform applied during painting without re-running layout.
49#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
50pub struct Transform2D {
51    /// Horizontal translation in logical pixels.
52    #[get(type(copy))]
53    pub(crate) translate_x: f32,
54    /// Vertical translation in logical pixels.
55    #[get(type(copy))]
56    pub(crate) translate_y: f32,
57    /// Horizontal scale factor (`1.0` = identity).
58    #[get(type(copy))]
59    pub(crate) scale_x: f32,
60    /// Vertical scale factor (`1.0` = identity).
61    #[get(type(copy))]
62    pub(crate) scale_y: f32,
63    /// Clockwise rotation angle in radians.
64    #[get(type(copy))]
65    pub(crate) rotation_rad: f32,
66}
67
68/// Paint-only visual properties decoupled from layout calculation.
69#[derive(Clone, Copy, Data, Debug, PartialEq)]
70pub struct PaintStyle {
71    /// Optional solid background fill color.
72    #[get(skip)]
73    pub(crate) background: Option<Color>,
74    /// Optional linear gradient background fill.
75    #[get(skip)]
76    pub(crate) gradient: Option<LinearGradient>,
77    /// Border stroke width and color.
78    #[get(type(copy))]
79    pub(crate) border: Border,
80    /// Per-corner border radii.
81    #[get(type(copy))]
82    pub(crate) radius: CornerRadius,
83    /// Optional drop shadow.
84    #[get(skip)]
85    pub(crate) shadow: Option<Shadow>,
86    /// Optional focus ring border drawn outside the box without altering layout.
87    #[get(skip)]
88    pub(crate) focus_ring: Option<Border>,
89    /// Node opacity in `[0.0, 1.0]`.
90    #[get(type(copy))]
91    pub(crate) opacity: f32,
92    /// 2D paint transform.
93    #[get(type(copy))]
94    pub(crate) transform: Transform2D,
95    /// Pointer cursor icon hint.
96    #[get(type(copy))]
97    pub(crate) cursor: CursorIcon,
98    /// Pointer hit-testing policy.
99    #[get(type(copy))]
100    pub(crate) pointer_events: PointerEvents,
101    /// When `true`, prevents scroll deltas from chaining/penetrating through to ancestor scroll containers.
102    #[get(type(copy))]
103    pub(crate) stop_scroll_propagation: bool,
104    /// When `true`, stops pointer/click event bubbling past this node to ancestor handlers.
105    #[get(type(copy))]
106    pub(crate) stop_event_propagation: bool,
107}