Struct rat_widget::scrolled::ScrolledState

source ·
pub struct ScrolledState<WidgetState> {
    pub widget: WidgetState,
    pub area: Rect,
    pub view_area: Rect,
    pub h_scrollbar_area: Option<Rect>,
    pub v_scrollbar_area: Option<Rect>,
    pub v_overscroll: usize,
    pub h_overscroll: usize,
    pub v_drag: bool,
    pub h_drag: bool,
    pub non_exhaustive: NonExhaustive,
}
Expand description

Scrolled state.

Fields§

§widget: WidgetState

State of the scrolled widget.

§area: Rect

Total screen area.

§view_area: Rect

View area.

§h_scrollbar_area: Option<Rect>

Scrollbar area.

§v_scrollbar_area: Option<Rect>

Scrollbar area.

§v_overscroll: usize

Allow overscroll by n items.

§h_overscroll: usize

Allow overscroll by n items.

§v_drag: bool

mouse action in progress

§h_drag: bool§non_exhaustive: NonExhaustive

Implementations§

source§

impl<WState> ScrolledState<WState>
where WState: ScrollingState,

source

pub fn vertical_offset(&self) -> usize

Current vertical offset.

source

pub fn horizontal_offset(&self) -> usize

Current horizontal offset.

source

pub fn set_vertical_offset(&mut self, offset: usize) -> bool

Change the offset. Limits the offset to max_v_offset + v_overscroll.

Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.

source

pub fn set_horizontal_offset(&mut self, offset: usize) -> bool

Change the offset. Limits the offset to max_h_offset + h_overscroll.

Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.

source

pub fn scroll_up(&mut self, n: usize) -> bool

Scroll up by n.

source

pub fn scroll_down(&mut self, n: usize) -> bool

Scroll down by n, but limited by the max_offset + overscroll

source

pub fn scroll_left(&mut self, n: usize) -> bool

Scroll up by n.

source

pub fn scroll_right(&mut self, n: usize) -> bool

Scroll right by n, but limited by the max_offset + overscroll

source

pub fn widget_mut(&mut self) -> &mut WState

Trait Implementations§

source§

impl<WidgetState> Clone for ScrolledState<WidgetState>
where WidgetState: Clone,

source§

fn clone(&self) -> ScrolledState<WidgetState>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<WidgetState> Debug for ScrolledState<WidgetState>
where WidgetState: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<WState> Default for ScrolledState<WState>
where WState: Default,

source§

fn default() -> ScrolledState<WState>

Returns the “default value” for a type. Read more
source§

impl<R, WState> HandleEvent<Event, FocusKeys, ScrollOutcome<R>> for ScrolledState<WState>

Handle events or the scrolled widget and forward to the inner widget.

source§

fn handle(&mut self, event: &Event, _keymap: FocusKeys) -> ScrollOutcome<R>

Handle an event. Read more
source§

impl<WState, Q, R> HandleEvent<Event, Inner<Q>, ScrollOutcome<R>> for ScrolledState<WState>
where WState: ScrollingState + HandleEvent<Event, Q, R>, R: ConsumedEvent,

Forward event-handling to the inner widget.

source§

fn handle(&mut self, event: &Event, qualifier: Inner<Q>) -> ScrollOutcome<R>

Handle an event. Read more
source§

impl<R, WState> HandleEvent<Event, MouseOnly, ScrollOutcome<R>> for ScrolledState<WState>

Handle events for the Scrolled widget and the scrollbars.

source§

fn handle(&mut self, event: &Event, _keymap: MouseOnly) -> ScrollOutcome<R>

Handle an event. Read more

Auto Trait Implementations§

§

impl<WidgetState> Freeze for ScrolledState<WidgetState>
where WidgetState: Freeze,

§

impl<WidgetState> RefUnwindSafe for ScrolledState<WidgetState>
where WidgetState: RefUnwindSafe,

§

impl<WidgetState> Send for ScrolledState<WidgetState>
where WidgetState: Send,

§

impl<WidgetState> Sync for ScrolledState<WidgetState>
where WidgetState: Sync,

§

impl<WidgetState> Unpin for ScrolledState<WidgetState>
where WidgetState: Unpin,

§

impl<WidgetState> UnwindSafe for ScrolledState<WidgetState>
where WidgetState: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.