Trait kas::Scrollable

source ·
pub trait Scrollable: Widget {
    // Required methods
    fn scroll_axes(&self, size: Size) -> (bool, bool);
    fn max_scroll_offset(&self) -> Offset;
    fn scroll_offset(&self) -> Offset;
    fn set_scroll_offset(
        &mut self,
        cx: &mut EventCx<'_>,
        offset: Offset
    ) -> Offset;
}
Expand description

Additional functionality on scrollable widgets

This trait should be implemented by widgets supporting scrolling, enabling a parent to control scrolling.

If the widget scrolls itself it should set a scroll action via EventCx::set_scroll.

Required Methods§

source

fn scroll_axes(&self, size: Size) -> (bool, bool)

Given size size, returns whether (horiz, vert) scrolling is required

Note: this is called before Layout::set_rect, thus must may need to perform independent calculation of the content size.

source

fn max_scroll_offset(&self) -> Offset

Get the maximum scroll offset

Note: the minimum scroll offset is always zero.

Note: this is called immediately after Layout::set_rect, thus should be updated there (as well as by Events::update if appropriate).

source

fn scroll_offset(&self) -> Offset

Get the current scroll offset

Contents of the scroll region are translated by this offset (to convert coordinates from the outer region to the scroll region, add this offset).

The offset is restricted between Offset::ZERO and Self::max_scroll_offset.

source

fn set_scroll_offset(&mut self, cx: &mut EventCx<'_>, offset: Offset) -> Offset

Set the scroll offset

This may be used for programmatic scrolling, e.g. by a wrapping widget with scroll controls. Note that calling this method directly on the scrolling widget will not update any controls in a wrapping widget.

The offset is clamped to the available scroll range and applied. The resulting offset is returned.

Implementors§

source§

impl<A, F, W> Scrollable for FilterList<A, F, W>
where A: ListData + 'static, F: Filter<<A as SharedData>::Item, Value = String>, W: Widget<Data = UnsafeFilteredList<A>> + Scrollable,

source§

impl<A, F, W, G> Scrollable for FilterBoxList<A, F, W, G>
where A: ListData + 'static, F: Filter<<A as SharedData>::Item, Value = String>, W: Widget<Data = UnsafeFilteredList<A>> + Scrollable, G: EditGuard<Data = ()>,

source§

impl<A, T> Scrollable for ScrollText<A, T>
where T: Default + FormattableText + 'static,

source§

impl<A, V> Scrollable for MatrixView<A, V>
where A: MatrixData, V: Driver<<A as SharedData>::Item, A>,

source§

impl<A, V, D> Scrollable for ListView<A, V, D>
where A: ListData, V: Driver<<A as SharedData>::Item, A>, D: Directional,

source§

impl<A, W, F> Scrollable for Map<A, W, F>
where W: Widget + Scrollable, F: for<'a> Fn(&'a A) -> &'a <W as Widget>::Data,

source§

impl<A, W, S> Scrollable for Adapt<A, W, S>
where W: Widget<Data = S> + Scrollable, S: Debug,

source§

impl<G> Scrollable for EditField<G>
where G: EditGuard,

source§

impl<T> Scrollable for ScrollLabel<T>
where T: FormattableText + 'static,

source§

impl<W> Scrollable for AdaptEvents<W>
where W: Widget + Scrollable,

source§

impl<W> Scrollable for ScrollBarRegion<W>
where W: Widget,

source§

impl<W> Scrollable for ScrollBars<W>
where W: Scrollable + Widget,

source§

impl<W> Scrollable for ScrollRegion<W>
where W: Widget,