Trait kas_widgets::Scrollable[][src]

pub trait Scrollable: Widget {
    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,
        mgr: &mut Manager<'_>,
        offset: Offset
    ) -> Offset; fn scroll_by_delta(
        &mut self,
        mgr: &mut Manager<'_>,
        delta: Offset
    ) -> Offset { ... } }
Expand description

Additional functionality on scrollable widgets

This trait should be implemented by widgets supporting scrolling, enabling a parent (such as the ScrollBars wrapper) to add controls.

The implementing widget may use event handlers to scroll itself (e.g. in reaction to a mouse wheel or touch-drag), but when doing so should emit Response::Focus to notify any wrapper of the new position (usually with Response::Focus(self.rect())).

Required methods

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

Get the maximum scroll offset

Note: the minimum scroll offset is always zero.

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 ScrollRegion::max_scroll_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.

Provided methods

Scroll by a delta

Returns the remaining (unused) delta.

Implementors