refactoring arranger into components

This commit is contained in:
🪞👃🪞 2024-09-12 19:24:21 +03:00
parent 0bc43ed36f
commit 5670fc179b
4 changed files with 262 additions and 288 deletions

View file

@ -316,6 +316,20 @@ impl<
}
}
//pub fn collect <'a, E: Engine, const N: usize> (
//items: &'a [&'a dyn Widget<Engine = E>;N]
//) -> impl Send + Sync + Fn(&'a mut dyn FnMut(&'a dyn Widget<Engine = E>)->Usually<()>)->Usually<()> + '_ {
//|add: &'a mut dyn FnMut(&'a dyn Widget<Engine = E>)->Usually<()>| {
//for item in items.iter() {
//add(item)?;
//}
//Ok(())
//}
//}
//`Layers<_, impl (Fn(&mut dyn FnMut(&dyn Widget<Engine = _>) -> Result<(), Box<...>>) -> ... ) + Send + Sync>`
//`Layers<Tui, impl (Fn(&mut dyn FnMut(&dyn Widget<Engine = Tui>) -> Result<(), Box<(dyn std::error::Error + 'static)>>) -> Result<(), Box<(dyn std::error::Error + 'static)>>) + Send + Sync + '_>`
#[derive(Copy, Clone)]
pub enum Direction {
Up,

View file

@ -582,10 +582,11 @@ impl<T: Widget<Engine = Tui>> Widget for Align<T> {
})
}
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
self.layout(to.area())?
.map(|area|to.render_in(area, self.inner()))
.transpose()
.map(|x|x.flatten())
if let Some(area) = self.layout(to.area())? {
to.render_in(area, self.inner())
} else {
Ok(None)
}
}
}