euv_core/style/sheet/impl.rs
1use super::*;
2
3/// Fluent zero-allocation builder methods for `Style`.
4impl Style {
5 /// Returns a shared reference to the embedded `LayoutStyle` without copying by value.
6 ///
7 /// # Arguments
8 ///
9 /// - `&Self` - Style reference.
10 ///
11 /// # Returns
12 ///
13 /// - `&LayoutStyle` - Borrowed layout style reference.
14 #[must_use]
15 #[inline(always)]
16 pub fn layout_ref(&self) -> &LayoutStyle {
17 let Self { layout, .. } = self;
18 layout
19 }
20
21 /// Returns a shared reference to the embedded `PaintStyle` without copying by value.
22 ///
23 /// # Arguments
24 ///
25 /// - `&Self` - Style reference.
26 ///
27 /// # Returns
28 ///
29 /// - `&PaintStyle` - Borrowed paint style reference.
30 #[must_use]
31 #[inline(always)]
32 pub fn paint_ref(&self) -> &PaintStyle {
33 let Self { paint, .. } = self;
34 paint
35 }
36
37 /// Returns a shared reference to the embedded `TextStyle` without copying by value.
38 ///
39 /// # Arguments
40 ///
41 /// - `&Self` - Style reference.
42 ///
43 /// # Returns
44 ///
45 /// - `&TextStyle` - Borrowed typography style reference.
46 #[must_use]
47 #[inline(always)]
48 pub fn text_ref(&self) -> &TextStyle {
49 let Self { text, .. } = self;
50 text
51 }
52
53 /// Mutates the embedded `LayoutStyle` directly in place without copying `Style` by value.
54 ///
55 /// # Arguments
56 ///
57 /// - `&Self` - Mutable style reference.
58 /// - `F` - In-place mutation closure receiving `&mut LayoutStyle`.
59 ///
60 /// # Returns
61 ///
62 /// - `&mut Self` - Mutable style reference for chaining.
63 #[inline(always)]
64 pub fn mutate_layout<F>(&mut self, update: F) -> &mut Self
65 where
66 F: FnOnce(&mut LayoutStyle),
67 {
68 update(self.get_mut_layout());
69 self
70 }
71
72 /// Mutates the embedded `PaintStyle` directly in place without copying `Style` by value.
73 ///
74 /// # Arguments
75 ///
76 /// - `&Self` - Mutable style reference.
77 /// - `F` - In-place mutation closure receiving `&mut PaintStyle`.
78 ///
79 /// # Returns
80 ///
81 /// - `&mut Self` - Mutable style reference for chaining.
82 #[inline(always)]
83 pub fn mutate_paint<F>(&mut self, update: F) -> &mut Self
84 where
85 F: FnOnce(&mut PaintStyle),
86 {
87 update(self.get_mut_paint());
88 self
89 }
90
91 /// Mutates the embedded `TextStyle` directly in place without copying `Style` by value.
92 ///
93 /// # Arguments
94 ///
95 /// - `&Self` - Mutable style reference.
96 /// - `F` - In-place mutation closure receiving `&mut TextStyle`.
97 ///
98 /// # Returns
99 ///
100 /// - `&mut Self` - Mutable style reference for chaining.
101 #[inline(always)]
102 pub fn mutate_text<F>(&mut self, update: F) -> &mut Self
103 where
104 F: FnOnce(&mut TextStyle),
105 {
106 update(self.get_mut_text());
107 self
108 }
109
110 /// Sets the flex container axis direction directly in place without copying `Style`.
111 ///
112 /// # Arguments
113 ///
114 /// - `&Self` - Mutable style reference.
115 /// - `FlexDirection` - Target flex axis direction.
116 ///
117 /// # Returns
118 ///
119 /// - `&mut Self` - Mutable style reference for chaining.
120 #[inline(always)]
121 pub fn set_direction_in_place(&mut self, direction: FlexDirection) -> &mut Self {
122 let layout: &mut LayoutStyle = self.get_mut_layout();
123 if layout.get_display() != Display::None {
124 layout.set_display(Display::Flex);
125 }
126 layout.set_flex_direction(direction);
127 self
128 }
129
130 /// Configures a horizontal flex row directly in place without copying `Style`.
131 ///
132 /// # Arguments
133 ///
134 /// - `&Self` - Mutable style reference.
135 ///
136 /// # Returns
137 ///
138 /// - `&mut Self` - Mutable style reference for chaining.
139 #[inline(always)]
140 pub fn set_row_in_place(&mut self) -> &mut Self {
141 self.set_direction_in_place(FlexDirection::Row)
142 }
143
144 /// Configures a vertical flex column directly in place without copying `Style`.
145 ///
146 /// # Arguments
147 ///
148 /// - `&Self` - Mutable style reference.
149 ///
150 /// # Returns
151 ///
152 /// - `&mut Self` - Mutable style reference for chaining.
153 #[inline(always)]
154 pub fn set_column_in_place(&mut self) -> &mut Self {
155 self.set_direction_in_place(FlexDirection::Column)
156 }
157
158 /// Configures a grid layout directly in place without copying `Style`.
159 ///
160 /// # Arguments
161 ///
162 /// - `&Self` - Mutable style reference.
163 /// - `u16` - Number of grid columns (clamped to at least 1).
164 ///
165 /// # Returns
166 ///
167 /// - `&mut Self` - Mutable style reference for chaining.
168 #[inline(always)]
169 pub fn set_grid_in_place(&mut self, columns: u16) -> &mut Self {
170 let layout: &mut LayoutStyle = self.get_mut_layout();
171 if layout.get_display() != Display::None {
172 layout.set_display(Display::Grid);
173 }
174 layout.set_grid_columns(columns.max(1));
175 self
176 }
177
178 /// Sets uniform row and column gaps directly in place without copying `Style`.
179 ///
180 /// # Arguments
181 ///
182 /// - `&Self` - Mutable style reference.
183 /// - `f32` - Gap in logical pixels.
184 ///
185 /// # Returns
186 ///
187 /// - `&mut Self` - Mutable style reference for chaining.
188 #[inline(always)]
189 pub fn set_gap_in_place(&mut self, gap: f32) -> &mut Self {
190 let clamped: f32 = gap.max(0.0);
191 let layout: &mut LayoutStyle = self.get_mut_layout();
192 layout.set_row_gap(clamped);
193 layout.set_column_gap(clamped);
194 self
195 }
196
197 /// Sets solid background fill color directly in place without copying `Style`.
198 ///
199 /// # Arguments
200 ///
201 /// - `&Self` - Mutable style reference.
202 /// - `Color` - Background color.
203 ///
204 /// # Returns
205 ///
206 /// - `&mut Self` - Mutable style reference for chaining.
207 #[inline(always)]
208 pub fn set_background_in_place(&mut self, color: Color) -> &mut Self {
209 self.get_mut_paint().set_background(Some(color));
210 self
211 }
212
213 /// Sets border stroke width and color directly in place without copying `Style`.
214 ///
215 /// # Arguments
216 ///
217 /// - `&Self` - Mutable style reference.
218 /// - `f32` - Border width in logical pixels.
219 /// - `Color` - Border color.
220 ///
221 /// # Returns
222 ///
223 /// - `&mut Self` - Mutable style reference for chaining.
224 #[inline(always)]
225 pub fn set_border_in_place(&mut self, width: f32, color: Color) -> &mut Self {
226 self.get_mut_paint()
227 .set_border(Border::new(width.max(0.0), color));
228 self
229 }
230
231 /// Sets uniform corner radius directly in place without copying `Style`.
232 ///
233 /// # Arguments
234 ///
235 /// - `&Self` - Mutable style reference.
236 /// - `f32` - Corner radius in logical pixels.
237 ///
238 /// # Returns
239 ///
240 /// - `&mut Self` - Mutable style reference for chaining.
241 #[inline(always)]
242 pub fn set_radius_in_place(&mut self, radius: f32) -> &mut Self {
243 self.get_mut_paint()
244 .set_radius(CornerRadius::all(radius.max(0.0)));
245 self
246 }
247
248 /// Sets opacity in `[0.0, 1.0]` directly in place without copying `Style`.
249 ///
250 /// # Arguments
251 ///
252 /// - `&Self` - Mutable style reference.
253 /// - `f32` - Opacity factor.
254 ///
255 /// # Returns
256 ///
257 /// - `&mut Self` - Mutable style reference for chaining.
258 #[inline(always)]
259 pub fn set_opacity_in_place(&mut self, opacity: f32) -> &mut Self {
260 self.get_mut_paint().set_opacity(opacity.clamp(0.0, 1.0));
261 self
262 }
263
264 /// Sets foreground text color directly in place without copying `Style`.
265 ///
266 /// # Arguments
267 ///
268 /// - `&Self` - Mutable style reference.
269 /// - `Color` - Text color.
270 ///
271 /// # Returns
272 ///
273 /// - `&mut Self` - Mutable style reference for chaining.
274 #[inline(always)]
275 pub fn set_color_in_place(&mut self, color: Color) -> &mut Self {
276 self.get_mut_text().set_color(color);
277 self
278 }
279
280 /// Sets font size in logical pixels directly in place without copying `Style`.
281 ///
282 /// # Arguments
283 ///
284 /// - `&Self` - Mutable style reference.
285 /// - `f32` - Font size in pixels.
286 ///
287 /// # Returns
288 ///
289 /// - `&mut Self` - Mutable style reference for chaining.
290 #[inline(always)]
291 pub fn set_font_size_in_place(&mut self, size: f32) -> &mut Self {
292 self.get_mut_text().set_font_size(size.max(6.0));
293 self
294 }
295
296 /// Applies any strongly-typed `StyleApply` value (e.g. `AlignItems::Center`, `Overflow::Hidden`, `Shadow`) to this style.
297 ///
298 /// # Arguments
299 ///
300 /// - `Self` - Source style.
301 /// - `T` - Typed property implementing `StyleApply`.
302 ///
303 /// # Returns
304 ///
305 /// - `Self` - Updated style.
306 #[must_use]
307 #[inline(always)]
308 pub fn apply<T>(self, prop: T) -> Self
309 where
310 T: StyleApply,
311 {
312 prop.apply_to(self)
313 }
314
315 /// Sets the flex container axis direction (`FlexDirection::Row` or `FlexDirection::Column`).
316 ///
317 /// # Arguments
318 ///
319 /// - `Self` - Source style.
320 /// - `FlexDirection` - Target flex axis direction.
321 ///
322 /// # Returns
323 ///
324 /// - `Self` - Updated style.
325 #[must_use]
326 #[inline(always)]
327 pub fn direction(mut self, direction: FlexDirection) -> Self {
328 let _: &mut Self = self.set_direction_in_place(direction);
329 self
330 }
331
332 /// Sets the box display mode.
333 ///
334 /// # Arguments
335 ///
336 /// - `Self` - Source style.
337 /// - `Display` - Target display mode.
338 ///
339 /// # Returns
340 ///
341 /// - `Self` - Updated style.
342 #[must_use]
343 #[inline(always)]
344 pub fn display(mut self, display: Display) -> Self {
345 self.get_mut_layout().set_display(display);
346 self
347 }
348
349 /// Sets the positioning mode.
350 ///
351 /// # Arguments
352 ///
353 /// - `Self` - Source style.
354 /// - `Position` - Target position mode.
355 ///
356 /// # Returns
357 ///
358 /// - `Self` - Updated style.
359 #[must_use]
360 #[inline(always)]
361 pub fn position(mut self, position: Position) -> Self {
362 self.get_mut_layout().set_position(position);
363 self
364 }
365
366 /// Configures a horizontal flex row.
367 ///
368 /// # Arguments
369 ///
370 /// - `Self` - Source style.
371 ///
372 /// # Returns
373 ///
374 /// - `Self` - Updated style.
375 #[must_use]
376 #[inline(always)]
377 pub fn row(mut self) -> Self {
378 let _: &mut Self = self.set_row_in_place();
379 self
380 }
381
382 /// Configures a vertical flex column.
383 ///
384 /// # Arguments
385 ///
386 /// - `Self` - Source style.
387 ///
388 /// # Returns
389 ///
390 /// - `Self` - Updated style.
391 #[must_use]
392 #[inline(always)]
393 pub fn column(mut self) -> Self {
394 let _: &mut Self = self.set_column_in_place();
395 self
396 }
397
398 /// Configures a grid layout with `columns` equal-width columns.
399 ///
400 /// # Arguments
401 ///
402 /// - `Self` - Source style.
403 /// - `u16` - Number of grid columns (clamped to at least 1).
404 ///
405 /// # Returns
406 ///
407 /// - `Self` - Updated style.
408 #[must_use]
409 #[inline(always)]
410 pub fn grid(mut self, columns: u16) -> Self {
411 let _: &mut Self = self.set_grid_in_place(columns);
412 self
413 }
414
415 /// Sets flex wrapping behavior.
416 ///
417 /// # Arguments
418 ///
419 /// - `Self` - Source style.
420 /// - `FlexWrap` - Wrap mode.
421 ///
422 /// # Returns
423 ///
424 /// - `Self` - Updated style.
425 #[must_use]
426 #[inline(always)]
427 pub fn wrap(mut self, wrap: FlexWrap) -> Self {
428 self.get_mut_layout().set_flex_wrap(wrap);
429 self
430 }
431
432 /// Sets main-axis justification.
433 ///
434 /// # Arguments
435 ///
436 /// - `Self` - Source style.
437 /// - `JustifyContent` - Justification mode.
438 ///
439 /// # Returns
440 ///
441 /// - `Self` - Updated style.
442 #[must_use]
443 #[inline(always)]
444 pub fn justify(mut self, justify: JustifyContent) -> Self {
445 self.get_mut_layout().set_justify_content(justify);
446 self
447 }
448
449 /// Sets cross-axis alignment.
450 ///
451 /// # Arguments
452 ///
453 /// - `Self` - Source style.
454 /// - `AlignItems` - Cross-axis alignment.
455 ///
456 /// # Returns
457 ///
458 /// - `Self` - Updated style.
459 #[must_use]
460 #[inline(always)]
461 pub fn align(mut self, align: AlignItems) -> Self {
462 self.get_mut_layout().set_align_items(align);
463 self
464 }
465
466 /// Sets flex grow factor.
467 ///
468 /// # Arguments
469 ///
470 /// - `Self` - Source style.
471 /// - `f32` - Flex grow factor.
472 ///
473 /// # Returns
474 ///
475 /// - `Self` - Updated style.
476 #[must_use]
477 #[inline(always)]
478 pub fn flex_grow(mut self, grow: f32) -> Self {
479 self.get_mut_layout().set_flex_grow(grow.max(0.0));
480 self
481 }
482
483 /// Sets flex shrink factor.
484 ///
485 /// # Arguments
486 ///
487 /// - `Self` - Source style.
488 /// - `f32` - Flex shrink factor.
489 ///
490 /// # Returns
491 ///
492 /// - `Self` - Updated style.
493 #[must_use]
494 #[inline(always)]
495 pub fn flex_shrink(mut self, shrink: f32) -> Self {
496 self.get_mut_layout().set_flex_shrink(shrink.max(0.0));
497 self
498 }
499
500 /// Sets width length.
501 ///
502 /// # Arguments
503 ///
504 /// - `Self` - Source style.
505 /// - `Length` - Target width.
506 ///
507 /// # Returns
508 ///
509 /// - `Self` - Updated style.
510 #[must_use]
511 #[inline(always)]
512 pub fn width(mut self, width: Length) -> Self {
513 self.get_mut_layout().set_width(width);
514 self
515 }
516
517 /// Sets height length.
518 ///
519 /// # Arguments
520 ///
521 /// - `Self` - Source style.
522 /// - `Length` - Target height.
523 ///
524 /// # Returns
525 ///
526 /// - `Self` - Updated style.
527 #[must_use]
528 #[inline(always)]
529 pub fn height(mut self, height: Length) -> Self {
530 self.get_mut_layout().set_height(height);
531 self
532 }
533
534 /// Sets minimum width constraint.
535 ///
536 /// # Arguments
537 ///
538 /// - `Self` - Source style.
539 /// - `Length` - Minimum width.
540 ///
541 /// # Returns
542 ///
543 /// - `Self` - Updated style.
544 #[must_use]
545 #[inline(always)]
546 pub fn min_width(mut self, min_width: Length) -> Self {
547 self.get_mut_layout().set_min_width(min_width);
548 self
549 }
550
551 /// Sets minimum height constraint.
552 ///
553 /// # Arguments
554 ///
555 /// - `Self` - Source style.
556 /// - `Length` - Minimum height.
557 ///
558 /// # Returns
559 ///
560 /// - `Self` - Updated style.
561 #[must_use]
562 #[inline(always)]
563 pub fn min_height(mut self, min_height: Length) -> Self {
564 self.get_mut_layout().set_min_height(min_height);
565 self
566 }
567
568 /// Sets maximum width constraint.
569 ///
570 /// # Arguments
571 ///
572 /// - `Self` - Source style.
573 /// - `Length` - Maximum width.
574 ///
575 /// # Returns
576 ///
577 /// - `Self` - Updated style.
578 #[must_use]
579 #[inline(always)]
580 pub fn max_width(mut self, max_width: Length) -> Self {
581 self.get_mut_layout().set_max_width(max_width);
582 self
583 }
584
585 /// Sets maximum height constraint.
586 ///
587 /// # Arguments
588 ///
589 /// - `Self` - Source style.
590 /// - `Length` - Maximum height.
591 ///
592 /// # Returns
593 ///
594 /// - `Self` - Updated style.
595 #[must_use]
596 #[inline(always)]
597 pub fn max_height(mut self, max_height: Length) -> Self {
598 self.get_mut_layout().set_max_height(max_height);
599 self
600 }
601
602 /// Sets an explicit width-to-height aspect ratio constraint.
603 ///
604 /// # Arguments
605 ///
606 /// - `Self` - Source style.
607 /// - `f32` - Positive aspect ratio (`width / height`).
608 ///
609 /// # Returns
610 ///
611 /// - `Self` - Updated style.
612 #[must_use]
613 #[inline(always)]
614 pub fn aspect_ratio(mut self, ratio: f32) -> Self {
615 if ratio > 0.0 && ratio.is_finite() {
616 self.get_mut_layout().set_aspect_ratio(Some(ratio));
617 }
618 self
619 }
620
621 /// Sets uniform gap along both row and column axes.
622 ///
623 /// # Arguments
624 ///
625 /// - `Self` - Source style.
626 /// - `f32` - Gap in logical pixels.
627 ///
628 /// # Returns
629 ///
630 /// - `Self` - Updated style.
631 #[must_use]
632 #[inline(always)]
633 pub fn gap(mut self, gap: f32) -> Self {
634 let _: &mut Self = self.set_gap_in_place(gap);
635 self
636 }
637
638 /// Sets inner padding edges.
639 ///
640 /// # Arguments
641 ///
642 /// - `Self` - Source style.
643 /// - `Edges` - Inner padding insets.
644 ///
645 /// # Returns
646 ///
647 /// - `Self` - Updated style.
648 #[must_use]
649 #[inline(always)]
650 pub fn padding(mut self, padding: Edges) -> Self {
651 self.get_mut_layout().set_padding(padding);
652 self
653 }
654
655 /// Sets outer margin edges.
656 ///
657 /// # Arguments
658 ///
659 /// - `Self` - Source style.
660 /// - `Edges` - Outer margin insets.
661 ///
662 /// # Returns
663 ///
664 /// - `Self` - Updated style.
665 #[must_use]
666 #[inline(always)]
667 pub fn margin(mut self, margin: Edges) -> Self {
668 self.get_mut_layout().set_margin(margin);
669 self
670 }
671
672 /// Sets overflow behavior.
673 ///
674 /// # Arguments
675 ///
676 /// - `Self` - Source style.
677 /// - `Overflow` - Target overflow behavior.
678 ///
679 /// # Returns
680 ///
681 /// - `Self` - Updated style.
682 #[must_use]
683 #[inline(always)]
684 pub fn overflow(mut self, overflow: Overflow) -> Self {
685 self.get_mut_layout().set_overflow(overflow);
686 self
687 }
688
689 /// Sets stacking z-index.
690 ///
691 /// # Arguments
692 ///
693 /// - `Self` - Source style.
694 /// - `i32` - Stacking layer index.
695 ///
696 /// # Returns
697 ///
698 /// - `Self` - Updated style.
699 #[must_use]
700 #[inline(always)]
701 pub fn z_index(mut self, z_index: i32) -> Self {
702 self.get_mut_layout().set_z_index(z_index);
703 self
704 }
705
706 /// Sets absolute or fixed inset coordinates.
707 ///
708 /// # Arguments
709 ///
710 /// - `Self` - Source style.
711 /// - `Option<f32>` - Top offset.
712 /// - `Option<f32>` - Right offset.
713 /// - `Option<f32>` - Bottom offset.
714 /// - `Option<f32>` - Left offset.
715 ///
716 /// # Returns
717 ///
718 /// - `Self` - Updated style.
719 #[must_use]
720 #[inline(always)]
721 pub fn inset(
722 mut self,
723 top: Option<f32>,
724 right: Option<f32>,
725 bottom: Option<f32>,
726 left: Option<f32>,
727 ) -> Self {
728 self.get_mut_layout().set_top(top);
729 self.get_mut_layout().set_right(right);
730 self.get_mut_layout().set_bottom(bottom);
731 self.get_mut_layout().set_left(left);
732 self
733 }
734
735 /// Sets solid background fill color.
736 ///
737 /// # Arguments
738 ///
739 /// - `Self` - Source style.
740 /// - `Color` - Background color.
741 ///
742 /// # Returns
743 ///
744 /// - `Self` - Updated style.
745 #[must_use]
746 #[inline(always)]
747 pub fn background(mut self, color: Color) -> Self {
748 let _: &mut Self = self.set_background_in_place(color);
749 self
750 }
751
752 /// Sets linear gradient fill.
753 ///
754 /// # Arguments
755 ///
756 /// - `Self` - Source style.
757 /// - `LinearGradient` - Linear gradient specification.
758 ///
759 /// # Returns
760 ///
761 /// - `Self` - Updated style.
762 #[must_use]
763 #[inline(always)]
764 pub fn gradient(mut self, gradient: LinearGradient) -> Self {
765 self.get_mut_paint().set_gradient(Some(gradient));
766 self
767 }
768
769 /// Sets border stroke width and color.
770 ///
771 /// # Arguments
772 ///
773 /// - `Self` - Source style.
774 /// - `f32` - Border width in logical pixels.
775 /// - `Color` - Border color.
776 ///
777 /// # Returns
778 ///
779 /// - `Self` - Updated style.
780 #[must_use]
781 #[inline(always)]
782 pub fn border(mut self, width: f32, color: Color) -> Self {
783 let _: &mut Self = self.set_border_in_place(width, color);
784 self
785 }
786
787 /// Sets uniform corner radius.
788 ///
789 /// # Arguments
790 ///
791 /// - `Self` - Source style.
792 /// - `f32` - Corner radius in logical pixels.
793 ///
794 /// # Returns
795 ///
796 /// - `Self` - Updated style.
797 #[must_use]
798 #[inline(always)]
799 pub fn radius(mut self, radius: f32) -> Self {
800 let _: &mut Self = self.set_radius_in_place(radius);
801 self
802 }
803
804 /// Sets drop shadow.
805 ///
806 /// # Arguments
807 ///
808 /// - `Self` - Source style.
809 /// - `Shadow` - Shadow definition.
810 ///
811 /// # Returns
812 ///
813 /// - `Self` - Updated style.
814 #[must_use]
815 #[inline(always)]
816 pub fn shadow(mut self, shadow: Shadow) -> Self {
817 self.get_mut_paint().set_shadow(Some(shadow));
818 self
819 }
820
821 /// Sets focus ring stroke.
822 ///
823 /// # Arguments
824 ///
825 /// - `Self` - Source style.
826 /// - `Border` - Focus ring width and color.
827 ///
828 /// # Returns
829 ///
830 /// - `Self` - Updated style.
831 #[must_use]
832 #[inline(always)]
833 pub fn focus_ring(mut self, ring: Border) -> Self {
834 self.get_mut_paint().set_focus_ring(Some(ring));
835 self
836 }
837
838 /// Sets opacity in `[0.0, 1.0]`.
839 ///
840 /// # Arguments
841 ///
842 /// - `Self` - Source style.
843 /// - `f32` - Opacity factor.
844 ///
845 /// # Returns
846 ///
847 /// - `Self` - Updated style.
848 #[must_use]
849 #[inline(always)]
850 pub fn opacity(mut self, opacity: f32) -> Self {
851 let _: &mut Self = self.set_opacity_in_place(opacity);
852 self
853 }
854
855 /// Sets cursor icon hint.
856 ///
857 /// # Arguments
858 ///
859 /// - `Self` - Source style.
860 /// - `CursorIcon` - Target cursor icon.
861 ///
862 /// # Returns
863 ///
864 /// - `Self` - Updated style.
865 #[must_use]
866 #[inline(always)]
867 pub fn cursor(mut self, cursor: CursorIcon) -> Self {
868 self.get_mut_paint().set_cursor(cursor);
869 self
870 }
871
872 /// Sets pointer hit-test participation behavior.
873 ///
874 /// # Arguments
875 ///
876 /// - `Self` - Source style.
877 /// - `PointerEvents` - Target pointer-events mode.
878 ///
879 /// # Returns
880 ///
881 /// - `Self` - Updated style.
882 #[must_use]
883 #[inline(always)]
884 pub fn pointer_events(mut self, pointer_events: PointerEvents) -> Self {
885 self.get_mut_paint().set_pointer_events(pointer_events);
886 self
887 }
888
889 /// Sets foreground text color.
890 ///
891 /// # Arguments
892 ///
893 /// - `Self` - Source style.
894 /// - `Color` - Text color.
895 ///
896 /// # Returns
897 ///
898 /// - `Self` - Updated style.
899 #[must_use]
900 #[inline(always)]
901 pub fn color(mut self, color: Color) -> Self {
902 let _: &mut Self = self.set_color_in_place(color);
903 self
904 }
905
906 /// Sets font size in logical pixels.
907 ///
908 /// # Arguments
909 ///
910 /// - `Self` - Source style.
911 /// - `f32` - Font size in pixels.
912 ///
913 /// # Returns
914 ///
915 /// - `Self` - Updated style.
916 #[must_use]
917 #[inline(always)]
918 pub fn font_size(mut self, size: f32) -> Self {
919 let _: &mut Self = self.set_font_size_in_place(size);
920 self
921 }
922
923 /// Sets font weight.
924 ///
925 /// # Arguments
926 ///
927 /// - `Self` - Source style.
928 /// - `FontWeight` - Target font weight.
929 ///
930 /// # Returns
931 ///
932 /// - `Self` - Updated style.
933 #[must_use]
934 #[inline(always)]
935 pub fn font_weight(mut self, weight: FontWeight) -> Self {
936 self.get_mut_text().set_weight(weight);
937 self
938 }
939
940 /// Sets font family.
941 ///
942 /// # Arguments
943 ///
944 /// - `Self` - Source style.
945 /// - `FontFamily` - Semantic font family.
946 ///
947 /// # Returns
948 ///
949 /// - `Self` - Updated style.
950 #[must_use]
951 #[inline(always)]
952 pub fn font_family(mut self, family: FontFamily) -> Self {
953 self.get_mut_text().set_family(family);
954 self
955 }
956
957 /// Sets italic font slant.
958 ///
959 /// # Arguments
960 ///
961 /// - `Self` - Source style.
962 /// - `bool` - Whether italic slant is active.
963 ///
964 /// # Returns
965 ///
966 /// - `Self` - Updated style.
967 #[must_use]
968 #[inline(always)]
969 pub fn italic(mut self, italic: bool) -> Self {
970 self.get_mut_text().set_italic(italic);
971 self
972 }
973
974 /// Sets horizontal text alignment.
975 ///
976 /// # Arguments
977 ///
978 /// - `Self` - Source style.
979 /// - `TextAlign` - Text alignment.
980 ///
981 /// # Returns
982 ///
983 /// - `Self` - Updated style.
984 #[must_use]
985 #[inline(always)]
986 pub fn text_align(mut self, align: TextAlign) -> Self {
987 self.get_mut_text().set_align(align);
988 self
989 }
990
991 /// Sets text overflow behavior.
992 ///
993 /// # Arguments
994 ///
995 /// - `Self` - Source style.
996 /// - `TextOverflow` - Overflow strategy.
997 ///
998 /// # Returns
999 ///
1000 /// - `Self` - Updated style.
1001 #[must_use]
1002 #[inline(always)]
1003 pub fn text_overflow(mut self, overflow: TextOverflow) -> Self {
1004 self.get_mut_text().set_overflow(overflow);
1005 self
1006 }
1007
1008 /// Configures interactive text selection and copy mode on this node and its descendant text subtree.
1009 ///
1010 /// # Arguments
1011 ///
1012 /// - `Self` - Source style.
1013 /// - `TextSelectMode` - Selection mode (`None` disables and opts out, `SelectAndCopy` enables drag selection, `All` selects full block on click).
1014 ///
1015 /// # Returns
1016 ///
1017 /// - `Self` - Updated style.
1018 #[must_use]
1019 #[inline(always)]
1020 pub fn text_select(mut self, mode: TextSelectMode) -> Self {
1021 self.get_mut_text().set_text_select(Some(mode));
1022 self
1023 }
1024
1025 /// Enables or disables native text selection on this node and its descendant text subtree.
1026 ///
1027 /// # Arguments
1028 ///
1029 /// - `Self` - Source style.
1030 /// - `bool` - Whether native text selection is enabled (`true`) or explicitly disabled (`false`).
1031 ///
1032 /// # Returns
1033 ///
1034 /// - `Self` - Updated style.
1035 #[must_use]
1036 #[inline(always)]
1037 pub fn selectable(self, selectable: bool) -> Self {
1038 let mode: TextSelectMode = if selectable {
1039 TextSelectMode::SelectAndCopy
1040 } else {
1041 TextSelectMode::None
1042 };
1043 self.text_select(mode)
1044 }
1045
1046 /// Sets the translucent highlight fill color used when rendering selected text ranges.
1047 ///
1048 /// # Arguments
1049 ///
1050 /// - `Self` - Source style.
1051 /// - `Color` - Selection highlight color.
1052 ///
1053 /// # Returns
1054 ///
1055 /// - `Self` - Updated style.
1056 #[must_use]
1057 #[inline(always)]
1058 pub fn selection_color(mut self, color: Color) -> Self {
1059 self.get_mut_text().set_selection_color(Some(color));
1060 self
1061 }
1062
1063 /// Configures whether scroll deltas stop at this node (`true`) or chain/penetrate to parent scrollables (`false`).
1064 ///
1065 /// # Arguments
1066 ///
1067 /// - `Self` - Source style.
1068 /// - `bool` - `true` blocks scroll penetration to ancestors; `false` permits scroll chaining.
1069 ///
1070 /// # Returns
1071 ///
1072 /// - `Self` - Updated style.
1073 #[must_use]
1074 #[inline(always)]
1075 pub fn stop_scroll_propagation(mut self, stop: bool) -> Self {
1076 self.get_mut_paint().set_stop_scroll_propagation(stop);
1077 self
1078 }
1079
1080 /// Configures whether click/pointer events stop bubbling at this node (`true`) or bubble to ancestors (`false`).
1081 ///
1082 /// # Arguments
1083 ///
1084 /// - `Self` - Source style.
1085 /// - `bool` - `true` blocks event bubbling; `false` permits bubbling.
1086 ///
1087 /// # Returns
1088 ///
1089 /// - `Self` - Updated style.
1090 #[must_use]
1091 #[inline(always)]
1092 pub fn stop_event_propagation(mut self, stop: bool) -> Self {
1093 self.get_mut_paint().set_stop_event_propagation(stop);
1094 self
1095 }
1096
1097 /// Merges all non-default layout, paint, and text properties from `overrides` onto `self`.
1098 ///
1099 /// # Arguments
1100 ///
1101 /// - `Self` - Base component or element style.
1102 /// - `&Self` - Override style whose non-default fields replace base fields.
1103 ///
1104 /// # Returns
1105 ///
1106 /// - `Self` - Combined style with overrides applied.
1107 #[must_use]
1108 pub fn merge_overrides(mut self, overrides: &Self) -> Self {
1109 let def: Self = Self::default();
1110 let ol: LayoutStyle = overrides.get_layout();
1111 let dl: LayoutStyle = def.get_layout();
1112 let ml: &mut LayoutStyle = self.get_mut_layout();
1113 if ol.get_display() != dl.get_display() {
1114 let _: &mut LayoutStyle = ml.set_display(ol.get_display());
1115 }
1116 if ol.get_position() != dl.get_position() {
1117 let _: &mut LayoutStyle = ml.set_position(ol.get_position());
1118 }
1119 if ol.get_flex_direction() != dl.get_flex_direction() {
1120 let _: &mut LayoutStyle = ml.set_flex_direction(ol.get_flex_direction());
1121 }
1122 if ol.get_flex_wrap() != dl.get_flex_wrap() {
1123 let _: &mut LayoutStyle = ml.set_flex_wrap(ol.get_flex_wrap());
1124 }
1125 if ol.get_justify_content() != dl.get_justify_content() {
1126 let _: &mut LayoutStyle = ml.set_justify_content(ol.get_justify_content());
1127 }
1128 if ol.get_align_items() != dl.get_align_items() {
1129 let _: &mut LayoutStyle = ml.set_align_items(ol.get_align_items());
1130 }
1131 if ol.get_align_self() != dl.get_align_self() {
1132 let _: &mut LayoutStyle = ml.set_align_self(ol.get_align_self());
1133 }
1134 if ol.get_overflow() != dl.get_overflow() {
1135 let _: &mut LayoutStyle = ml.set_overflow(ol.get_overflow());
1136 }
1137 if ol.get_flex_basis() != dl.get_flex_basis() {
1138 let _: &mut LayoutStyle = ml.set_flex_basis(ol.get_flex_basis());
1139 }
1140 if ol.get_width() != dl.get_width() {
1141 let _: &mut LayoutStyle = ml.set_width(ol.get_width());
1142 }
1143 if ol.get_height() != dl.get_height() {
1144 let _: &mut LayoutStyle = ml.set_height(ol.get_height());
1145 }
1146 if ol.get_min_width() != dl.get_min_width() {
1147 let _: &mut LayoutStyle = ml.set_min_width(ol.get_min_width());
1148 }
1149 if ol.get_min_height() != dl.get_min_height() {
1150 let _: &mut LayoutStyle = ml.set_min_height(ol.get_min_height());
1151 }
1152 if ol.get_max_width() != dl.get_max_width() {
1153 let _: &mut LayoutStyle = ml.set_max_width(ol.get_max_width());
1154 }
1155 if ol.get_max_height() != dl.get_max_height() {
1156 let _: &mut LayoutStyle = ml.set_max_height(ol.get_max_height());
1157 }
1158 if ol.get_flex_grow() != dl.get_flex_grow() {
1159 let _: &mut LayoutStyle = ml.set_flex_grow(ol.get_flex_grow());
1160 }
1161 if ol.get_flex_shrink() != dl.get_flex_shrink() {
1162 let _: &mut LayoutStyle = ml.set_flex_shrink(ol.get_flex_shrink());
1163 }
1164 if ol.get_margin() != dl.get_margin() {
1165 let _: &mut LayoutStyle = ml.set_margin(ol.get_margin());
1166 }
1167 if ol.get_padding() != dl.get_padding() {
1168 let _: &mut LayoutStyle = ml.set_padding(ol.get_padding());
1169 }
1170 if ol.get_row_gap() != dl.get_row_gap() {
1171 let _: &mut LayoutStyle = ml.set_row_gap(ol.get_row_gap());
1172 }
1173 if ol.get_column_gap() != dl.get_column_gap() {
1174 let _: &mut LayoutStyle = ml.set_column_gap(ol.get_column_gap());
1175 }
1176 if let Some(top) = ol.top_offset() {
1177 let _: &mut LayoutStyle = ml.set_top(Some(top));
1178 }
1179 if let Some(right) = ol.right_offset() {
1180 let _: &mut LayoutStyle = ml.set_right(Some(right));
1181 }
1182 if let Some(bottom) = ol.bottom_offset() {
1183 let _: &mut LayoutStyle = ml.set_bottom(Some(bottom));
1184 }
1185 if let Some(left) = ol.left_offset() {
1186 let _: &mut LayoutStyle = ml.set_left(Some(left));
1187 }
1188 if let Some(ratio) = ol.aspect_ratio_value() {
1189 let _: &mut LayoutStyle = ml.set_aspect_ratio(Some(ratio));
1190 }
1191 if ol.get_z_index() != dl.get_z_index() {
1192 let _: &mut LayoutStyle = ml.set_z_index(ol.get_z_index());
1193 }
1194 if ol.get_grid_columns() != dl.get_grid_columns() {
1195 let _: &mut LayoutStyle = ml.set_grid_columns(ol.get_grid_columns());
1196 }
1197 let op: PaintStyle = overrides.get_paint();
1198 let dp: PaintStyle = def.get_paint();
1199 let mp: &mut PaintStyle = self.get_mut_paint();
1200 if let Some(bg) = op.background_color() {
1201 let _: &mut PaintStyle = mp.set_background(Some(bg));
1202 }
1203 if let Some(grad) = op.background_gradient() {
1204 let _: &mut PaintStyle = mp.set_gradient(Some(grad));
1205 }
1206 if op.get_border() != dp.get_border() {
1207 let _: &mut PaintStyle = mp.set_border(op.get_border());
1208 }
1209 if op.get_radius() != dp.get_radius() {
1210 let _: &mut PaintStyle = mp.set_radius(op.get_radius());
1211 }
1212 if let Some(shadow) = op.box_shadow() {
1213 let _: &mut PaintStyle = mp.set_shadow(Some(shadow));
1214 }
1215 if let Some(ring) = op.focus_ring_border() {
1216 let _: &mut PaintStyle = mp.set_focus_ring(Some(ring));
1217 }
1218 if op.get_opacity() != dp.get_opacity() {
1219 let _: &mut PaintStyle = mp.set_opacity(op.get_opacity());
1220 }
1221 if op.get_transform() != dp.get_transform() {
1222 let _: &mut PaintStyle = mp.set_transform(op.get_transform());
1223 }
1224 if op.get_cursor() != dp.get_cursor() {
1225 let _: &mut PaintStyle = mp.set_cursor(op.get_cursor());
1226 }
1227 if op.get_pointer_events() != dp.get_pointer_events() {
1228 let _: &mut PaintStyle = mp.set_pointer_events(op.get_pointer_events());
1229 }
1230 if op.get_stop_scroll_propagation() != dp.get_stop_scroll_propagation() {
1231 let _: &mut PaintStyle =
1232 mp.set_stop_scroll_propagation(op.get_stop_scroll_propagation());
1233 }
1234 if op.get_stop_event_propagation() != dp.get_stop_event_propagation() {
1235 let _: &mut PaintStyle = mp.set_stop_event_propagation(op.get_stop_event_propagation());
1236 }
1237 let ot: TextStyle = overrides.get_text();
1238 let dt: TextStyle = def.get_text();
1239 let mt: &mut TextStyle = self.get_mut_text();
1240 if ot.get_family() != dt.get_family() {
1241 let _: &mut TextStyle = mt.set_family(ot.get_family());
1242 }
1243 if ot.get_font_size() != dt.get_font_size() {
1244 let _: &mut TextStyle = mt.set_font_size(ot.get_font_size());
1245 }
1246 if ot.get_weight() != dt.get_weight() {
1247 let _: &mut TextStyle = mt.set_weight(ot.get_weight());
1248 }
1249 if ot.get_line_height() != dt.get_line_height() {
1250 let _: &mut TextStyle = mt.set_line_height(ot.get_line_height());
1251 }
1252 if ot.get_letter_spacing() != dt.get_letter_spacing() {
1253 let _: &mut TextStyle = mt.set_letter_spacing(ot.get_letter_spacing());
1254 }
1255 if ot.get_align() != dt.get_align() {
1256 let _: &mut TextStyle = mt.set_align(ot.get_align());
1257 }
1258 if ot.get_overflow() != dt.get_overflow() {
1259 let _: &mut TextStyle = mt.set_overflow(ot.get_overflow());
1260 }
1261 if ot.get_color() != dt.get_color() {
1262 let _: &mut TextStyle = mt.set_color(ot.get_color());
1263 }
1264 if ot.get_italic() != dt.get_italic() {
1265 let _: &mut TextStyle = mt.set_italic(ot.get_italic());
1266 }
1267 if ot.get_underline() != dt.get_underline() {
1268 let _: &mut TextStyle = mt.set_underline(ot.get_underline());
1269 }
1270 if ot.get_strikethrough() != dt.get_strikethrough() {
1271 let _: &mut TextStyle = mt.set_strikethrough(ot.get_strikethrough());
1272 }
1273 if let Some(mode) = ot.text_select_mode() {
1274 let _: &mut TextStyle = mt.set_text_select(Some(mode));
1275 }
1276 if let Some(sel_color) = ot.selection_color() {
1277 let _: &mut TextStyle = mt.set_selection_color(Some(sel_color));
1278 }
1279 self
1280 }
1281
1282 /// Applies an optional override `Style` on top of `self` when present.
1283 ///
1284 /// # Arguments
1285 ///
1286 /// - `Self` - Base style.
1287 /// - `Option<Self>` - Optional override style.
1288 ///
1289 /// # Returns
1290 ///
1291 /// - `Self` - Combined style if `overrides` is `Some`, otherwise `self`.
1292 #[must_use]
1293 #[inline(always)]
1294 pub fn with_overrides(self, overrides: Option<Self>) -> Self {
1295 match overrides {
1296 Some(extra) => self.merge_overrides(&extra),
1297 None => self,
1298 }
1299 }
1300}
1301
1302/// Resolution helpers for `ResponsiveStyle`.
1303impl ResponsiveStyle {
1304 /// Resolves the active `Style` for the supplied `Breakpoint`.
1305 ///
1306 /// # Arguments
1307 ///
1308 /// - `&Self` - Responsive style definition.
1309 /// - `Breakpoint` - Current viewport breakpoint.
1310 ///
1311 /// # Returns
1312 ///
1313 /// - `Style` - Resolved concrete style.
1314 #[must_use]
1315 #[inline(always)]
1316 pub fn resolve(&self, breakpoint: Breakpoint) -> Style {
1317 let Self {
1318 base,
1319 compact,
1320 medium,
1321 } = *self;
1322 match breakpoint {
1323 Breakpoint::Compact => compact.unwrap_or(base),
1324 Breakpoint::Medium => medium.unwrap_or(base),
1325 Breakpoint::Expanded => base,
1326 }
1327 }
1328}
1329
1330/// `StyleApply` implementation for `Display`.
1331impl StyleApply for Display {
1332 /// Applies `Display` to `style`.
1333 ///
1334 /// # Arguments
1335 ///
1336 /// - `Self` - Target display mode.
1337 /// - `Style` - Style accumulator.
1338 ///
1339 /// # Returns
1340 ///
1341 /// - `Style` - Updated style.
1342 #[inline(always)]
1343 fn apply_to(self, style: Style) -> Style {
1344 style.display(self)
1345 }
1346}
1347
1348/// `StyleApply` implementation for `Position`.
1349impl StyleApply for Position {
1350 /// Applies `Position` to `style`.
1351 ///
1352 /// # Arguments
1353 ///
1354 /// - `Self` - Target positioning mode.
1355 /// - `Style` - Style accumulator.
1356 ///
1357 /// # Returns
1358 ///
1359 /// - `Style` - Updated style.
1360 #[inline(always)]
1361 fn apply_to(self, style: Style) -> Style {
1362 style.position(self)
1363 }
1364}
1365
1366/// `StyleApply` implementation for `FlexDirection`.
1367impl StyleApply for FlexDirection {
1368 /// Applies `FlexDirection` to `style`.
1369 ///
1370 /// # Arguments
1371 ///
1372 /// - `Self` - Target flex axis direction.
1373 /// - `Style` - Style accumulator.
1374 ///
1375 /// # Returns
1376 ///
1377 /// - `Style` - Updated style.
1378 #[inline(always)]
1379 fn apply_to(self, style: Style) -> Style {
1380 style.direction(self)
1381 }
1382}
1383
1384/// `StyleApply` implementation for `FlexWrap`.
1385impl StyleApply for FlexWrap {
1386 /// Applies `FlexWrap` to `style`.
1387 ///
1388 /// # Arguments
1389 ///
1390 /// - `Self` - Target flex wrap mode.
1391 /// - `Style` - Style accumulator.
1392 ///
1393 /// # Returns
1394 ///
1395 /// - `Style` - Updated style.
1396 #[inline(always)]
1397 fn apply_to(self, style: Style) -> Style {
1398 style.wrap(self)
1399 }
1400}
1401
1402/// `StyleApply` implementation for `JustifyContent`.
1403impl StyleApply for JustifyContent {
1404 /// Applies `JustifyContent` to `style`.
1405 ///
1406 /// # Arguments
1407 ///
1408 /// - `Self` - Target main-axis justification.
1409 /// - `Style` - Style accumulator.
1410 ///
1411 /// # Returns
1412 ///
1413 /// - `Style` - Updated style.
1414 #[inline(always)]
1415 fn apply_to(self, style: Style) -> Style {
1416 style.justify(self)
1417 }
1418}
1419
1420/// `StyleApply` implementation for `AlignItems`.
1421impl StyleApply for AlignItems {
1422 /// Applies `AlignItems` to `style`.
1423 ///
1424 /// # Arguments
1425 ///
1426 /// - `Self` - Target cross-axis alignment.
1427 /// - `Style` - Style accumulator.
1428 ///
1429 /// # Returns
1430 ///
1431 /// - `Style` - Updated style.
1432 #[inline(always)]
1433 fn apply_to(self, style: Style) -> Style {
1434 style.align(self)
1435 }
1436}
1437
1438/// `StyleApply` implementation for `Overflow`.
1439impl StyleApply for Overflow {
1440 /// Applies `Overflow` to `style`.
1441 ///
1442 /// # Arguments
1443 ///
1444 /// - `Self` - Target overflow behavior.
1445 /// - `Style` - Style accumulator.
1446 ///
1447 /// # Returns
1448 ///
1449 /// - `Style` - Updated style.
1450 #[inline(always)]
1451 fn apply_to(self, style: Style) -> Style {
1452 style.overflow(self)
1453 }
1454}
1455
1456/// `StyleApply` implementation for `CursorIcon`.
1457impl StyleApply for CursorIcon {
1458 /// Applies `CursorIcon` to `style`.
1459 ///
1460 /// # Arguments
1461 ///
1462 /// - `Self` - Target cursor hint.
1463 /// - `Style` - Style accumulator.
1464 ///
1465 /// # Returns
1466 ///
1467 /// - `Style` - Updated style.
1468 #[inline(always)]
1469 fn apply_to(self, style: Style) -> Style {
1470 style.cursor(self)
1471 }
1472}
1473
1474/// `StyleApply` implementation for `PointerEvents`.
1475impl StyleApply for PointerEvents {
1476 /// Applies `PointerEvents` to `style`.
1477 ///
1478 /// # Arguments
1479 ///
1480 /// - `Self` - Target pointer-events mode.
1481 /// - `Style` - Style accumulator.
1482 ///
1483 /// # Returns
1484 ///
1485 /// - `Style` - Updated style.
1486 #[inline(always)]
1487 fn apply_to(self, style: Style) -> Style {
1488 style.pointer_events(self)
1489 }
1490}
1491
1492/// `StyleApply` implementation for `FontWeight`.
1493impl StyleApply for FontWeight {
1494 /// Applies `FontWeight` to `style`.
1495 ///
1496 /// # Arguments
1497 ///
1498 /// - `Self` - Target font weight.
1499 /// - `Style` - Style accumulator.
1500 ///
1501 /// # Returns
1502 ///
1503 /// - `Style` - Updated style.
1504 #[inline(always)]
1505 fn apply_to(self, style: Style) -> Style {
1506 style.font_weight(self)
1507 }
1508}
1509
1510/// `StyleApply` implementation for `FontFamily`.
1511impl StyleApply for FontFamily {
1512 /// Applies `FontFamily` to `style`.
1513 ///
1514 /// # Arguments
1515 ///
1516 /// - `Self` - Target font family.
1517 /// - `Style` - Style accumulator.
1518 ///
1519 /// # Returns
1520 ///
1521 /// - `Style` - Updated style.
1522 #[inline(always)]
1523 fn apply_to(self, style: Style) -> Style {
1524 style.font_family(self)
1525 }
1526}
1527
1528/// `StyleApply` implementation for `TextAlign`.
1529impl StyleApply for TextAlign {
1530 /// Applies `TextAlign` to `style`.
1531 ///
1532 /// # Arguments
1533 ///
1534 /// - `Self` - Target horizontal text alignment.
1535 /// - `Style` - Style accumulator.
1536 ///
1537 /// # Returns
1538 ///
1539 /// - `Style` - Updated style.
1540 #[inline(always)]
1541 fn apply_to(self, style: Style) -> Style {
1542 style.text_align(self)
1543 }
1544}
1545
1546/// `StyleApply` implementation for `TextOverflow`.
1547impl StyleApply for TextOverflow {
1548 /// Applies `TextOverflow` to `style`.
1549 ///
1550 /// # Arguments
1551 ///
1552 /// - `Self` - Target text overflow strategy.
1553 /// - `Style` - Style accumulator.
1554 ///
1555 /// # Returns
1556 ///
1557 /// - `Style` - Updated style.
1558 #[inline(always)]
1559 fn apply_to(self, style: Style) -> Style {
1560 style.text_overflow(self)
1561 }
1562}
1563
1564/// `StyleApply` implementation for `Shadow`.
1565impl StyleApply for Shadow {
1566 /// Applies `Shadow` to `style`.
1567 ///
1568 /// # Arguments
1569 ///
1570 /// - `Self` - Drop shadow specification.
1571 /// - `Style` - Style accumulator.
1572 ///
1573 /// # Returns
1574 ///
1575 /// - `Style` - Updated style.
1576 #[inline(always)]
1577 fn apply_to(self, style: Style) -> Style {
1578 style.shadow(self)
1579 }
1580}
1581
1582/// `StyleApply` implementation for `LinearGradient`.
1583impl StyleApply for LinearGradient {
1584 /// Applies `LinearGradient` to `style`.
1585 ///
1586 /// # Arguments
1587 ///
1588 /// - `Self` - Linear gradient fill.
1589 /// - `Style` - Style accumulator.
1590 ///
1591 /// # Returns
1592 ///
1593 /// - `Style` - Updated style.
1594 #[inline(always)]
1595 fn apply_to(self, style: Style) -> Style {
1596 style.gradient(self)
1597 }
1598}
1599
1600/// `StyleApply` implementation for `CornerRadius`.
1601impl StyleApply for CornerRadius {
1602 /// Applies `CornerRadius` to `style`.
1603 ///
1604 /// # Arguments
1605 ///
1606 /// - `Self` - Corner radius specification.
1607 /// - `Style` - Style accumulator.
1608 ///
1609 /// # Returns
1610 ///
1611 /// - `Style` - Updated style.
1612 #[inline(always)]
1613 fn apply_to(self, style: Style) -> Style {
1614 let mut out: Style = style;
1615 out.get_mut_paint().set_radius(self);
1616 out
1617 }
1618}
1619
1620/// `StyleApply` implementation for `Style` allowing base-style merging inside newline-separated `style!` blocks.
1621impl StyleApply for Style {
1622 /// Replaces `style` with `self` as a base preset inside `style!`.
1623 ///
1624 /// # Arguments
1625 ///
1626 /// - `Self` - Base style preset.
1627 /// - `Style` - Previous accumulator.
1628 ///
1629 /// # Returns
1630 ///
1631 /// - `Style` - Base style value.
1632 #[inline(always)]
1633 fn apply_to(self, _style: Style) -> Style {
1634 self
1635 }
1636}