output: refactor Content and Render traits

This commit is contained in:
🪞👃🪞 2025-09-06 08:46:52 +03:00
parent 74b3af2212
commit 1c21a85f27
24 changed files with 346 additions and 613 deletions

View file

@ -66,7 +66,7 @@ impl_map_direction!(south, y, n);
impl_map_direction!(west, x, e);
impl_map_direction!(north, y, s);
impl<'a, E, A, B, I, F, G> Content<E> for Map<E, A, B, I, F, G> where
impl<'a, E, A, B, I, F, G> Render<E> for Map<E, A, B, I, F, G> where
E: Output,
B: Render<E>,
I: Iterator<Item = A> + Send + Sync + 'a,
@ -94,7 +94,7 @@ impl<'a, E, A, B, I, F, G> Content<E> for Map<E, A, B, I, F, G> where
fn render (&self, to: &mut E) {
let Self { get_iter, get_item, .. } = self;
let mut index = 0;
let area = Content::layout(self, to.area());
let area = Render::layout(self, to.area());
for item in get_iter() {
let item = get_item(item, index);
//to.place(area.into(), &item);
@ -107,24 +107,24 @@ impl<'a, E, A, B, I, F, G> Content<E> for Map<E, A, B, I, F, G> where
#[inline] pub fn map_south<O: Output>(
item_offset: O::Unit,
item_height: O::Unit,
item: impl Content<O>
) -> impl Content<O> {
item: impl Render<O>
) -> impl Render<O> {
Push::y(item_offset, Fixed::y(item_height, Fill::x(item)))
}
#[inline] pub fn map_south_west<O: Output>(
item_offset: O::Unit,
item_height: O::Unit,
item: impl Content<O>
) -> impl Content<O> {
item: impl Render<O>
) -> impl Render<O> {
Push::y(item_offset, Align::nw(Fixed::y(item_height, Fill::x(item))))
}
#[inline] pub fn map_east<O: Output>(
item_offset: O::Unit,
item_width: O::Unit,
item: impl Content<O>
) -> impl Content<O> {
item: impl Render<O>
) -> impl Render<O> {
Push::x(item_offset, Align::w(Fixed::x(item_width, Fill::y(item))))
}