Fusuma

Components / Tiling

tiling

The panes of tiles, each made by pane from its number, with a bar over every cut.

How it looks

Drawn by the toolkit from the example below. No page of the gallery uses tiling yet, so there is nothing to run.

tiling drawn by Fusuma

The panes of tiles, each made by pane from its number, with a bar over every cut. on_resize makes the message of a drag from the split's number and its new position in thousandths; the app answers it with Tiles::resize.

The app keeps the Tiles (which panes there are and where the cuts are); a drag on a bar sends on_resize, and the app answers with tiles.resize(split, permille).

Signature

pub fn tiling<'a, M: Clone + 'a, V: View<M> + 'a, const T: usize>( tiles: &'a Tiles<T>, on_resize: fn(u16, u16) -> M, pane: fn(u16) -> V, ) -> impl View<M> + 'a

Example

use fusuma::{Tiles, text, tiling};
let mut tiles = Tiles::<4>::new(1);
tiles.split(1, false, 2);
let view = tiling(&tiles, |split, permille| (split, permille), |pane| text(if pane == 1 { "Left" } else { "Right" }));
let built = fusuma::doc::built::<(u16, u16), _>(&view);
assert_eq!(built.texts(), ["Left", "Right"]);

All components · Source