Skip to main content

euv_core/style/sheet/
impl.rs

1use super::*;
2
3/// Fluent zero-allocation builder methods for `Style`.
4impl Style {
5    /// Applies any strongly-typed `StyleApply` value (e.g. `AlignItems::Center`, `Overflow::Hidden`, `Shadow`) to this style.
6    ///
7    /// # Arguments
8    ///
9    /// - `Self` - Source style.
10    /// - `T` - Typed property implementing `StyleApply`.
11    ///
12    /// # Returns
13    ///
14    /// - `Self` - Updated style.
15    #[must_use]
16    pub fn apply<T>(self, prop: T) -> Self
17    where
18        T: StyleApply,
19    {
20        prop.apply_to(self)
21    }
22
23    /// Sets the flex container axis direction (`FlexDirection::Row` or `FlexDirection::Column`).
24    ///
25    /// # Arguments
26    ///
27    /// - `Self` - Source style.
28    /// - `FlexDirection` - Target flex axis direction.
29    ///
30    /// # Returns
31    ///
32    /// - `Self` - Updated style.
33    #[must_use]
34    pub fn direction(mut self, direction: FlexDirection) -> Self {
35        if self.get_layout().get_display() != Display::None {
36            self.get_mut_layout().set_display(Display::Flex);
37        }
38        self.get_mut_layout().set_flex_direction(direction);
39        self
40    }
41
42    /// Sets the box display mode.
43    ///
44    /// # Arguments
45    ///
46    /// - `Self` - Source style.
47    /// - `Display` - Target display mode.
48    ///
49    /// # Returns
50    ///
51    /// - `Self` - Updated style.
52    #[must_use]
53    pub fn display(mut self, display: Display) -> Self {
54        self.get_mut_layout().set_display(display);
55        self
56    }
57
58    /// Sets the positioning mode.
59    ///
60    /// # Arguments
61    ///
62    /// - `Self` - Source style.
63    /// - `Position` - Target position mode.
64    ///
65    /// # Returns
66    ///
67    /// - `Self` - Updated style.
68    #[must_use]
69    pub fn position(mut self, position: Position) -> Self {
70        self.get_mut_layout().set_position(position);
71        self
72    }
73
74    /// Configures a horizontal flex row.
75    ///
76    /// # Arguments
77    ///
78    /// - `Self` - Source style.
79    ///
80    /// # Returns
81    ///
82    /// - `Self` - Updated style.
83    #[must_use]
84    pub fn row(mut self) -> Self {
85        if self.get_layout().get_display() != Display::None {
86            self.get_mut_layout().set_display(Display::Flex);
87        }
88        self.get_mut_layout().set_flex_direction(FlexDirection::Row);
89        self
90    }
91
92    /// Configures a vertical flex column.
93    ///
94    /// # Arguments
95    ///
96    /// - `Self` - Source style.
97    ///
98    /// # Returns
99    ///
100    /// - `Self` - Updated style.
101    #[must_use]
102    pub fn column(mut self) -> Self {
103        if self.get_layout().get_display() != Display::None {
104            self.get_mut_layout().set_display(Display::Flex);
105        }
106        self.get_mut_layout()
107            .set_flex_direction(FlexDirection::Column);
108        self
109    }
110
111    /// Configures a grid layout with `columns` equal-width columns.
112    ///
113    /// # Arguments
114    ///
115    /// - `Self` - Source style.
116    /// - `u16` - Number of grid columns (clamped to at least 1).
117    ///
118    /// # Returns
119    ///
120    /// - `Self` - Updated style.
121    #[must_use]
122    pub fn grid(mut self, columns: u16) -> Self {
123        if self.get_layout().get_display() != Display::None {
124            self.get_mut_layout().set_display(Display::Grid);
125        }
126        self.get_mut_layout().set_grid_columns(columns.max(1));
127        self
128    }
129
130    /// Sets flex wrapping behavior.
131    ///
132    /// # Arguments
133    ///
134    /// - `Self` - Source style.
135    /// - `FlexWrap` - Wrap mode.
136    ///
137    /// # Returns
138    ///
139    /// - `Self` - Updated style.
140    #[must_use]
141    pub fn wrap(mut self, wrap: FlexWrap) -> Self {
142        self.get_mut_layout().set_flex_wrap(wrap);
143        self
144    }
145
146    /// Sets main-axis justification.
147    ///
148    /// # Arguments
149    ///
150    /// - `Self` - Source style.
151    /// - `JustifyContent` - Justification mode.
152    ///
153    /// # Returns
154    ///
155    /// - `Self` - Updated style.
156    #[must_use]
157    pub fn justify(mut self, justify: JustifyContent) -> Self {
158        self.get_mut_layout().set_justify_content(justify);
159        self
160    }
161
162    /// Sets cross-axis alignment.
163    ///
164    /// # Arguments
165    ///
166    /// - `Self` - Source style.
167    /// - `AlignItems` - Cross-axis alignment.
168    ///
169    /// # Returns
170    ///
171    /// - `Self` - Updated style.
172    #[must_use]
173    pub fn align(mut self, align: AlignItems) -> Self {
174        self.get_mut_layout().set_align_items(align);
175        self
176    }
177
178    /// Sets flex grow factor.
179    ///
180    /// # Arguments
181    ///
182    /// - `Self` - Source style.
183    /// - `f32` - Flex grow factor.
184    ///
185    /// # Returns
186    ///
187    /// - `Self` - Updated style.
188    #[must_use]
189    pub fn flex_grow(mut self, grow: f32) -> Self {
190        self.get_mut_layout().set_flex_grow(grow.max(0.0));
191        self
192    }
193
194    /// Sets flex shrink factor.
195    ///
196    /// # Arguments
197    ///
198    /// - `Self` - Source style.
199    /// - `f32` - Flex shrink factor.
200    ///
201    /// # Returns
202    ///
203    /// - `Self` - Updated style.
204    #[must_use]
205    pub fn flex_shrink(mut self, shrink: f32) -> Self {
206        self.get_mut_layout().set_flex_shrink(shrink.max(0.0));
207        self
208    }
209
210    /// Sets width length.
211    ///
212    /// # Arguments
213    ///
214    /// - `Self` - Source style.
215    /// - `Length` - Target width.
216    ///
217    /// # Returns
218    ///
219    /// - `Self` - Updated style.
220    #[must_use]
221    pub fn width(mut self, width: Length) -> Self {
222        self.get_mut_layout().set_width(width);
223        self
224    }
225
226    /// Sets height length.
227    ///
228    /// # Arguments
229    ///
230    /// - `Self` - Source style.
231    /// - `Length` - Target height.
232    ///
233    /// # Returns
234    ///
235    /// - `Self` - Updated style.
236    #[must_use]
237    pub fn height(mut self, height: Length) -> Self {
238        self.get_mut_layout().set_height(height);
239        self
240    }
241
242    /// Sets minimum width constraint.
243    ///
244    /// # Arguments
245    ///
246    /// - `Self` - Source style.
247    /// - `Length` - Minimum width.
248    ///
249    /// # Returns
250    ///
251    /// - `Self` - Updated style.
252    #[must_use]
253    pub fn min_width(mut self, min_width: Length) -> Self {
254        self.get_mut_layout().set_min_width(min_width);
255        self
256    }
257
258    /// Sets minimum height constraint.
259    ///
260    /// # Arguments
261    ///
262    /// - `Self` - Source style.
263    /// - `Length` - Minimum height.
264    ///
265    /// # Returns
266    ///
267    /// - `Self` - Updated style.
268    #[must_use]
269    pub fn min_height(mut self, min_height: Length) -> Self {
270        self.get_mut_layout().set_min_height(min_height);
271        self
272    }
273
274    /// Sets maximum width constraint.
275    ///
276    /// # Arguments
277    ///
278    /// - `Self` - Source style.
279    /// - `Length` - Maximum width.
280    ///
281    /// # Returns
282    ///
283    /// - `Self` - Updated style.
284    #[must_use]
285    pub fn max_width(mut self, max_width: Length) -> Self {
286        self.get_mut_layout().set_max_width(max_width);
287        self
288    }
289
290    /// Sets maximum height constraint.
291    ///
292    /// # Arguments
293    ///
294    /// - `Self` - Source style.
295    /// - `Length` - Maximum height.
296    ///
297    /// # Returns
298    ///
299    /// - `Self` - Updated style.
300    #[must_use]
301    pub fn max_height(mut self, max_height: Length) -> Self {
302        self.get_mut_layout().set_max_height(max_height);
303        self
304    }
305
306    /// Sets an explicit width-to-height aspect ratio constraint.
307    ///
308    /// # Arguments
309    ///
310    /// - `Self` - Source style.
311    /// - `f32` - Positive aspect ratio (`width / height`).
312    ///
313    /// # Returns
314    ///
315    /// - `Self` - Updated style.
316    #[must_use]
317    pub fn aspect_ratio(mut self, ratio: f32) -> Self {
318        if ratio > 0.0 && ratio.is_finite() {
319            self.get_mut_layout().set_aspect_ratio(Some(ratio));
320        }
321        self
322    }
323
324    /// Sets uniform gap along both row and column axes.
325    ///
326    /// # Arguments
327    ///
328    /// - `Self` - Source style.
329    /// - `f32` - Gap in logical pixels.
330    ///
331    /// # Returns
332    ///
333    /// - `Self` - Updated style.
334    #[must_use]
335    pub fn gap(mut self, gap: f32) -> Self {
336        let clamped: f32 = gap.max(0.0);
337        self.get_mut_layout().set_row_gap(clamped);
338        self.get_mut_layout().set_column_gap(clamped);
339        self
340    }
341
342    /// Sets inner padding edges.
343    ///
344    /// # Arguments
345    ///
346    /// - `Self` - Source style.
347    /// - `Edges` - Inner padding insets.
348    ///
349    /// # Returns
350    ///
351    /// - `Self` - Updated style.
352    #[must_use]
353    pub fn padding(mut self, padding: Edges) -> Self {
354        self.get_mut_layout().set_padding(padding);
355        self
356    }
357
358    /// Sets outer margin edges.
359    ///
360    /// # Arguments
361    ///
362    /// - `Self` - Source style.
363    /// - `Edges` - Outer margin insets.
364    ///
365    /// # Returns
366    ///
367    /// - `Self` - Updated style.
368    #[must_use]
369    pub fn margin(mut self, margin: Edges) -> Self {
370        self.get_mut_layout().set_margin(margin);
371        self
372    }
373
374    /// Sets overflow behavior.
375    ///
376    /// # Arguments
377    ///
378    /// - `Self` - Source style.
379    /// - `Overflow` - Target overflow behavior.
380    ///
381    /// # Returns
382    ///
383    /// - `Self` - Updated style.
384    #[must_use]
385    pub fn overflow(mut self, overflow: Overflow) -> Self {
386        self.get_mut_layout().set_overflow(overflow);
387        self
388    }
389
390    /// Sets stacking z-index.
391    ///
392    /// # Arguments
393    ///
394    /// - `Self` - Source style.
395    /// - `i32` - Stacking layer index.
396    ///
397    /// # Returns
398    ///
399    /// - `Self` - Updated style.
400    #[must_use]
401    pub fn z_index(mut self, z_index: i32) -> Self {
402        self.get_mut_layout().set_z_index(z_index);
403        self
404    }
405
406    /// Sets absolute or fixed inset coordinates.
407    ///
408    /// # Arguments
409    ///
410    /// - `Self` - Source style.
411    /// - `Option<f32>` - Top offset.
412    /// - `Option<f32>` - Right offset.
413    /// - `Option<f32>` - Bottom offset.
414    /// - `Option<f32>` - Left offset.
415    ///
416    /// # Returns
417    ///
418    /// - `Self` - Updated style.
419    #[must_use]
420    pub fn inset(
421        mut self,
422        top: Option<f32>,
423        right: Option<f32>,
424        bottom: Option<f32>,
425        left: Option<f32>,
426    ) -> Self {
427        self.get_mut_layout().set_top(top);
428        self.get_mut_layout().set_right(right);
429        self.get_mut_layout().set_bottom(bottom);
430        self.get_mut_layout().set_left(left);
431        self
432    }
433
434    /// Sets solid background fill color.
435    ///
436    /// # Arguments
437    ///
438    /// - `Self` - Source style.
439    /// - `Color` - Background color.
440    ///
441    /// # Returns
442    ///
443    /// - `Self` - Updated style.
444    #[must_use]
445    pub fn background(mut self, color: Color) -> Self {
446        self.get_mut_paint().set_background(Some(color));
447        self
448    }
449
450    /// Sets linear gradient fill.
451    ///
452    /// # Arguments
453    ///
454    /// - `Self` - Source style.
455    /// - `LinearGradient` - Linear gradient specification.
456    ///
457    /// # Returns
458    ///
459    /// - `Self` - Updated style.
460    #[must_use]
461    pub fn gradient(mut self, gradient: LinearGradient) -> Self {
462        self.get_mut_paint().set_gradient(Some(gradient));
463        self
464    }
465
466    /// Sets border stroke width and color.
467    ///
468    /// # Arguments
469    ///
470    /// - `Self` - Source style.
471    /// - `f32` - Border width in logical pixels.
472    /// - `Color` - Border color.
473    ///
474    /// # Returns
475    ///
476    /// - `Self` - Updated style.
477    #[must_use]
478    pub fn border(mut self, width: f32, color: Color) -> Self {
479        self.get_mut_paint()
480            .set_border(Border::new(width.max(0.0), color));
481        self
482    }
483
484    /// Sets uniform corner radius.
485    ///
486    /// # Arguments
487    ///
488    /// - `Self` - Source style.
489    /// - `f32` - Corner radius in logical pixels.
490    ///
491    /// # Returns
492    ///
493    /// - `Self` - Updated style.
494    #[must_use]
495    pub fn radius(mut self, radius: f32) -> Self {
496        self.get_mut_paint()
497            .set_radius(CornerRadius::all(radius.max(0.0)));
498        self
499    }
500
501    /// Sets drop shadow.
502    ///
503    /// # Arguments
504    ///
505    /// - `Self` - Source style.
506    /// - `Shadow` - Shadow definition.
507    ///
508    /// # Returns
509    ///
510    /// - `Self` - Updated style.
511    #[must_use]
512    pub fn shadow(mut self, shadow: Shadow) -> Self {
513        self.get_mut_paint().set_shadow(Some(shadow));
514        self
515    }
516
517    /// Sets focus ring stroke.
518    ///
519    /// # Arguments
520    ///
521    /// - `Self` - Source style.
522    /// - `Border` - Focus ring width and color.
523    ///
524    /// # Returns
525    ///
526    /// - `Self` - Updated style.
527    #[must_use]
528    pub fn focus_ring(mut self, ring: Border) -> Self {
529        self.get_mut_paint().set_focus_ring(Some(ring));
530        self
531    }
532
533    /// Sets opacity in `[0.0, 1.0]`.
534    ///
535    /// # Arguments
536    ///
537    /// - `Self` - Source style.
538    /// - `f32` - Opacity factor.
539    ///
540    /// # Returns
541    ///
542    /// - `Self` - Updated style.
543    #[must_use]
544    pub fn opacity(mut self, opacity: f32) -> Self {
545        self.get_mut_paint().set_opacity(opacity.clamp(0.0, 1.0));
546        self
547    }
548
549    /// Sets cursor icon hint.
550    ///
551    /// # Arguments
552    ///
553    /// - `Self` - Source style.
554    /// - `CursorIcon` - Target cursor icon.
555    ///
556    /// # Returns
557    ///
558    /// - `Self` - Updated style.
559    #[must_use]
560    pub fn cursor(mut self, cursor: CursorIcon) -> Self {
561        self.get_mut_paint().set_cursor(cursor);
562        self
563    }
564
565    /// Sets pointer hit-test participation behavior.
566    ///
567    /// # Arguments
568    ///
569    /// - `Self` - Source style.
570    /// - `PointerEvents` - Target pointer-events mode.
571    ///
572    /// # Returns
573    ///
574    /// - `Self` - Updated style.
575    #[must_use]
576    pub fn pointer_events(mut self, pointer_events: PointerEvents) -> Self {
577        self.get_mut_paint().set_pointer_events(pointer_events);
578        self
579    }
580
581    /// Sets foreground text color.
582    ///
583    /// # Arguments
584    ///
585    /// - `Self` - Source style.
586    /// - `Color` - Text color.
587    ///
588    /// # Returns
589    ///
590    /// - `Self` - Updated style.
591    #[must_use]
592    pub fn color(mut self, color: Color) -> Self {
593        self.get_mut_text().set_color(color);
594        self
595    }
596
597    /// Sets font size in logical pixels.
598    ///
599    /// # Arguments
600    ///
601    /// - `Self` - Source style.
602    /// - `f32` - Font size in pixels.
603    ///
604    /// # Returns
605    ///
606    /// - `Self` - Updated style.
607    #[must_use]
608    pub fn font_size(mut self, size: f32) -> Self {
609        self.get_mut_text().set_font_size(size.max(6.0));
610        self
611    }
612
613    /// Sets font weight.
614    ///
615    /// # Arguments
616    ///
617    /// - `Self` - Source style.
618    /// - `FontWeight` - Target font weight.
619    ///
620    /// # Returns
621    ///
622    /// - `Self` - Updated style.
623    #[must_use]
624    pub fn font_weight(mut self, weight: FontWeight) -> Self {
625        self.get_mut_text().set_weight(weight);
626        self
627    }
628
629    /// Sets font family.
630    ///
631    /// # Arguments
632    ///
633    /// - `Self` - Source style.
634    /// - `FontFamily` - Semantic font family.
635    ///
636    /// # Returns
637    ///
638    /// - `Self` - Updated style.
639    #[must_use]
640    pub fn font_family(mut self, family: FontFamily) -> Self {
641        self.get_mut_text().set_family(family);
642        self
643    }
644
645    /// Sets italic font slant.
646    ///
647    /// # Arguments
648    ///
649    /// - `Self` - Source style.
650    /// - `bool` - Whether italic slant is active.
651    ///
652    /// # Returns
653    ///
654    /// - `Self` - Updated style.
655    #[must_use]
656    pub fn italic(mut self, italic: bool) -> Self {
657        self.get_mut_text().set_italic(italic);
658        self
659    }
660
661    /// Sets horizontal text alignment.
662    ///
663    /// # Arguments
664    ///
665    /// - `Self` - Source style.
666    /// - `TextAlign` - Text alignment.
667    ///
668    /// # Returns
669    ///
670    /// - `Self` - Updated style.
671    #[must_use]
672    pub fn text_align(mut self, align: TextAlign) -> Self {
673        self.get_mut_text().set_align(align);
674        self
675    }
676
677    /// Sets text overflow behavior.
678    ///
679    /// # Arguments
680    ///
681    /// - `Self` - Source style.
682    /// - `TextOverflow` - Overflow strategy.
683    ///
684    /// # Returns
685    ///
686    /// - `Self` - Updated style.
687    #[must_use]
688    pub fn text_overflow(mut self, overflow: TextOverflow) -> Self {
689        self.get_mut_text().set_overflow(overflow);
690        self
691    }
692
693    /// Configures whether scroll deltas stop at this node (`true`) or chain/penetrate to parent scrollables (`false`).
694    ///
695    /// # Arguments
696    ///
697    /// - `Self` - Source style.
698    /// - `bool` - `true` blocks scroll penetration to ancestors; `false` permits scroll chaining.
699    ///
700    /// # Returns
701    ///
702    /// - `Self` - Updated style.
703    #[must_use]
704    pub fn stop_scroll_propagation(mut self, stop: bool) -> Self {
705        self.get_mut_paint().set_stop_scroll_propagation(stop);
706        self
707    }
708
709    /// Configures whether click/pointer events stop bubbling at this node (`true`) or bubble to ancestors (`false`).
710    ///
711    /// # Arguments
712    ///
713    /// - `Self` - Source style.
714    /// - `bool` - `true` blocks event bubbling; `false` permits bubbling.
715    ///
716    /// # Returns
717    ///
718    /// - `Self` - Updated style.
719    #[must_use]
720    pub fn stop_event_propagation(mut self, stop: bool) -> Self {
721        self.get_mut_paint().set_stop_event_propagation(stop);
722        self
723    }
724}
725
726/// Resolution helpers for `ResponsiveStyle`.
727impl ResponsiveStyle {
728    /// Resolves the active `Style` for the supplied `Breakpoint`.
729    ///
730    /// # Arguments
731    ///
732    /// - `&Self` - Responsive style definition.
733    /// - `Breakpoint` - Current viewport breakpoint.
734    ///
735    /// # Returns
736    ///
737    /// - `Style` - Resolved concrete style.
738    #[must_use]
739    pub fn resolve(&self, breakpoint: Breakpoint) -> Style {
740        let Self {
741            base,
742            compact,
743            medium,
744        } = *self;
745        match breakpoint {
746            Breakpoint::Compact => compact.unwrap_or(base),
747            Breakpoint::Medium => medium.unwrap_or(base),
748            Breakpoint::Expanded => base,
749        }
750    }
751}
752
753/// `StyleApply` implementation for `Display`.
754impl StyleApply for Display {
755    /// Applies `Display` to `style`.
756    ///
757    /// # Arguments
758    ///
759    /// - `Self` - Target display mode.
760    /// - `Style` - Style accumulator.
761    ///
762    /// # Returns
763    ///
764    /// - `Style` - Updated style.
765    fn apply_to(self, style: Style) -> Style {
766        style.display(self)
767    }
768}
769
770/// `StyleApply` implementation for `Position`.
771impl StyleApply for Position {
772    /// Applies `Position` to `style`.
773    ///
774    /// # Arguments
775    ///
776    /// - `Self` - Target positioning mode.
777    /// - `Style` - Style accumulator.
778    ///
779    /// # Returns
780    ///
781    /// - `Style` - Updated style.
782    fn apply_to(self, style: Style) -> Style {
783        style.position(self)
784    }
785}
786
787/// `StyleApply` implementation for `FlexDirection`.
788impl StyleApply for FlexDirection {
789    /// Applies `FlexDirection` to `style`.
790    ///
791    /// # Arguments
792    ///
793    /// - `Self` - Target flex axis direction.
794    /// - `Style` - Style accumulator.
795    ///
796    /// # Returns
797    ///
798    /// - `Style` - Updated style.
799    fn apply_to(self, style: Style) -> Style {
800        style.direction(self)
801    }
802}
803
804/// `StyleApply` implementation for `FlexWrap`.
805impl StyleApply for FlexWrap {
806    /// Applies `FlexWrap` to `style`.
807    ///
808    /// # Arguments
809    ///
810    /// - `Self` - Target flex wrap mode.
811    /// - `Style` - Style accumulator.
812    ///
813    /// # Returns
814    ///
815    /// - `Style` - Updated style.
816    fn apply_to(self, style: Style) -> Style {
817        style.wrap(self)
818    }
819}
820
821/// `StyleApply` implementation for `JustifyContent`.
822impl StyleApply for JustifyContent {
823    /// Applies `JustifyContent` to `style`.
824    ///
825    /// # Arguments
826    ///
827    /// - `Self` - Target main-axis justification.
828    /// - `Style` - Style accumulator.
829    ///
830    /// # Returns
831    ///
832    /// - `Style` - Updated style.
833    fn apply_to(self, style: Style) -> Style {
834        style.justify(self)
835    }
836}
837
838/// `StyleApply` implementation for `AlignItems`.
839impl StyleApply for AlignItems {
840    /// Applies `AlignItems` to `style`.
841    ///
842    /// # Arguments
843    ///
844    /// - `Self` - Target cross-axis alignment.
845    /// - `Style` - Style accumulator.
846    ///
847    /// # Returns
848    ///
849    /// - `Style` - Updated style.
850    fn apply_to(self, style: Style) -> Style {
851        style.align(self)
852    }
853}
854
855/// `StyleApply` implementation for `Overflow`.
856impl StyleApply for Overflow {
857    /// Applies `Overflow` to `style`.
858    ///
859    /// # Arguments
860    ///
861    /// - `Self` - Target overflow behavior.
862    /// - `Style` - Style accumulator.
863    ///
864    /// # Returns
865    ///
866    /// - `Style` - Updated style.
867    fn apply_to(self, style: Style) -> Style {
868        style.overflow(self)
869    }
870}
871
872/// `StyleApply` implementation for `CursorIcon`.
873impl StyleApply for CursorIcon {
874    /// Applies `CursorIcon` to `style`.
875    ///
876    /// # Arguments
877    ///
878    /// - `Self` - Target cursor hint.
879    /// - `Style` - Style accumulator.
880    ///
881    /// # Returns
882    ///
883    /// - `Style` - Updated style.
884    fn apply_to(self, style: Style) -> Style {
885        style.cursor(self)
886    }
887}
888
889/// `StyleApply` implementation for `PointerEvents`.
890impl StyleApply for PointerEvents {
891    /// Applies `PointerEvents` to `style`.
892    ///
893    /// # Arguments
894    ///
895    /// - `Self` - Target pointer-events mode.
896    /// - `Style` - Style accumulator.
897    ///
898    /// # Returns
899    ///
900    /// - `Style` - Updated style.
901    fn apply_to(self, style: Style) -> Style {
902        style.pointer_events(self)
903    }
904}
905
906/// `StyleApply` implementation for `FontWeight`.
907impl StyleApply for FontWeight {
908    /// Applies `FontWeight` to `style`.
909    ///
910    /// # Arguments
911    ///
912    /// - `Self` - Target font weight.
913    /// - `Style` - Style accumulator.
914    ///
915    /// # Returns
916    ///
917    /// - `Style` - Updated style.
918    fn apply_to(self, style: Style) -> Style {
919        style.font_weight(self)
920    }
921}
922
923/// `StyleApply` implementation for `FontFamily`.
924impl StyleApply for FontFamily {
925    /// Applies `FontFamily` to `style`.
926    ///
927    /// # Arguments
928    ///
929    /// - `Self` - Target font family.
930    /// - `Style` - Style accumulator.
931    ///
932    /// # Returns
933    ///
934    /// - `Style` - Updated style.
935    fn apply_to(self, style: Style) -> Style {
936        style.font_family(self)
937    }
938}
939
940/// `StyleApply` implementation for `TextAlign`.
941impl StyleApply for TextAlign {
942    /// Applies `TextAlign` to `style`.
943    ///
944    /// # Arguments
945    ///
946    /// - `Self` - Target horizontal text alignment.
947    /// - `Style` - Style accumulator.
948    ///
949    /// # Returns
950    ///
951    /// - `Style` - Updated style.
952    fn apply_to(self, style: Style) -> Style {
953        style.text_align(self)
954    }
955}
956
957/// `StyleApply` implementation for `TextOverflow`.
958impl StyleApply for TextOverflow {
959    /// Applies `TextOverflow` to `style`.
960    ///
961    /// # Arguments
962    ///
963    /// - `Self` - Target text overflow strategy.
964    /// - `Style` - Style accumulator.
965    ///
966    /// # Returns
967    ///
968    /// - `Style` - Updated style.
969    fn apply_to(self, style: Style) -> Style {
970        style.text_overflow(self)
971    }
972}
973
974/// `StyleApply` implementation for `Shadow`.
975impl StyleApply for Shadow {
976    /// Applies `Shadow` to `style`.
977    ///
978    /// # Arguments
979    ///
980    /// - `Self` - Drop shadow specification.
981    /// - `Style` - Style accumulator.
982    ///
983    /// # Returns
984    ///
985    /// - `Style` - Updated style.
986    fn apply_to(self, style: Style) -> Style {
987        style.shadow(self)
988    }
989}
990
991/// `StyleApply` implementation for `LinearGradient`.
992impl StyleApply for LinearGradient {
993    /// Applies `LinearGradient` to `style`.
994    ///
995    /// # Arguments
996    ///
997    /// - `Self` - Linear gradient fill.
998    /// - `Style` - Style accumulator.
999    ///
1000    /// # Returns
1001    ///
1002    /// - `Style` - Updated style.
1003    fn apply_to(self, style: Style) -> Style {
1004        style.gradient(self)
1005    }
1006}
1007
1008/// `StyleApply` implementation for `CornerRadius`.
1009impl StyleApply for CornerRadius {
1010    /// Applies `CornerRadius` to `style`.
1011    ///
1012    /// # Arguments
1013    ///
1014    /// - `Self` - Corner radius specification.
1015    /// - `Style` - Style accumulator.
1016    ///
1017    /// # Returns
1018    ///
1019    /// - `Style` - Updated style.
1020    fn apply_to(self, style: Style) -> Style {
1021        let mut out: Style = style;
1022        out.get_mut_paint().set_radius(self);
1023        out
1024    }
1025}
1026
1027/// `StyleApply` implementation for `Style` allowing base-style merging inside newline-separated `style!` blocks.
1028impl StyleApply for Style {
1029    /// Replaces `style` with `self` as a base preset inside `style!`.
1030    ///
1031    /// # Arguments
1032    ///
1033    /// - `Self` - Base style preset.
1034    /// - `Style` - Previous accumulator.
1035    ///
1036    /// # Returns
1037    ///
1038    /// - `Style` - Base style value.
1039    fn apply_to(self, _style: Style) -> Style {
1040        self
1041    }
1042}