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
use polyhorn_core::Reference;

use crate::handles::ScrollableHandle;
use crate::styles::ScrollableViewStyle;

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ScrollDirection {
    Both,
    Horizontal,
    Vertical,
}

/// Implements scroll gestures and bars to accommodate layouts that exceed
/// screen or container dimensions.
#[derive(Clone)]
pub struct Scrollable {
    /// Controls the appearance of this Scrollable.
    pub style: ScrollableViewStyle,

    /// Controls the direction(s) in which this Scrollable can be scrolled.
    pub direction: ScrollDirection,

    /// Replaces the handle within this reference with a handle to this
    /// Scrollable that can be used to access its API in imperative code.
    pub reference: Option<Reference<Box<dyn ScrollableHandle>>>,
}

impl Default for Scrollable {
    fn default() -> Self {
        Scrollable {
            style: ScrollableViewStyle::default(),
            direction: ScrollDirection::Vertical,
            reference: None,
        }
    }
}