Fusuma

Components / Components

page_window

The PAGE_SLOTS buttons for page current of total (both counted from 1; out-of-range values are held in range): every page when they fit, else the first, the last, the neighbours of the current one and a gap where pages are left out, the current one never at the edge of a gap.

The PAGE_SLOTS buttons for page current of total (both counted from 1; out-of-range values are held in range): every page when they fit, else the first, the last, the neighbours of the current one and a gap where pages are left out, the current one never at the edge of a gap.

Signature

pub fn page_window(current: u32, total: u32) -> [PageSlot; PAGE_SLOTS]

Example

use fusuma::{PageSlot, page_window};
// Five pages all fit; fifty do not: the first, the neighbours of page 25, the last, and gaps between.
assert_eq!(page_window(2, 3)[..3], [PageSlot::Page(1), PageSlot::Page(2), PageSlot::Page(3)]);
let slots = page_window(25, 50);
assert_eq!(slots[0], PageSlot::Page(1));
assert!(slots.contains(&PageSlot::Gap));
assert!(slots.contains(&PageSlot::Page(25)));
assert_eq!(slots[slots.len() - 1], PageSlot::Page(50));

All components · Source