|
|
|
|
@@ -56,7 +56,7 @@ impl<W> WidgetId<W> {
|
|
|
|
|
|
|
|
|
|
pub trait WidgetLike {
|
|
|
|
|
type Widget;
|
|
|
|
|
fn id(self, ui: &mut UIBuilder) -> WidgetId<Self::Widget>;
|
|
|
|
|
fn add(self, ui: &mut UIBuilder) -> WidgetId<Self::Widget>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// wouldn't be needed if negative trait bounds & disjoint impls existed
|
|
|
|
|
@@ -64,7 +64,7 @@ pub struct WidgetFn<F: FnOnce(&mut UIBuilder) -> W, W>(pub F);
|
|
|
|
|
|
|
|
|
|
impl<W: Widget, F: FnOnce(&mut UIBuilder) -> W> WidgetLike for WidgetFn<F, W> {
|
|
|
|
|
type Widget = W;
|
|
|
|
|
fn id(self, ui: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
fn add(self, ui: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
let w = (self.0)(ui);
|
|
|
|
|
ui.add(w).to_id()
|
|
|
|
|
}
|
|
|
|
|
@@ -72,21 +72,21 @@ impl<W: Widget, F: FnOnce(&mut UIBuilder) -> W> WidgetLike for WidgetFn<F, W> {
|
|
|
|
|
|
|
|
|
|
impl<W: Widget> WidgetLike for W {
|
|
|
|
|
type Widget = W;
|
|
|
|
|
fn id(self, ui: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
fn add(self, ui: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
ui.add(self).to_id()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<W> WidgetLike for WidgetId<W> {
|
|
|
|
|
type Widget = W;
|
|
|
|
|
fn id(self, _: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
fn add(self, _: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<W> WidgetLike for WidgetArr<1, (W,)> {
|
|
|
|
|
type Widget = W;
|
|
|
|
|
fn id(self, _: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
fn add(self, _: &mut UIBuilder) -> WidgetId<W> {
|
|
|
|
|
let [id] = self.arr;
|
|
|
|
|
id.cast_type()
|
|
|
|
|
}
|
|
|
|
|
@@ -134,7 +134,7 @@ impl<const LEN: usize, Ws> WidgetArrLike<LEN> for WidgetArr<LEN, Ws> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// I hate this language it's so bad why do I even use it
|
|
|
|
|
macro_rules! impl_node_arr {
|
|
|
|
|
macro_rules! impl_widget_arr {
|
|
|
|
|
($n:expr;$($T:tt)*) => {
|
|
|
|
|
impl<$($T: WidgetLike,)*> WidgetArrLike<$n> for ($($T,)*) {
|
|
|
|
|
type Ws = ($($T::Widget,)*);
|
|
|
|
|
@@ -144,22 +144,22 @@ macro_rules! impl_node_arr {
|
|
|
|
|
let ($($T,)*) = self;
|
|
|
|
|
WidgetArr::new(
|
|
|
|
|
ui.clone(),
|
|
|
|
|
[$($T.id(ui).cast_type(),)*],
|
|
|
|
|
[$($T.add(ui).cast_type(),)*],
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl_node_arr!(1;A);
|
|
|
|
|
impl_node_arr!(2;A B);
|
|
|
|
|
impl_node_arr!(3;A B C);
|
|
|
|
|
impl_node_arr!(4;A B C D);
|
|
|
|
|
impl_node_arr!(5;A B C D E);
|
|
|
|
|
impl_node_arr!(6;A B C D E F);
|
|
|
|
|
impl_node_arr!(7;A B C D E F G);
|
|
|
|
|
impl_node_arr!(8;A B C D E F G H);
|
|
|
|
|
impl_node_arr!(9;A B C D E F G H I);
|
|
|
|
|
impl_node_arr!(10;A B C D E F G H I J);
|
|
|
|
|
impl_node_arr!(11;A B C D E F G H I J K);
|
|
|
|
|
impl_node_arr!(12;A B C D E F G H I J K L);
|
|
|
|
|
impl_widget_arr!(1;A);
|
|
|
|
|
impl_widget_arr!(2;A B);
|
|
|
|
|
impl_widget_arr!(3;A B C);
|
|
|
|
|
impl_widget_arr!(4;A B C D);
|
|
|
|
|
impl_widget_arr!(5;A B C D E);
|
|
|
|
|
impl_widget_arr!(6;A B C D E F);
|
|
|
|
|
impl_widget_arr!(7;A B C D E F G);
|
|
|
|
|
impl_widget_arr!(8;A B C D E F G H);
|
|
|
|
|
impl_widget_arr!(9;A B C D E F G H I);
|
|
|
|
|
impl_widget_arr!(10;A B C D E F G H I J);
|
|
|
|
|
impl_widget_arr!(11;A B C D E F G H I J K);
|
|
|
|
|
impl_widget_arr!(12;A B C D E F G H I J K L);
|
|
|
|
|
|