Module pager

Source
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ยง

DualPager
This widget renders twp pages of a GenericLayout.
DualPagerBuffer
Renders directly to the frame buffer.
DualPagerState
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.
FormBuffer
Renders directly to the frame buffer.
FormState
Widget state.
PageNavigation
Render the navigation for one or more Pager widgets.
PageNavigationState
Widget state.
Pager
Renders widgets for one page of a GenericLayout.
PagerBuffer
Rendering phase.
PagerStyle
All styles for a pager.
SinglePager
This widget renders a single page of a GenericLayout.
SinglePagerBuffer
Renders directly to the frame buffer.
SinglePagerState
Widget state.