small stuff
This commit is contained in:
@@ -125,7 +125,7 @@ impl<W: WidgetLike> WidgetUtil for W {
|
|||||||
fn pad(self, padding: impl Into<Padding>) -> impl WidgetLike<Widget = Regioned> {
|
fn pad(self, padding: impl Into<Padding>) -> impl WidgetLike<Widget = Regioned> {
|
||||||
WidgetFn(|ui| Regioned {
|
WidgetFn(|ui| Regioned {
|
||||||
region: padding.into().region(),
|
region: padding.into().region(),
|
||||||
inner: self.id(ui).erase_type(),
|
inner: self.add(ui).erase_type(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ impl UIBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish<W: WidgetLike>(mut self, base: W) -> UI {
|
pub fn finish<W: WidgetLike>(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();
|
let mut ui = Rc::into_inner(self.ui).unwrap().into_inner();
|
||||||
ui.base = Some(base);
|
ui.base = Some(base);
|
||||||
ui
|
ui
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ impl<W> WidgetId<W> {
|
|||||||
|
|
||||||
pub trait WidgetLike {
|
pub trait WidgetLike {
|
||||||
type Widget;
|
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
|
/// 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> {
|
impl<W: Widget, F: FnOnce(&mut UIBuilder) -> W> WidgetLike for WidgetFn<F, W> {
|
||||||
type Widget = 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);
|
let w = (self.0)(ui);
|
||||||
ui.add(w).to_id()
|
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 {
|
impl<W: Widget> WidgetLike for W {
|
||||||
type Widget = 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()
|
ui.add(self).to_id()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W> WidgetLike for WidgetId<W> {
|
impl<W> WidgetLike for WidgetId<W> {
|
||||||
type Widget = W;
|
type Widget = W;
|
||||||
fn id(self, _: &mut UIBuilder) -> WidgetId<W> {
|
fn add(self, _: &mut UIBuilder) -> WidgetId<W> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W> WidgetLike for WidgetArr<1, (W,)> {
|
impl<W> WidgetLike for WidgetArr<1, (W,)> {
|
||||||
type Widget = W;
|
type Widget = W;
|
||||||
fn id(self, _: &mut UIBuilder) -> WidgetId<W> {
|
fn add(self, _: &mut UIBuilder) -> WidgetId<W> {
|
||||||
let [id] = self.arr;
|
let [id] = self.arr;
|
||||||
id.cast_type()
|
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
|
// 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)*) => {
|
($n:expr;$($T:tt)*) => {
|
||||||
impl<$($T: WidgetLike,)*> WidgetArrLike<$n> for ($($T,)*) {
|
impl<$($T: WidgetLike,)*> WidgetArrLike<$n> for ($($T,)*) {
|
||||||
type Ws = ($($T::Widget,)*);
|
type Ws = ($($T::Widget,)*);
|
||||||
@@ -144,22 +144,22 @@ macro_rules! impl_node_arr {
|
|||||||
let ($($T,)*) = self;
|
let ($($T,)*) = self;
|
||||||
WidgetArr::new(
|
WidgetArr::new(
|
||||||
ui.clone(),
|
ui.clone(),
|
||||||
[$($T.id(ui).cast_type(),)*],
|
[$($T.add(ui).cast_type(),)*],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_node_arr!(1;A);
|
impl_widget_arr!(1;A);
|
||||||
impl_node_arr!(2;A B);
|
impl_widget_arr!(2;A B);
|
||||||
impl_node_arr!(3;A B C);
|
impl_widget_arr!(3;A B C);
|
||||||
impl_node_arr!(4;A B C D);
|
impl_widget_arr!(4;A B C D);
|
||||||
impl_node_arr!(5;A B C D E);
|
impl_widget_arr!(5;A B C D E);
|
||||||
impl_node_arr!(6;A B C D E F);
|
impl_widget_arr!(6;A B C D E F);
|
||||||
impl_node_arr!(7;A B C D E F G);
|
impl_widget_arr!(7;A B C D E F G);
|
||||||
impl_node_arr!(8;A B C D E F G H);
|
impl_widget_arr!(8;A B C D E F G H);
|
||||||
impl_node_arr!(9;A B C D E F G H I);
|
impl_widget_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_widget_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_widget_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!(12;A B C D E F G H I J K L);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
#![feature(const_from)]
|
#![feature(const_from)]
|
||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
|
#![feature(generic_const_exprs)]
|
||||||
|
|
||||||
mod layout;
|
mod layout;
|
||||||
mod render;
|
mod render;
|
||||||
|
|||||||
Reference in New Issue
Block a user