Skip to main content

day_spec/controls/
pager.rs

1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4pub const KIND: &str = "day.piece.pager";
5#[derive(Clone, Debug, PartialEq, Eq, Default)]
6pub struct PagerState {
7    pub order: Vec<usize>,
8    pub selected: usize,
9    pub epoch: u64,
10}
11impl PagerState {
12    #[must_use]
13    pub fn accepts(&self, epoch: u64, slot: usize) -> bool {
14        self.epoch == epoch && self.order.contains(&slot)
15    }
16}
17#[derive(Clone, Debug)]
18pub struct PagerProps {
19    pub slots: usize,
20    /// Report the pager's continuous position while a page is dragged (docs/pager.md
21    /// "Progress"): an `Event::Custom` whose text is `progress <epoch> <position>`, the
22    /// position in reading-order pages (`1.5` is halfway from the second page to the third),
23    /// at most once per display frame.
24    pub track_progress: bool,
25}
26#[derive(Clone, Debug)]
27pub struct PagerPatch(pub PagerState);