polyhorn_ui/components/
scrollable.rs

1use polyhorn_core::Reference;
2
3use crate::handles::ScrollableHandle;
4use crate::styles::ScrollableViewStyle;
5
6#[derive(Copy, Clone, Debug, Eq, PartialEq)]
7pub enum ScrollDirection {
8    Both,
9    Horizontal,
10    Vertical,
11}
12
13/// Implements scroll gestures and bars to accommodate layouts that exceed
14/// screen or container dimensions.
15#[derive(Clone)]
16pub struct Scrollable {
17    /// Controls the appearance of this Scrollable.
18    pub style: ScrollableViewStyle,
19
20    /// Controls the direction(s) in which this Scrollable can be scrolled.
21    pub direction: ScrollDirection,
22
23    /// Replaces the handle within this reference with a handle to this
24    /// Scrollable that can be used to access its API in imperative code.
25    pub reference: Option<Reference<Box<dyn ScrollableHandle>>>,
26}
27
28impl Default for Scrollable {
29    fn default() -> Self {
30        Scrollable {
31            style: ScrollableViewStyle::default(),
32            direction: ScrollDirection::Vertical,
33            reference: None,
34        }
35    }
36}