1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#![doc = include_str!("../readme.md")]
#![allow(clippy::collapsible_else_if)]

mod inner;
mod scrolled;
mod util;
pub mod view;
pub mod viewport;

pub use scrolled::{
    core, layout_scroll, layout_scroll_inner, Scroll, ScrollArea, ScrollState, ScrollbarPolicy,
    ScrolledStyle,
};

pub mod event {
    use rat_event::{ConsumedEvent, Outcome};

    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
    pub enum ScrollOutcome {
        /// The given event has not been used at all.
        NotUsed,
        /// The event has been recognized, but the result was nil.
        /// Further processing for this event may stop.
        Unchanged,
        /// The event has been recognized and there is some change
        /// due to it.
        /// Further processing for this event may stop.
        /// Rendering the ui is advised.
        Changed,
        /// Scroll delta when using HandleEvent for area scrolling.
        Up(usize),
        /// Scroll delta when using HandleEvent for area scrolling.
        Down(usize),
        /// Scroll delta when using HandleEvent for area scrolling.
        Left(usize),
        /// Scroll delta when using HandleEvent for area scrolling.
        Right(usize),
        /// Absolute position.
        VPos(usize),
        /// Absolute position.
        HPos(usize),
    }

    impl ConsumedEvent for ScrollOutcome {
        fn is_consumed(&self) -> bool {
            !matches!(self, ScrollOutcome::NotUsed)
        }
    }

    impl From<ScrollOutcome> for Outcome {
        fn from(value: ScrollOutcome) -> Self {
            match value {
                ScrollOutcome::NotUsed => Outcome::NotUsed,
                ScrollOutcome::Unchanged => Outcome::Unchanged,
                ScrollOutcome::Changed => Outcome::Changed,
                ScrollOutcome::Up(_) => Outcome::Changed,
                ScrollOutcome::Down(_) => Outcome::Changed,
                ScrollOutcome::Left(_) => Outcome::Changed,
                ScrollOutcome::Right(_) => Outcome::Changed,
                ScrollOutcome::VPos(_) => Outcome::Changed,
                ScrollOutcome::HPos(_) => Outcome::Changed,
            }
        }
    }
}

mod _private {
    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct NonExhaustive;
}