use gpui::{App, Bounds, IntoElement, ParentElement, Pixels, Styled as _, Window, canvas};
use crate::TextSelectionScopeId;
pub trait ElementExt: ParentElement + Sized {
fn text_selection_scope(self, scope: TextSelectionScopeId) -> impl IntoElement
where
Self: IntoElement,
{
crate::text_selection::text_selection_scope(scope, self)
}
fn on_prepaint<F>(self, callback: F) -> Self
where
F: FnOnce(Bounds<Pixels>, &mut Window, &mut App) + 'static,
{
self.child(
canvas(
move |bounds, window, cx| callback(bounds, window, cx),
|_, _, _, _| {},
)
.absolute()
.size_full(),
)
}
}
impl<T: ParentElement> ElementExt for T {}