1//! Elements are the workhorses of GPUI. They are responsible for laying out and painting all of
2//! the contents of a window. Elements form a tree and are laid out according to the web layout
3//! standards as implemented by [taffy](https://github.com/DioxusLabs/taffy). Most of the time,
4//! you won't need to interact with this module or these APIs directly. Elements provide their
5//! own APIs and GPUI, or other element implementation, uses the APIs in this module to convert
6//! that element tree into the pixels you see on the screen.
7//!
8//! # Element Basics
9//!
10//! Elements are constructed by calling [`Render::render()`] on the root view of the window,
11//! which recursively constructs the element tree from the current state of the application,.
12//! These elements are then laid out by Taffy, and painted to the screen according to their own
13//! implementation of [`Element::paint()`]. Before the start of the next frame, the entire element
14//! tree and any callbacks they have registered with GPUI are dropped and the process repeats.
15//!
16//! But some state is too simple and voluminous to store in every view that needs it, e.g.
17//! whether a hover has been started or not. For this, GPUI provides the [`Element::State`], associated type.
18//!
19//! # Implementing your own elements
20//!
21//! Elements are intended to be the low level, imperative API to GPUI. They are responsible for upholding,
22//! or breaking, GPUI's features as they deem necessary. As an example, most GPUI elements are expected
23//! to stay in the bounds that their parent element gives them. But with [`WindowContext::break_content_mask`],
24//! you can ignore this restriction and paint anywhere inside of the window's bounds. This is useful for overlays
25//! and popups and anything else that shows up 'on top' of other elements.
26//! With great power, comes great responsibility.
27//!
28//! However, most of the time, you won't need to implement your own elements. GPUI provides a number of
29//! elements that should cover most common use cases out of the box and it's recommended that you use those
30//! to construct `components`, using the [`RenderOnce`] trait and the `#[derive(IntoElement)]` macro. Only implement
31//! elements when you need to take manual control of the layout and painting process, such as when using
32//! your own custom layout algorithm or rendering a code editor.
33
34use crate::{
35 App, ArenaBox, AvailableSpace, Bounds, Context, DispatchNodeId, ELEMENT_ARENA, ElementId,
36 FocusHandle, InspectorElementId, LayoutId, Pixels, Point, Size, Style, Window,
37 util::FluentBuilder,
38};
39use derive_more::{Deref, DerefMut};
40pub(crate) use smallvec::SmallVec;
41use std::{
42 any::Any,
43 fmt::{self, Debug, Display},
44 mem, panic,
45};
46
47/// Implemented by types that participate in laying out and painting the contents of a window.
48/// Elements form a tree and are laid out according to web-based layout rules, as implemented by Taffy.
49/// You can create custom elements by implementing this trait, see the module-level documentation
50/// for more details.
51pub trait Element: 'static + IntoElement {
52 /// The type of state returned from [`Element::request_layout`]. A mutable reference to this state is subsequently
53 /// provided to [`Element::prepaint`] and [`Element::paint`].
54 type RequestLayoutState: 'static;
55
56 /// The type of state returned from [`Element::prepaint`]. A mutable reference to this state is subsequently
57 /// provided to [`Element::paint`].
58 type PrepaintState: 'static;
59
60 /// If this element has a unique identifier, return it here. This is used to track elements across frames, and
61 /// will cause a GlobalElementId to be passed to the request_layout, prepaint, and paint methods.
62 ///
63 /// The global id can in turn be used to access state that's connected to an element with the same id across
64 /// frames. This id must be unique among children of the first containing element with an id.
65 fn id(&self) -> Option<ElementId>;
66
67 /// Source location where this element was constructed, used to disambiguate elements in the
68 /// inspector and navigate to their source code.
69 fn source_location(&self) -> Option<&'static panic::Location<'static>>;
70
71 /// Before an element can be painted, we need to know where it's going to be and how big it is.
72 /// Use this method to request a layout from Taffy and initialize the element's state.
73 fn request_layout(
74 &mut self,
75 id: Option<&GlobalElementId>,
76 inspector_id: Option<&InspectorElementId>,
77 window: &mut Window,
78 cx: &mut App,
79 ) -> (LayoutId, Self::RequestLayoutState);
80
81 /// After laying out an element, we need to commit its bounds to the current frame for hitbox
82 /// purposes. The state argument is the same state that was returned from [`Element::request_layout()`].
83 fn prepaint(
84 &mut self,
85 id: Option<&GlobalElementId>,
86 inspector_id: Option<&InspectorElementId>,
87 bounds: Bounds<Pixels>,
88 request_layout: &mut Self::RequestLayoutState,
89 window: &mut Window,
90 cx: &mut App,
91 ) -> Self::PrepaintState;
92
93 /// Once layout has been completed, this method will be called to paint the element to the screen.
94 /// The state argument is the same state that was returned from [`Element::request_layout()`].
95 fn paint(
96 &mut self,
97 id: Option<&GlobalElementId>,
98 inspector_id: Option<&InspectorElementId>,
99 bounds: Bounds<Pixels>,
100 request_layout: &mut Self::RequestLayoutState,
101 prepaint: &mut Self::PrepaintState,
102 window: &mut Window,
103 cx: &mut App,
104 );
105
106 /// Convert this element into a dynamically-typed [`AnyElement`].
107 fn into_any(self) -> AnyElement {
108 AnyElement::new(self)
109 }
110}
111
112/// Implemented by any type that can be converted into an element.
113pub trait IntoElement: Sized {
114 /// The specific type of element into which the implementing type is converted.
115 /// Useful for converting other types into elements automatically, like Strings
116 type Element: Element;
117
118 /// Convert self into a type that implements [`Element`].
119 fn into_element(self) -> Self::Element;
120
121 /// Convert self into a dynamically-typed [`AnyElement`].
122 fn into_any_element(self) -> AnyElement {
123 self.into_element().into_any()
124 }
125}
126
127impl<T: IntoElement> FluentBuilder for T {}
128
129/// An object that can be drawn to the screen. This is the trait that distinguishes "views" from
130/// other entities. Views are `Entity`'s which `impl Render` and drawn to the screen.
131pub trait Render: 'static + Sized {
132 /// Render this view into an element tree.
133 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement;
134}
135
136impl Render for Empty {
137 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
138 Empty
139 }
140}
141
142/// You can derive [`IntoElement`] on any type that implements this trait.
143/// It is used to construct reusable `components` out of plain data. Think of
144/// components as a recipe for a certain pattern of elements. RenderOnce allows
145/// you to invoke this pattern, without breaking the fluent builder pattern of
146/// the element APIs.
147pub trait RenderOnce: 'static {
148 /// Render this component into an element tree. Note that this method
149 /// takes ownership of self, as compared to [`Render::render()`] method
150 /// which takes a mutable reference.
151 fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement;
152}
153
154/// This is a helper trait to provide a uniform interface for constructing elements that
155/// can accept any number of any kind of child elements
156pub trait ParentElement {
157 /// Extend this element's children with the given child elements.
158 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>);
159
160 /// Add a single child element to this element.
161 fn child(mut self, child: impl IntoElement) -> Self
162 where
163 Self: Sized,
164 {
165 self.extend(std::iter::once(child.into_element().into_any()));
166 self
167 }
168
169 /// Add multiple child elements to this element.
170 fn children(mut self, children: impl IntoIterator<Item = impl IntoElement>) -> Self
171 where
172 Self: Sized,
173 {
174 self.extend(children.into_iter().map(|child| child.into_any_element()));
175 self
176 }
177}
178
179/// An element for rendering components. An implementation detail of the [`IntoElement`] derive macro
180/// for [`RenderOnce`]
181#[doc(hidden)]
182pub struct Component<C: RenderOnce> {
183 component: Option<C>,
184 #[cfg(debug_assertions)]
185 source: &'static core::panic::Location<'static>,
186}
187
188impl<C: RenderOnce> Component<C> {
189 /// Create a new component from the given RenderOnce type.
190 #[track_caller]
191 pub fn new(component: C) -> Self {
192 Component {
193 component: Some(component),
194 #[cfg(debug_assertions)]
195 source: core::panic::Location::caller(),
196 }
197 }
198}
199
200impl<C: RenderOnce> Element for Component<C> {
201 type RequestLayoutState = AnyElement;
202 type PrepaintState = ();
203
204 fn id(&self) -> Option<ElementId> {
205 None
206 }
207
208 fn source_location(&self) -> Option<&'static core::panic::Location<'static>> {
209 #[cfg(debug_assertions)]
210 return Some(self.source);
211
212 #[cfg(not(debug_assertions))]
213 return None;
214 }
215
216 fn request_layout(
217 &mut self,
218 _id: Option<&GlobalElementId>,
219 _inspector_id: Option<&InspectorElementId>,
220 window: &mut Window,
221 cx: &mut App,
222 ) -> (LayoutId, Self::RequestLayoutState) {
223 let mut element = self
224 .component
225 .take()
226 .unwrap()
227 .render(window, cx)
228 .into_any_element();
229 let layout_id = element.request_layout(window, cx);
230 (layout_id, element)
231 }
232
233 fn prepaint(
234 &mut self,
235 _id: Option<&GlobalElementId>,
236 _inspector_id: Option<&InspectorElementId>,
237 _: Bounds<Pixels>,
238 element: &mut AnyElement,
239 window: &mut Window,
240 cx: &mut App,
241 ) {
242 element.prepaint(window, cx);
243 }
244
245 fn paint(
246 &mut self,
247 _id: Option<&GlobalElementId>,
248 _inspector_id: Option<&InspectorElementId>,
249 _: Bounds<Pixels>,
250 element: &mut Self::RequestLayoutState,
251 _: &mut Self::PrepaintState,
252 window: &mut Window,
253 cx: &mut App,
254 ) {
255 element.paint(window, cx);
256 }
257}
258
259impl<C: RenderOnce> IntoElement for Component<C> {
260 type Element = Self;
261
262 fn into_element(self) -> Self::Element {
263 self
264 }
265}
266
267/// A globally unique identifier for an element, used to track state across frames.
268#[derive(Deref, DerefMut, Default, Debug, Eq, PartialEq, Hash)]
269pub struct GlobalElementId(pub(crate) SmallVec<[ElementId; 32]>);
270
271impl Display for GlobalElementId {
272 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
273 for (i, element_id) in self.0.iter().enumerate() {
274 if i > 0 {
275 write!(f, ".")?;
276 }
277 write!(f, "{}", element_id)?;
278 }
279 Ok(())
280 }
281}
282
283trait ElementObject {
284 fn inner_element(&mut self) -> &mut dyn Any;
285
286 fn request_layout(&mut self, window: &mut Window, cx: &mut App) -> LayoutId;
287
288 fn prepaint(&mut self, window: &mut Window, cx: &mut App);
289
290 fn paint(&mut self, window: &mut Window, cx: &mut App);
291
292 fn layout_as_root(
293 &mut self,
294 available_space: Size<AvailableSpace>,
295 window: &mut Window,
296 cx: &mut App,
297 ) -> Size<Pixels>;
298}
299
300/// A wrapper around an implementer of [`Element`] that allows it to be drawn in a window.
301pub struct Drawable<E: Element> {
302 /// The drawn element.
303 pub element: E,
304 phase: ElementDrawPhase<E::RequestLayoutState, E::PrepaintState>,
305}
306
307#[derive(Default)]
308enum ElementDrawPhase<RequestLayoutState, PrepaintState> {
309 #[default]
310 Start,
311 RequestLayout {
312 layout_id: LayoutId,
313 global_id: Option<GlobalElementId>,
314 inspector_id: Option<InspectorElementId>,
315 request_layout: RequestLayoutState,
316 },
317 LayoutComputed {
318 layout_id: LayoutId,
319 global_id: Option<GlobalElementId>,
320 inspector_id: Option<InspectorElementId>,
321 available_space: Size<AvailableSpace>,
322 request_layout: RequestLayoutState,
323 },
324 Prepaint {
325 node_id: DispatchNodeId,
326 global_id: Option<GlobalElementId>,
327 inspector_id: Option<InspectorElementId>,
328 bounds: Bounds<Pixels>,
329 request_layout: RequestLayoutState,
330 prepaint: PrepaintState,
331 },
332 Painted,
333}
334
335/// A wrapper around an implementer of [`Element`] that allows it to be drawn in a window.
336impl<E: Element> Drawable<E> {
337 pub(crate) fn new(element: E) -> Self {
338 Drawable {
339 element,
340 phase: ElementDrawPhase::Start,
341 }
342 }
343
344 fn request_layout(&mut self, window: &mut Window, cx: &mut App) -> LayoutId {
345 match mem::take(&mut self.phase) {
346 ElementDrawPhase::Start => {
347 let global_id = self.element.id().map(|element_id| {
348 window.element_id_stack.push(element_id);
349 GlobalElementId(window.element_id_stack.clone())
350 });
351
352 let inspector_id;
353 #[cfg(any(feature = "inspector", debug_assertions))]
354 {
355 inspector_id = self.element.source_location().map(|source| {
356 let path = crate::InspectorElementPath {
357 global_id: GlobalElementId(window.element_id_stack.clone()),
358 source_location: source,
359 };
360 window.build_inspector_element_id(path)
361 });
362 }
363 #[cfg(not(any(feature = "inspector", debug_assertions)))]
364 {
365 inspector_id = None;
366 }
367
368 let (layout_id, request_layout) = self.element.request_layout(
369 global_id.as_ref(),
370 inspector_id.as_ref(),
371 window,
372 cx,
373 );
374
375 if global_id.is_some() {
376 window.element_id_stack.pop();
377 }
378
379 self.phase = ElementDrawPhase::RequestLayout {
380 layout_id,
381 global_id,
382 inspector_id,
383 request_layout,
384 };
385 layout_id
386 }
387 _ => panic!("must call request_layout only once"),
388 }
389 }
390
391 pub(crate) fn prepaint(&mut self, window: &mut Window, cx: &mut App) {
392 match mem::take(&mut self.phase) {
393 ElementDrawPhase::RequestLayout {
394 layout_id,
395 global_id,
396 inspector_id,
397 mut request_layout,
398 }
399 | ElementDrawPhase::LayoutComputed {
400 layout_id,
401 global_id,
402 inspector_id,
403 mut request_layout,
404 ..
405 } => {
406 if let Some(element_id) = self.element.id() {
407 window.element_id_stack.push(element_id);
408 debug_assert_eq!(global_id.as_ref().unwrap().0, window.element_id_stack);
409 }
410
411 let bounds = window.layout_bounds(layout_id);
412 let node_id = window.next_frame.dispatch_tree.push_node();
413 let prepaint = self.element.prepaint(
414 global_id.as_ref(),
415 inspector_id.as_ref(),
416 bounds,
417 &mut request_layout,
418 window,
419 cx,
420 );
421 window.next_frame.dispatch_tree.pop_node();
422
423 if global_id.is_some() {
424 window.element_id_stack.pop();
425 }
426
427 self.phase = ElementDrawPhase::Prepaint {
428 node_id,
429 global_id,
430 inspector_id,
431 bounds,
432 request_layout,
433 prepaint,
434 };
435 }
436 _ => panic!("must call request_layout before prepaint"),
437 }
438 }
439
440 pub(crate) fn paint(
441 &mut self,
442 window: &mut Window,
443 cx: &mut App,
444 ) -> (E::RequestLayoutState, E::PrepaintState) {
445 match mem::take(&mut self.phase) {
446 ElementDrawPhase::Prepaint {
447 node_id,
448 global_id,
449 inspector_id,
450 bounds,
451 mut request_layout,
452 mut prepaint,
453 ..
454 } => {
455 if let Some(element_id) = self.element.id() {
456 window.element_id_stack.push(element_id);
457 debug_assert_eq!(global_id.as_ref().unwrap().0, window.element_id_stack);
458 }
459
460 window.next_frame.dispatch_tree.set_active_node(node_id);
461 self.element.paint(
462 global_id.as_ref(),
463 inspector_id.as_ref(),
464 bounds,
465 &mut request_layout,
466 &mut prepaint,
467 window,
468 cx,
469 );
470
471 if global_id.is_some() {
472 window.element_id_stack.pop();
473 }
474
475 self.phase = ElementDrawPhase::Painted;
476 (request_layout, prepaint)
477 }
478 _ => panic!("must call prepaint before paint"),
479 }
480 }
481
482 pub(crate) fn layout_as_root(
483 &mut self,
484 available_space: Size<AvailableSpace>,
485 window: &mut Window,
486 cx: &mut App,
487 ) -> Size<Pixels> {
488 if matches!(&self.phase, ElementDrawPhase::Start) {
489 self.request_layout(window, cx);
490 }
491
492 let layout_id = match mem::take(&mut self.phase) {
493 ElementDrawPhase::RequestLayout {
494 layout_id,
495 global_id,
496 inspector_id,
497 request_layout,
498 } => {
499 window.compute_layout(layout_id, available_space, cx);
500 self.phase = ElementDrawPhase::LayoutComputed {
501 layout_id,
502 global_id,
503 inspector_id,
504 available_space,
505 request_layout,
506 };
507 layout_id
508 }
509 ElementDrawPhase::LayoutComputed {
510 layout_id,
511 global_id,
512 inspector_id,
513 available_space: prev_available_space,
514 request_layout,
515 } => {
516 if available_space != prev_available_space {
517 window.compute_layout(layout_id, available_space, cx);
518 }
519 self.phase = ElementDrawPhase::LayoutComputed {
520 layout_id,
521 global_id,
522 inspector_id,
523 available_space,
524 request_layout,
525 };
526 layout_id
527 }
528 _ => panic!("cannot measure after painting"),
529 };
530
531 window.layout_bounds(layout_id).size
532 }
533}
534
535impl<E> ElementObject for Drawable<E>
536where
537 E: Element,
538 E::RequestLayoutState: 'static,
539{
540 fn inner_element(&mut self) -> &mut dyn Any {
541 &mut self.element
542 }
543
544 fn request_layout(&mut self, window: &mut Window, cx: &mut App) -> LayoutId {
545 Drawable::request_layout(self, window, cx)
546 }
547
548 fn prepaint(&mut self, window: &mut Window, cx: &mut App) {
549 Drawable::prepaint(self, window, cx);
550 }
551
552 fn paint(&mut self, window: &mut Window, cx: &mut App) {
553 Drawable::paint(self, window, cx);
554 }
555
556 fn layout_as_root(
557 &mut self,
558 available_space: Size<AvailableSpace>,
559 window: &mut Window,
560 cx: &mut App,
561 ) -> Size<Pixels> {
562 Drawable::layout_as_root(self, available_space, window, cx)
563 }
564}
565
566/// A dynamically typed element that can be used to store any element type.
567pub struct AnyElement(ArenaBox<dyn ElementObject>);
568
569impl AnyElement {
570 pub(crate) fn new<E>(element: E) -> Self
571 where
572 E: 'static + Element,
573 E::RequestLayoutState: Any,
574 {
575 let element = ELEMENT_ARENA
576 .with_borrow_mut(|arena| arena.alloc(|| Drawable::new(element)))
577 .map(|element| element as &mut dyn ElementObject);
578 AnyElement(element)
579 }
580
581 /// Attempt to downcast a reference to the boxed element to a specific type.
582 pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> {
583 self.0.inner_element().downcast_mut::<T>()
584 }
585
586 /// Request the layout ID of the element stored in this `AnyElement`.
587 /// Used for laying out child elements in a parent element.
588 pub fn request_layout(&mut self, window: &mut Window, cx: &mut App) -> LayoutId {
589 self.0.request_layout(window, cx)
590 }
591
592 /// Prepares the element to be painted by storing its bounds, giving it a chance to draw hitboxes and
593 /// request autoscroll before the final paint pass is confirmed.
594 pub fn prepaint(&mut self, window: &mut Window, cx: &mut App) -> Option<FocusHandle> {
595 let focus_assigned = window.next_frame.focus.is_some();
596
597 self.0.prepaint(window, cx);
598
599 if !focus_assigned {
600 if let Some(focus_id) = window.next_frame.focus {
601 return FocusHandle::for_id(focus_id, &cx.focus_handles);
602 }
603 }
604
605 None
606 }
607
608 /// Paints the element stored in this `AnyElement`.
609 pub fn paint(&mut self, window: &mut Window, cx: &mut App) {
610 self.0.paint(window, cx);
611 }
612
613 /// Performs layout for this element within the given available space and returns its size.
614 pub fn layout_as_root(
615 &mut self,
616 available_space: Size<AvailableSpace>,
617 window: &mut Window,
618 cx: &mut App,
619 ) -> Size<Pixels> {
620 self.0.layout_as_root(available_space, window, cx)
621 }
622
623 /// Prepaints this element at the given absolute origin.
624 /// If any element in the subtree beneath this element is focused, its FocusHandle is returned.
625 pub fn prepaint_at(
626 &mut self,
627 origin: Point<Pixels>,
628 window: &mut Window,
629 cx: &mut App,
630 ) -> Option<FocusHandle> {
631 window.with_absolute_element_offset(origin, |window| self.prepaint(window, cx))
632 }
633
634 /// Performs layout on this element in the available space, then prepaints it at the given absolute origin.
635 /// If any element in the subtree beneath this element is focused, its FocusHandle is returned.
636 pub fn prepaint_as_root(
637 &mut self,
638 origin: Point<Pixels>,
639 available_space: Size<AvailableSpace>,
640 window: &mut Window,
641 cx: &mut App,
642 ) -> Option<FocusHandle> {
643 self.layout_as_root(available_space, window, cx);
644 window.with_absolute_element_offset(origin, |window| self.prepaint(window, cx))
645 }
646}
647
648impl Element for AnyElement {
649 type RequestLayoutState = ();
650 type PrepaintState = ();
651
652 fn id(&self) -> Option<ElementId> {
653 None
654 }
655
656 fn source_location(&self) -> Option<&'static panic::Location<'static>> {
657 None
658 }
659
660 fn request_layout(
661 &mut self,
662 _: Option<&GlobalElementId>,
663 _inspector_id: Option<&InspectorElementId>,
664 window: &mut Window,
665 cx: &mut App,
666 ) -> (LayoutId, Self::RequestLayoutState) {
667 let layout_id = self.request_layout(window, cx);
668 (layout_id, ())
669 }
670
671 fn prepaint(
672 &mut self,
673 _: Option<&GlobalElementId>,
674 _inspector_id: Option<&InspectorElementId>,
675 _: Bounds<Pixels>,
676 _: &mut Self::RequestLayoutState,
677 window: &mut Window,
678 cx: &mut App,
679 ) {
680 self.prepaint(window, cx);
681 }
682
683 fn paint(
684 &mut self,
685 _: Option<&GlobalElementId>,
686 _inspector_id: Option<&InspectorElementId>,
687 _: Bounds<Pixels>,
688 _: &mut Self::RequestLayoutState,
689 _: &mut Self::PrepaintState,
690 window: &mut Window,
691 cx: &mut App,
692 ) {
693 self.paint(window, cx);
694 }
695}
696
697impl IntoElement for AnyElement {
698 type Element = Self;
699
700 fn into_element(self) -> Self::Element {
701 self
702 }
703
704 fn into_any_element(self) -> AnyElement {
705 self
706 }
707}
708
709/// The empty element, which renders nothing.
710pub struct Empty;
711
712impl IntoElement for Empty {
713 type Element = Self;
714
715 fn into_element(self) -> Self::Element {
716 self
717 }
718}
719
720impl Element for Empty {
721 type RequestLayoutState = ();
722 type PrepaintState = ();
723
724 fn id(&self) -> Option<ElementId> {
725 None
726 }
727
728 fn source_location(&self) -> Option<&'static panic::Location<'static>> {
729 None
730 }
731
732 fn request_layout(
733 &mut self,
734 _id: Option<&GlobalElementId>,
735 _inspector_id: Option<&InspectorElementId>,
736 window: &mut Window,
737 cx: &mut App,
738 ) -> (LayoutId, Self::RequestLayoutState) {
739 (window.request_layout(Style::default(), None, cx), ())
740 }
741
742 fn prepaint(
743 &mut self,
744 _id: Option<&GlobalElementId>,
745 _inspector_id: Option<&InspectorElementId>,
746 _bounds: Bounds<Pixels>,
747 _state: &mut Self::RequestLayoutState,
748 _window: &mut Window,
749 _cx: &mut App,
750 ) {
751 }
752
753 fn paint(
754 &mut self,
755 _id: Option<&GlobalElementId>,
756 _inspector_id: Option<&InspectorElementId>,
757 _bounds: Bounds<Pixels>,
758 _request_layout: &mut Self::RequestLayoutState,
759 _prepaint: &mut Self::PrepaintState,
760 _window: &mut Window,
761 _cx: &mut App,
762 ) {
763 }
764}