pagination
Builds Pagination Select


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn pagination(window: &mut Window, cx: &mut App) -> AnyElement {
if !cx.has_global::<ScenePagination>() {
let page_size = cx.new(|cx| {
Select::new("scene.pagination.size", window, cx)
.options([
SelectOption::new("25", "25 per page"),
SelectOption::new("50", "50 per page"),
SelectOption::new("100", "100 per page"),
])
.selected("50")
});
cx.set_global(ScenePagination { page_size });
}
let page_size = cx.global::<ScenePagination>().page_size.clone();
let theme = cx.theme().clone();
stack(&theme)
.w(px(620.0))
.child(
Pagination::new("scene.pagination.known")
.page(9)
.total_pages(20)
.page_size(page_size)
.on_select(|_, _, _| {}),
)
// A host that only knows there is another page says exactly that: no
// last-page control, no numbers, and no total.
.child(
Pagination::new("scene.pagination.unknown")
.page(3)
.unknown_total(true)
.on_select(|_, _, _| {}),
)
.into_any_element()
}