update
This commit is contained in:
parent
bf72429ac5
commit
0444726a2d
3 changed files with 27 additions and 30 deletions
|
@ -67,22 +67,16 @@ impl DivWidget {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo : Fix weird types
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn push_for_each<
|
pub fn push_for_each<T, X, F>(mut self, items: &[X], mut action: F) -> Self
|
||||||
|
where
|
||||||
T: UIWidget + 'static,
|
T: UIWidget + 'static,
|
||||||
X,
|
F: FnMut(&X) -> T,
|
||||||
U: Fn(&X) -> T,
|
{
|
||||||
I: Iterator<Item = X>,
|
for item in items {
|
||||||
O: Into<I>,
|
self.0.push(Box::new(action(item)));
|
||||||
>(
|
|
||||||
mut self,
|
|
||||||
iterator: O,
|
|
||||||
then: U,
|
|
||||||
) -> Self {
|
|
||||||
for val in iterator.into() {
|
|
||||||
self.0.push(Box::new(then(&val)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,27 +7,27 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Height<T: UIWidget + 'static>(
|
pub fn Height<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||||
size: Either<ScreenValue, Fraction>,
|
size: S,
|
||||||
inner: T,
|
inner: T,
|
||||||
) -> HeightWidget {
|
) -> HeightWidget {
|
||||||
HeightWidget(Box::new(inner), size, 0)
|
HeightWidget(Box::new(inner), size.into(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn MinHeight<T: UIWidget + 'static>(
|
pub fn MinHeight<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||||
size: Either<ScreenValue, Fraction>,
|
size: S,
|
||||||
inner: T,
|
inner: T,
|
||||||
) -> HeightWidget {
|
) -> HeightWidget {
|
||||||
HeightWidget(Box::new(inner), size, 1)
|
HeightWidget(Box::new(inner), size.into(), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn MaxHeight<T: UIWidget + 'static>(
|
pub fn MaxHeight<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||||
size: Either<ScreenValue, Fraction>,
|
size: S,
|
||||||
inner: T,
|
inner: T,
|
||||||
) -> HeightWidget {
|
) -> HeightWidget {
|
||||||
HeightWidget(Box::new(inner), size, 2)
|
HeightWidget(Box::new(inner), size.into(), 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HeightWidget(Box<dyn UIWidget>, Either<ScreenValue, Fraction>, u8);
|
pub struct HeightWidget(Box<dyn UIWidget>, Either<ScreenValue, Fraction>, u8);
|
||||||
|
|
|
@ -7,24 +7,27 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Width<T: UIWidget + 'static>(size: Either<ScreenValue, Fraction>, inner: T) -> WidthWidget {
|
pub fn Width<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||||
WidthWidget(Box::new(inner), size, 0)
|
size: S,
|
||||||
|
inner: T,
|
||||||
|
) -> WidthWidget {
|
||||||
|
WidthWidget(Box::new(inner), size.into(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn MinWidth<T: UIWidget + 'static>(
|
pub fn MinWidth<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||||
size: Either<ScreenValue, Fraction>,
|
size: S,
|
||||||
inner: T,
|
inner: T,
|
||||||
) -> WidthWidget {
|
) -> WidthWidget {
|
||||||
WidthWidget(Box::new(inner), size, 1)
|
WidthWidget(Box::new(inner), size.into(), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn MaxWidth<T: UIWidget + 'static>(
|
pub fn MaxWidth<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||||
size: Either<ScreenValue, Fraction>,
|
size: S,
|
||||||
inner: T,
|
inner: T,
|
||||||
) -> WidthWidget {
|
) -> WidthWidget {
|
||||||
WidthWidget(Box::new(inner), size, 2)
|
WidthWidget(Box::new(inner), size.into(), 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WidthWidget(Box<dyn UIWidget>, Either<ScreenValue, Fraction>, u8);
|
pub struct WidthWidget(Box<dyn UIWidget>, Either<ScreenValue, Fraction>, u8);
|
||||||
|
|
Loading…
Add table
Reference in a new issue