quickgui 0.1.1

A damage-driven, GPU-accelerated desktop GUI foundation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
use super::*;

impl Element {
    pub fn padding_axis(mut self, vertical: f32, horizontal: f32) -> Self {
        self.layout.padding = TaffyRect {
            left: LengthPercentage::length(horizontal),
            right: LengthPercentage::length(horizontal),
            top: LengthPercentage::length(vertical),
            bottom: LengthPercentage::length(vertical),
        };
        self
    }

    pub fn bg(mut self, color: Color) -> Self {
        self.visual.background = Some(color);
        self
    }

    /// Set the opacity of this element and all of its descendants.
    ///
    /// Opacity is paint-only: transparent elements keep their layout, pointer behavior, focus,
    /// and accessibility semantics. Nested opacity values multiply like GPUI and the web.
    pub fn opacity(mut self, opacity: f32) -> Self {
        self.visual.opacity = finite_opacity(opacity);
        self
    }

    pub fn border(mut self, width: f32, color: Color) -> Self {
        let width = width.max(0.0);
        self.visual.border_width = width;
        self.visual.border_color = Some(color);
        self.layout.border = TaffyRect {
            left: LengthPercentage::length(width),
            right: LengthPercentage::length(width),
            top: LengthPercentage::length(width),
            bottom: LengthPercentage::length(width),
        };
        self
    }

    pub fn rounded(mut self, radius: f32) -> Self {
        self.visual.radius = radius.max(0.0);
        self
    }

    pub fn rounded_sm(self) -> Self {
        self.rounded(4.0)
    }
    pub fn rounded_md(self) -> Self {
        self.rounded(6.0)
    }
    pub fn rounded_lg(self) -> Self {
        self.rounded(8.0)
    }
    pub fn rounded_xl(self) -> Self {
        self.rounded(12.0)
    }
    pub fn rounded_2xl(self) -> Self {
        self.rounded(16.0)
    }

    /// Paint one CSS-like box shadow without affecting layout.
    pub fn shadow(mut self, shadow: BoxShadow) -> Self {
        self.visual.shadows = Some(Arc::from([shadow]));
        self
    }

    /// Paint multiple CSS-like box shadows in declaration order.
    ///
    /// As on the web, the first shadow is painted on top of later shadows.
    pub fn shadows(mut self, shadows: impl IntoIterator<Item = BoxShadow>) -> Self {
        self.visual.shadows = Some(collect_box_shadows(shadows));
        self
    }

    pub fn shadow_none(mut self) -> Self {
        self.visual.shadows = None;
        self
    }

    pub fn shadow_sm(self) -> Self {
        self.shadow(shadow_sm_preset())
    }

    pub fn shadow_md(self) -> Self {
        self.shadows(shadow_md_preset())
    }

    pub fn shadow_lg(self) -> Self {
        self.shadows(shadow_lg_preset())
    }

    pub fn shadow_xl(self) -> Self {
        self.shadows(shadow_xl_preset())
    }

    pub fn shadow_2xl(self) -> Self {
        self.shadow(shadow_2xl_preset())
    }

    /// Choose how image, SVG, or path content is fitted into its layout box.
    pub fn object_fit(mut self, fit: ObjectFit) -> Self {
        match &mut self.kind {
            ElementKind::Image(image) => image.object_fit = fit,
            ElementKind::Svg(svg) => svg.object_fit = fit,
            ElementKind::Path(path) => path.object_fit = fit,
            _ => {}
        }
        self
    }

    /// Override a path element's inherited text color with a solid color or linear gradient.
    pub fn path_background(mut self, background: impl Into<Background>) -> Self {
        if let ElementKind::Path(path) = &mut self.kind {
            path.background = Some(background.into());
        }
        self
    }

    /// Replace the four parameter vectors supplied to this custom shader instance.
    pub fn shader_parameters(mut self, parameters: impl Into<ShaderParameters>) -> Self {
        let ElementKind::CustomShader(shader) = &mut self.kind else {
            panic!("shader_parameters can only be applied to a custom shader element");
        };
        shader.parameters = parameters.into();
        self
    }

    /// Apply a render-only transform to SVG content without affecting flexbox layout.
    pub fn svg_transform(mut self, transform: SvgTransform) -> Self {
        if let ElementKind::Svg(svg) = &mut self.kind {
            svg.transform = transform;
        }
        self
    }

    /// Render an image in grayscale without creating another decoded image.
    pub fn grayscale(mut self, grayscale: bool) -> Self {
        if let ElementKind::Image(image) = &mut self.kind {
            image.grayscale = grayscale;
        }
        self
    }

    /// Render a replacement element when an image resource has been loading for 200 ms.
    pub fn with_loading<E: IntoElement + 'static>(
        mut self,
        render: impl Fn() -> E + 'static,
    ) -> Self {
        if let ElementKind::Image(image) = &mut self.kind {
            image.loading = Some(ImageReplacement::new(render));
        }
        self
    }

    /// Render a replacement element when an image resource fails to load.
    pub fn with_fallback<E: IntoElement + 'static>(
        mut self,
        render: impl Fn() -> E + 'static,
    ) -> Self {
        if let ElementKind::Image(image) = &mut self.kind {
            image.fallback = Some(ImageReplacement::new(render));
        }
        self
    }

    pub fn text_color(mut self, color: Color) -> Self {
        self.typography.color = Some(color);
        self
    }

    pub fn text_size(mut self, size: f32) -> Self {
        self.typography.font_size = Some(size.max(1.0));
        self
    }

    pub fn line_height(mut self, height: f32) -> Self {
        self.typography.line_height = Some(height.max(1.0));
        self
    }

    /// Quantize glyph advances to one logical monospace cell width.
    pub fn monospace_width(mut self, width: f32) -> Self {
        self.typography.monospace_width = Some(width.max(1.0));
        self
    }

    pub fn text_xs(self) -> Self {
        self.text_size(12.0).line_height(16.0)
    }
    pub fn text_sm(self) -> Self {
        self.text_size(14.0).line_height(20.0)
    }
    pub fn text_base(self) -> Self {
        self.text_size(16.0).line_height(24.0)
    }
    pub fn text_lg(self) -> Self {
        self.text_size(18.0).line_height(26.0)
    }
    pub fn text_xl(self) -> Self {
        self.text_size(20.0).line_height(28.0)
    }
    pub fn text_2xl(self) -> Self {
        self.text_size(24.0).line_height(32.0)
    }
    pub fn text_3xl(self) -> Self {
        self.text_size(30.0).line_height(36.0)
    }

    pub fn font_weight(mut self, weight: Weight) -> Self {
        self.typography.weight = Some(weight);
        self
    }

    pub fn font_normal(self) -> Self {
        self.font_weight(Weight::NORMAL)
    }

    pub fn font_medium(self) -> Self {
        self.font_weight(Weight::MEDIUM)
    }

    pub fn font_semibold(self) -> Self {
        self.font_weight(Weight::SEMIBOLD)
    }

    pub fn font_bold(self) -> Self {
        self.font_weight(Weight::BOLD)
    }

    /// Set the inherited font slant.
    pub fn font_style(mut self, style: GlyphStyle) -> Self {
        self.typography.font_style = Some(style);
        self
    }

    pub fn italic(self) -> Self {
        self.font_style(GlyphStyle::Italic)
    }

    pub fn not_italic(self) -> Self {
        self.font_style(GlyphStyle::Normal)
    }

    /// Optically thicken descendant glyph stems without selecting a heavier font face.
    pub fn font_thicken(mut self, thicken: bool) -> Self {
        self.typography.font_thicken = Some(thicken);
        self
    }

    /// Underline descendant text with the font's native single-line metrics.
    pub fn underline(mut self) -> Self {
        self.typography.underline = Some(TextUnderline::Single);
        self.typography.underline_wavy = Some(false);
        self.typography.underline_thickness = Some(1.0);
        self
    }

    /// Underline descendant text with two native lines.
    pub fn double_underline(mut self) -> Self {
        self.typography.underline = Some(TextUnderline::Double);
        self.typography.underline_wavy = Some(false);
        self.typography.underline_thickness = Some(1.0);
        self
    }

    /// Strike through descendant text with the font's native metrics.
    pub fn line_through(mut self) -> Self {
        self.typography.strikethrough = Some(true);
        self
    }

    /// Remove inherited underline and strikethrough decoration.
    pub fn text_decoration_none(mut self) -> Self {
        self.typography.underline = Some(TextUnderline::None);
        self.typography.underline_color = Some(None);
        self.typography.underline_wavy = Some(false);
        self.typography.underline_thickness = Some(1.0);
        self.typography.strikethrough = Some(false);
        self.typography.strikethrough_color = Some(None);
        self
    }

    /// Set the inherited underline color, enabling a single underline when needed.
    pub fn text_decoration_color(mut self, color: Color) -> Self {
        if self
            .typography
            .underline
            .is_none_or(|underline| underline == TextUnderline::None)
        {
            self.typography.underline = Some(TextUnderline::Single);
            self.typography.underline_wavy = Some(false);
            self.typography.underline_thickness = Some(1.0);
        }
        self.typography.underline_color = Some(Some(color));
        self
    }

    /// Use an ordinary solid underline, enabling one when no underline is inherited.
    pub fn text_decoration_solid(mut self) -> Self {
        let enables_underline = self
            .typography
            .underline
            .is_none_or(|underline| underline == TextUnderline::None);
        if enables_underline {
            self.typography.underline = Some(TextUnderline::Single);
            self.typography.underline_thickness = Some(1.0);
        }
        self.typography.underline_wavy = Some(false);
        self
    }

    /// Use a GPU-rendered spell-checker-style wavy underline.
    pub fn text_decoration_wavy(mut self) -> Self {
        let enables_underline = self
            .typography
            .underline
            .is_none_or(|underline| underline == TextUnderline::None);
        if enables_underline {
            self.typography.underline = Some(TextUnderline::Single);
            self.typography.underline_thickness = Some(1.0);
        }
        self.typography.underline_wavy = Some(true);
        self
    }

    fn text_decoration_thickness(mut self, thickness: f32) -> Self {
        if self
            .typography
            .underline
            .is_none_or(|underline| underline == TextUnderline::None)
        {
            self.typography.underline = Some(TextUnderline::Single);
        }
        self.typography.underline_thickness = Some(thickness);
        self
    }

    pub fn text_decoration_0(self) -> Self {
        self.text_decoration_thickness(0.0)
    }

    pub fn text_decoration_1(self) -> Self {
        self.text_decoration_thickness(1.0)
    }

    pub fn text_decoration_2(self) -> Self {
        self.text_decoration_thickness(2.0)
    }

    pub fn text_decoration_4(self) -> Self {
        self.text_decoration_thickness(4.0)
    }

    pub fn text_decoration_8(self) -> Self {
        self.text_decoration_thickness(8.0)
    }

    pub fn font_family(mut self, family: impl Into<FontFamily>) -> Self {
        let family = family.into();
        assert_valid_font_family(&family);
        self.typography.family = Some(family);
        self
    }

    /// Set the inherited OpenType feature table used while shaping descendant text.
    pub fn font_features(mut self, features: FontFeatures) -> Self {
        self.typography.features = Some(features);
        self
    }

    /// Set the ordered families tried after the primary family and before platform fallbacks.
    ///
    /// Passing an empty stack intentionally clears an inherited custom fallback stack.
    pub fn font_fallbacks(mut self, fallbacks: FontFallbacks) -> Self {
        self.typography.fallbacks = Some((!fallbacks.is_empty()).then_some(fallbacks));
        self
    }

    /// Replace the complete inherited font configuration.
    pub fn font(mut self, font: Font) -> Self {
        assert_valid_font_family(&font.family);
        self.typography.family = Some(font.family);
        self.typography.features = Some(font.features);
        self.typography.fallbacks = Some(normalize_fallbacks(font.fallbacks));
        self.typography.weight = Some(font.weight);
        self.typography.font_style = Some(font.style);
        self
    }

    /// Align descendant text lines within their assigned element width.
    pub fn text_align(mut self, align: TextAlign) -> Self {
        self.typography.align = Some(align);
        self
    }

    pub fn text_left(self) -> Self {
        self.text_align(TextAlign::Left)
    }

    pub fn text_center(self) -> Self {
        self.text_align(TextAlign::Center)
    }

    pub fn text_right(self) -> Self {
        self.text_align(TextAlign::Right)
    }

    pub fn text_justify(self) -> Self {
        self.text_align(TextAlign::Justify)
    }

    pub fn no_wrap(mut self) -> Self {
        self.typography.wrap = Some(TextWrap::None);
        self
    }

    /// Set inherited CSS-like whitespace behavior.
    pub fn white_space(mut self, white_space: WhiteSpace) -> Self {
        self.typography.wrap = Some(white_space.into());
        self
    }

    /// Allow ordinary word wrapping, matching GPUI and `white-space: normal` on the web.
    pub fn whitespace_normal(self) -> Self {
        self.white_space(WhiteSpace::Normal)
    }

    /// Keep each logical line unwrapped, matching GPUI and `white-space: nowrap` on the web.
    pub fn whitespace_nowrap(self) -> Self {
        self.white_space(WhiteSpace::Nowrap)
    }

    /// Set the replacement used when text exceeds its assigned width.
    pub fn text_overflow(mut self, overflow: TextOverflow) -> Self {
        self.typography.text_overflow = Some(overflow);
        self
    }

    /// Preserve the start of overflowing text and append an ellipsis.
    pub fn text_ellipsis(self) -> Self {
        self.text_overflow(TextOverflow::ellipsis())
    }

    /// Preserve the end of overflowing text and prepend an ellipsis.
    pub fn text_ellipsis_start(self) -> Self {
        self.text_overflow(TextOverflow::ellipsis_start())
    }

    /// Preserve both ends of overflowing text and place an ellipsis in the middle.
    pub fn text_ellipsis_middle(self) -> Self {
        self.text_overflow(TextOverflow::ellipsis_middle())
    }

    /// Limit descendant text leaves to a fixed number of visible lines.
    ///
    /// Combine this with [`Self::text_ellipsis`] when the final visible line should carry an
    /// ellipsis. Values below one are normalized to one.
    pub fn line_clamp(mut self, lines: usize) -> Self {
        self.typography.line_clamp = Some(lines.max(1));
        self.overflow_hidden()
    }

    /// Web-style single-line truncation: no wrapping, hidden overflow, and a trailing ellipsis.
    pub fn truncate(self) -> Self {
        self.overflow_hidden().whitespace_nowrap().text_ellipsis()
    }

    /// Use cheap one-glyph-per-character shaping for app-controlled text and fonts.
    ///
    /// Keep the default advanced mode for complex scripts, ligatures, or general font fallback.
    pub fn text_shaping_basic(mut self) -> Self {
        self.typography.shaping = Some(TextShaping::Basic);
        self
    }

    pub fn text_shaping(mut self, shaping: TextShaping) -> Self {
        self.typography.shaping = Some(shaping);
        self
    }

    pub fn wrap(mut self) -> Self {
        self.typography.wrap = Some(TextWrap::Word);
        self
    }

    pub fn overflow_hidden(mut self) -> Self {
        self.layout.overflow = TaffyPoint {
            x: Overflow::Hidden,
            y: Overflow::Hidden,
        };
        self
    }

    pub fn overflow_y_scroll(mut self) -> Self {
        self.layout.overflow = TaffyPoint {
            x: Overflow::Hidden,
            y: Overflow::Scroll,
        };
        self
    }

    /// Follow the end of an ordinary vertical overflow container when `revision` changes.
    ///
    /// The first declaration starts at the end. Later revisions keep following only while the
    /// user was already at the previous end; scrolling away pauses following, and returning to
    /// the end resumes it on the next revision. This performs no scheduling or per-frame work.
    pub fn scroll_to_end(mut self, revision: u64) -> Self {
        self.scroll_to_end_revision = Some(revision);
        self
    }

    /// Bind this clipped viewport to a fixed-height [`VirtualList`].
    ///
    /// The mounted rows remain application-controlled, while QuickGUI owns the native-style
    /// retained scrollbar, wheel routing, pointer capture, hover expansion, and one-shot
    /// autohide. Offset changes rebuild the virtualized view only when the offset actually moves;
    /// hover and visibility changes stay paint-only.
    pub fn virtual_scroll(mut self, list: &VirtualList) -> Self {
        self.layout.overflow.y = Overflow::Hidden;
        self.virtual_scroll = Some(VirtualScrollStyle {
            handle: list.scroll_handle(),
            max_offset_y: list.max_scroll_offset(),
            measurement_revision: 0,
            mount: list.scroll_mount(),
        });
        self
    }

    /// Bind this clipped viewport to a differently sized [`ListState`].
    ///
    /// Use [`ListState::visible_rows`] and [`ListState::render_rows`] to mount a bounded normal-flow
    /// slice. QuickGUI measures those rows after Taffy layout, preserves the logical top item while
    /// estimates converge, and schedules only the correcting rebuilds that actually changed a
    /// measurement. Wheel input, scrollbar capture, hover expansion, and autohide use the same
    /// retained path as ordinary scrolling and fixed-height virtualization.
    pub fn variable_virtual_scroll(mut self, list: &ListState) -> Self {
        self.layout.overflow.y = Overflow::Hidden;
        let (handle, max_offset_y, measurement_revision, mount) = list.scroll_binding();
        self.virtual_scroll = Some(VirtualScrollStyle {
            handle,
            max_offset_y,
            measurement_revision,
            mount,
        });
        self
    }

    pub fn absolute(mut self) -> Self {
        self.layout.position = Position::Absolute;
        self
    }

    /// Create a stacking context within the current render plane.
    ///
    /// Values are relative to the nearest ancestor stacking context. Elements sharing a value stay
    /// batched and retain source order.
    pub fn z_index(mut self, value: i16) -> Self {
        self.z_index = Some(value);
        self
    }

    /// Paint this subtree in the viewport overlay plane above ordinary application content.
    ///
    /// The element becomes absolutely positioned, escapes ancestor clipping, and blocks pointer
    /// events from falling through its own bounds.
    pub fn overlay(mut self) -> Self {
        self.layout.position = Position::Absolute;
        self.plane = Some(ScenePlane::Overlay);
        self.portal = true;
        self.blocks_pointer = true;
        self
    }

    /// Position this floating element relative to a stable element ID.
    pub fn anchor_to(mut self, target: impl Into<ElementId>, placement: AnchorPlacement) -> Self {
        self = self.overlay();
        self.anchor = Some(AnchorStyle {
            target: AnchorTarget::Element(target.into()),
            placement,
            gap: DEFAULT_ANCHOR_GAP,
            viewport_margin: DEFAULT_VIEWPORT_MARGIN,
        });
        self
    }

    /// Position a viewport overlay relative to a logical point.
    ///
    /// This is the cursor-point counterpart of [`Self::anchor_to`] and is intended for context
    /// menus. Placement uses the same flip, alternate-alignment, and viewport-clamping rules.
    pub fn anchor_at(mut self, point: crate::Point, placement: AnchorPlacement) -> Self {
        self = self.overlay();
        let point = crate::Point::new(
            if point.x.is_finite() { point.x } else { 0.0 },
            if point.y.is_finite() { point.y } else { 0.0 },
        );
        self.anchor = Some(AnchorStyle {
            target: AnchorTarget::Point(point),
            placement,
            gap: 0.0,
            viewport_margin: DEFAULT_VIEWPORT_MARGIN,
        });
        self
    }

    /// Set the distance between an anchored surface and its trigger.
    pub fn anchor_gap(mut self, gap: f32) -> Self {
        if let Some(anchor) = &mut self.anchor {
            anchor.gap = gap.max(0.0);
        }
        self
    }

    /// Set the minimum distance between an anchored surface and the content viewport edge.
    pub fn viewport_margin(mut self, margin: f32) -> Self {
        if let Some(anchor) = &mut self.anchor {
            anchor.viewport_margin = margin.max(0.0);
        }
        self
    }

    /// Show a delayed, pointer-passive GPU tooltip while this element is hovered.
    ///
    /// The detached tooltip tree is laid out only after its exact delay expires. Entering a
    /// pending tooltip schedules no frame loop, and moving between ordinary points inside the
    /// trigger does not rebuild the application view.
    pub fn tooltip(mut self, tooltip: impl Into<Tooltip>) -> Self {
        let tooltip = tooltip.into();
        if self.accessibility.description.is_none() {
            self.accessibility.description = tooltip.accessibility_description.clone();
        }
        self.tooltip = Some(tooltip);
        self
    }

    /// Prevent pointer events inside this element from reaching lower visual layers.
    pub fn block_pointer(mut self) -> Self {
        self.blocks_pointer = true;
        self
    }

    /// Set web-style native window dragging behavior for this element's layout box.
    pub fn app_region(mut self, region: AppRegion) -> Self {
        self.app_region = Some(region);
        self
    }

    /// Make this element a native window drag region.
    pub fn app_region_drag(self) -> Self {
        self.app_region(AppRegion::Drag)
    }

    /// Restore normal pointer input inside an ancestor window drag region.
    pub fn app_region_no_drag(self) -> Self {
        self.app_region(AppRegion::NoDrag)
    }

    pub fn relative(mut self) -> Self {
        self.layout.position = Position::Relative;
        self
    }

    pub fn top(mut self, value: f32) -> Self {
        self.layout.inset.top = LengthPercentageAuto::length(value);
        self
    }

    pub fn right(mut self, value: f32) -> Self {
        self.layout.inset.right = LengthPercentageAuto::length(value);
        self
    }

    pub fn bottom(mut self, value: f32) -> Self {
        self.layout.inset.bottom = LengthPercentageAuto::length(value);
        self
    }

    pub fn left(mut self, value: f32) -> Self {
        self.layout.inset.left = LengthPercentageAuto::length(value);
        self
    }

    pub fn inset_0(mut self) -> Self {
        let zero = LengthPercentageAuto::length(0.0);
        self.layout.inset = TaffyRect {
            left: zero,
            right: zero,
            top: zero,
            bottom: zero,
        };
        self
    }
}