From 577d62b1da9cb598a16055d0688d26e27584886d Mon Sep 17 00:00:00 2001 From: shadow cat Date: Sun, 10 Aug 2025 14:35:01 -0400 Subject: [PATCH] small stuff --- src/base/mod.rs | 2 +- src/layout/ui.rs | 2 +- src/layout/widget.rs | 38 +++++++++++++++++++------------------- src/lib.rs | 1 + 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/base/mod.rs b/src/base/mod.rs index 6abb129..0577fac 100644 --- a/src/base/mod.rs +++ b/src/base/mod.rs @@ -125,7 +125,7 @@ impl WidgetUtil for W { fn pad(self, padding: impl Into) -> impl WidgetLike { WidgetFn(|ui| Regioned { region: padding.into().region(), - inner: self.id(ui).erase_type(), + inner: self.add(ui).erase_type(), }) } } diff --git a/src/layout/ui.rs b/src/layout/ui.rs index 03a23b2..0cb28cb 100644 --- a/src/layout/ui.rs +++ b/src/layout/ui.rs @@ -43,7 +43,7 @@ impl UIBuilder { } pub fn finish(mut self, base: W) -> UI { - let base = base.id(&mut self).erase_type(); + let base = base.add(&mut self).erase_type(); let mut ui = Rc::into_inner(self.ui).unwrap().into_inner(); ui.base = Some(base); ui diff --git a/src/layout/widget.rs b/src/layout/widget.rs index 39f248d..9700dac 100644 --- a/src/layout/widget.rs +++ b/src/layout/widget.rs @@ -56,7 +56,7 @@ impl WidgetId { pub trait WidgetLike { type Widget; - fn id(self, ui: &mut UIBuilder) -> WidgetId; + fn add(self, ui: &mut UIBuilder) -> WidgetId; } /// wouldn't be needed if negative trait bounds & disjoint impls existed @@ -64,7 +64,7 @@ pub struct WidgetFn W, W>(pub F); impl W> WidgetLike for WidgetFn { type Widget = W; - fn id(self, ui: &mut UIBuilder) -> WidgetId { + fn add(self, ui: &mut UIBuilder) -> WidgetId { let w = (self.0)(ui); ui.add(w).to_id() } @@ -72,21 +72,21 @@ impl W> WidgetLike for WidgetFn { impl WidgetLike for W { type Widget = W; - fn id(self, ui: &mut UIBuilder) -> WidgetId { + fn add(self, ui: &mut UIBuilder) -> WidgetId { ui.add(self).to_id() } } impl WidgetLike for WidgetId { type Widget = W; - fn id(self, _: &mut UIBuilder) -> WidgetId { + fn add(self, _: &mut UIBuilder) -> WidgetId { self } } impl WidgetLike for WidgetArr<1, (W,)> { type Widget = W; - fn id(self, _: &mut UIBuilder) -> WidgetId { + fn add(self, _: &mut UIBuilder) -> WidgetId { let [id] = self.arr; id.cast_type() } @@ -134,7 +134,7 @@ impl WidgetArrLike for WidgetArr { } // 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); diff --git a/src/lib.rs b/src/lib.rs index 89d2b0e..c19b5bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![feature(const_trait_impl)] #![feature(const_from)] #![feature(trait_alias)] +#![feature(generic_const_exprs)] mod layout; mod render;