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
|
||||
}
|
||||
|
||||
// todo : Fix weird types
|
||||
#[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,
|
||||
X,
|
||||
U: Fn(&X) -> T,
|
||||
I: Iterator<Item = X>,
|
||||
O: Into<I>,
|
||||
>(
|
||||
mut self,
|
||||
iterator: O,
|
||||
then: U,
|
||||
) -> Self {
|
||||
for val in iterator.into() {
|
||||
self.0.push(Box::new(then(&val)));
|
||||
F: FnMut(&X) -> T,
|
||||
{
|
||||
for item in items {
|
||||
self.0.push(Box::new(action(item)));
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
@ -7,27 +7,27 @@ use super::{
|
|||
};
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Height<T: UIWidget + 'static>(
|
||||
size: Either<ScreenValue, Fraction>,
|
||||
pub fn Height<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||
size: S,
|
||||
inner: T,
|
||||
) -> HeightWidget {
|
||||
HeightWidget(Box::new(inner), size, 0)
|
||||
HeightWidget(Box::new(inner), size.into(), 0)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn MinHeight<T: UIWidget + 'static>(
|
||||
size: Either<ScreenValue, Fraction>,
|
||||
pub fn MinHeight<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||
size: S,
|
||||
inner: T,
|
||||
) -> HeightWidget {
|
||||
HeightWidget(Box::new(inner), size, 1)
|
||||
HeightWidget(Box::new(inner), size.into(), 1)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn MaxHeight<T: UIWidget + 'static>(
|
||||
size: Either<ScreenValue, Fraction>,
|
||||
pub fn MaxHeight<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||
size: S,
|
||||
inner: T,
|
||||
) -> HeightWidget {
|
||||
HeightWidget(Box::new(inner), size, 2)
|
||||
HeightWidget(Box::new(inner), size.into(), 2)
|
||||
}
|
||||
|
||||
pub struct HeightWidget(Box<dyn UIWidget>, Either<ScreenValue, Fraction>, u8);
|
||||
|
|
|
@ -7,24 +7,27 @@ use super::{
|
|||
};
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Width<T: UIWidget + 'static>(size: Either<ScreenValue, Fraction>, inner: T) -> WidthWidget {
|
||||
WidthWidget(Box::new(inner), size, 0)
|
||||
pub fn Width<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||
size: S,
|
||||
inner: T,
|
||||
) -> WidthWidget {
|
||||
WidthWidget(Box::new(inner), size.into(), 0)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn MinWidth<T: UIWidget + 'static>(
|
||||
size: Either<ScreenValue, Fraction>,
|
||||
pub fn MinWidth<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||
size: S,
|
||||
inner: T,
|
||||
) -> WidthWidget {
|
||||
WidthWidget(Box::new(inner), size, 1)
|
||||
WidthWidget(Box::new(inner), size.into(), 1)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn MaxWidth<T: UIWidget + 'static>(
|
||||
size: Either<ScreenValue, Fraction>,
|
||||
pub fn MaxWidth<T: UIWidget + 'static, S: Into<Either<ScreenValue, Fraction>>>(
|
||||
size: S,
|
||||
inner: T,
|
||||
) -> WidthWidget {
|
||||
WidthWidget(Box::new(inner), size, 2)
|
||||
WidthWidget(Box::new(inner), size.into(), 2)
|
||||
}
|
||||
|
||||
pub struct WidthWidget(Box<dyn UIWidget>, Either<ScreenValue, Fraction>, u8);
|
||||
|
|
Loading…
Add table
Reference in a new issue