idek stuff like stack
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
use super::*;
|
||||
use crate::{UiRegion, Vec2, WidgetArrLike, WidgetFn, WidgetLike};
|
||||
|
||||
pub trait CoreWidget<Ctx: 'static, Tag> {
|
||||
pub trait CoreWidget<W: 'static, Ctx: 'static, Tag> {
|
||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Regioned, Ctx>;
|
||||
fn center(self, size: impl Into<Vec2>) -> impl WidgetFn<Regioned, Ctx>;
|
||||
fn region(self, region: UiRegion) -> impl WidgetFn<Regioned, Ctx>;
|
||||
}
|
||||
|
||||
impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<Ctx, Tag> for W {
|
||||
impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<W::Widget, Ctx, Tag> for W {
|
||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Regioned, Ctx> {
|
||||
|ui| Regioned {
|
||||
region: padding.into().region(),
|
||||
@@ -16,7 +17,14 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<Ctx, Tag> for W {
|
||||
|
||||
fn center(self, size: impl Into<Vec2>) -> impl WidgetFn<Regioned, Ctx> {
|
||||
|ui| Regioned {
|
||||
region: UiRegion::center(size.into()),
|
||||
region: UiRegion::center().size(size.into()),
|
||||
inner: self.add(ui).erase_type(),
|
||||
}
|
||||
}
|
||||
|
||||
fn region(self, region: UiRegion) -> impl WidgetFn<Regioned, Ctx> {
|
||||
move |ui| Regioned {
|
||||
region,
|
||||
inner: self.add(ui).erase_type(),
|
||||
}
|
||||
}
|
||||
@@ -24,10 +32,11 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx: 'static, Tag> CoreWidget<Ctx, Tag> for W {
|
||||
|
||||
pub trait CoreWidgetArr<const LEN: usize, Ctx: 'static, Tag> {
|
||||
fn span(self, dir: Dir, lengths: [impl Into<SpanLen>; LEN]) -> impl WidgetFn<Span, Ctx>;
|
||||
fn stack(self) -> impl WidgetFn<Stack, Ctx>;
|
||||
}
|
||||
|
||||
impl<const LEN: usize, Wa: WidgetArrLike<LEN, Ctx, Tag>, Ctx: 'static, Tag> CoreWidgetArr<LEN, Ctx, Tag>
|
||||
for Wa
|
||||
impl<const LEN: usize, Wa: WidgetArrLike<LEN, Ctx, Tag>, Ctx: 'static, Tag>
|
||||
CoreWidgetArr<LEN, Ctx, Tag> for Wa
|
||||
{
|
||||
fn span(self, dir: Dir, lengths: [impl Into<SpanLen>; LEN]) -> impl WidgetFn<Span, Ctx> {
|
||||
let lengths = lengths.map(Into::into);
|
||||
@@ -36,4 +45,9 @@ impl<const LEN: usize, Wa: WidgetArrLike<LEN, Ctx, Tag>, Ctx: 'static, Tag> Core
|
||||
children: self.ui(ui).arr.into_iter().zip(lengths).collect(),
|
||||
}
|
||||
}
|
||||
fn stack(self) -> impl WidgetFn<Stack, Ctx> {
|
||||
move |ui| Stack {
|
||||
children: self.ui(ui).arr.to_vec(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user