1use gpui::{App, Bounds, IntoElement, ParentElement, Pixels, Styled as _, Window, canvas};
2
3use crate::TextSelectionScopeId;
4
5pub trait ElementExt: ParentElement + Sized {
7 fn text_selection_scope(self, scope: TextSelectionScopeId) -> impl IntoElement
9 where
10 Self: IntoElement,
11 {
12 crate::text_selection::text_selection_scope(scope, self)
13 }
14
15 fn on_prepaint<F>(self, callback: F) -> Self
17 where
18 F: FnOnce(Bounds<Pixels>, &mut Window, &mut App) + 'static,
19 {
20 self.child(
21 canvas(
22 move |bounds, window, cx| callback(bounds, window, cx),
23 |_, _, _, _| {},
24 )
25 .absolute()
26 .size_full(),
27 )
28 }
29}
30
31impl<T: ParentElement> ElementExt for T {}