use super::*; use crate::{UiRegion, Vec2, WidgetArrLike, WidgetFn, WidgetLike}; pub trait CoreWidget { fn pad(self, padding: impl Into) -> impl WidgetFn; fn center(self, size: impl Into) -> impl WidgetFn; fn region(self, region: UiRegion) -> impl WidgetFn; } impl, Ctx: 'static, Tag> CoreWidget for W { fn pad(self, padding: impl Into) -> impl WidgetFn { |ui| Regioned { region: padding.into().region(), inner: self.add(ui).erase_type(), } } fn center(self, size: impl Into) -> impl WidgetFn { |ui| Regioned { region: UiRegion::center().size(size.into()), inner: self.add(ui).erase_type(), } } fn region(self, region: UiRegion) -> impl WidgetFn { move |ui| Regioned { region, inner: self.add(ui).erase_type(), } } } pub trait CoreWidgetArr { fn span(self, dir: Dir, lengths: [impl Into; LEN]) -> impl WidgetFn; fn stack(self) -> impl WidgetFn; } impl, Ctx: 'static, Tag> CoreWidgetArr for Wa { fn span(self, dir: Dir, lengths: [impl Into; LEN]) -> impl WidgetFn { let lengths = lengths.map(Into::into); move |ui| Span { dir, children: self.ui(ui).arr.into_iter().zip(lengths).collect(), } } fn stack(self) -> impl WidgetFn { move |ui| Stack { children: self.ui(ui).arr.to_vec(), } } }