Expand description
Alternative to scrolling by page-breaking a layout.
If you have a lot of widgets to display, splitting them into pages is an alternative to scrolling.
/// Single pager shows the widgets in one column, and
/// can page through the list.
let pager = SinglePager::new();
let size = pager.layout_size(l2[1]);
if !state.pager.valid_layout(size) {
// GenericLayout is very basic.
// Try LayoutForm or layout_edit() instead.
let mut pl = GenericLayout::new();
for i in 0..100 {
pl.add(
state.check_states[i].focus.clone(), // widget-key
Rect::new(10, 10+i as u16, 15, 10), // widget area
None, // label text
Rect::default() // label area
);
}
state.pager.set_layout(pl);
}
///
/// Use [SinglePager] or [DualPager] to calculate the page breaks.
///
let mut pg_buf = pager
.into_buffer(l2[1], &mut buf, &mut state.pager);
///
/// Render your widgets with the help of [SinglePagerBuffer]/[DualPagerBuffer]
///
for i in 0..100 {
pg_buf.render(
state.check_states[i].focus.clone(),
|| {
Checkbox::new().text(format!("{:?}", i).to_string())
},
&mut state.check_states[i],
);
}
Structsยง
- Dual
Pager - This widget renders twp pages of a GenericLayout.
- Dual
Pager Buffer - Renders directly to the frame buffer.
- Dual
Pager State - Widget state.
- Form
- A widget that helps with rendering a Form. Uses a GenericLayout for its layout information. Does no scrolling/paging whatsoever and any widgets out of view are simply not rendered.
- Form
Buffer - Renders directly to the frame buffer.
- Form
State - Widget state.
- Page
Navigation - Render the navigation for one or more Pager widgets.
- Page
Navigation State - Widget state.
- Pager
- Renders widgets for one page of a GenericLayout.
- Pager
Buffer - Rendering phase.
- Pager
Style - All styles for a pager.
- Single
Pager - This widget renders a single page of a GenericLayout.
- Single
Pager Buffer - Renders directly to the frame buffer.
- Single
Pager State - Widget state.