Skip to main content

ferroui_base/input/
i_scrollable.rs

1use crate::{Size, Vector};
2
3/// Interface implemented by scrollable controls.
4///
5/// Upstream this contract lives with the control primitives; it is defined
6/// here because directional navigation is its only consumer in the base
7/// library so far. An input element exposes it through the
8/// `as_scrollable` virtual member of `InputElement`.
9pub trait IScrollable {
10    /// The extent of the scrollable content, in logical units.
11    fn extent(&self) -> Size;
12
13    /// The current scroll offset, in logical units.
14    fn offset(&self) -> Vector;
15
16    /// Sets the current scroll offset, in logical units.
17    fn set_offset(&self, value: Vector);
18
19    /// The size of the viewport, in logical units.
20    fn viewport(&self) -> Size;
21
22    /// Whether the content can be scrolled horizontally.
23    fn can_horizontally_scroll(&self) -> bool;
24
25    /// Whether the content can be scrolled vertically.
26    fn can_vertically_scroll(&self) -> bool;
27}