Skip to main content

ScrollViewState

Struct ScrollViewState 

Source
pub struct ScrollViewState { /* private fields */ }

Implementations§

Source§

impl ScrollViewState

Source

pub fn new() -> Self

Source

pub fn with_offset(offset: Position) -> Self

Source

pub const fn set_offset(&mut self, offset: Position)

Source

pub const fn offset(&self) -> Position

Source

pub const fn scroll_up(&mut self)

Source

pub const fn scroll_down(&mut self)

Source

pub fn scroll_page_down(&mut self)

Source

pub fn scroll_page_up(&mut self)

Source

pub const fn scroll_left(&mut self)

Source

pub const fn scroll_right(&mut self)

Source

pub const fn scroll_to_top(&mut self)

Source

pub fn scroll_to_bottom(&mut self)

Source

pub const fn size(&self) -> Option<Size>

The content size (the full scrollable buffer). None before the first render.

Source

pub const fn page_size(&self) -> Option<Size>

The visible page size (viewport after scrollbars). None before the first render.

Source

pub fn is_at_bottom(&self) -> bool

Whether the last content row is visible in the current page.

Returns true before the first render (size unknown). Ported from upstream tui-scrollview; relies on page_size meaning the visible viewport.

Source

pub fn scroll_to_visible(&mut self, y: u16, height: u16)

Scroll the vertical offset the minimum amount so the row range [y, y + height) is inside the visible page. No-op if already visible.

The render pass re-clamps against the content, so this only needs to move the offset toward the target.

Source

pub fn child_area(&self, index: usize) -> Option<Rect>

The content-buffer area of the direct child at index (in child order), as recorded by ScrollView on the last render. None before the first render or when index is out of range.

Source

pub fn scroll_to_index(&mut self, index: usize)

Scroll so the direct child at index (in child order) is visible.

This is the “follow the selection” primitive: after a page moves its selection over a list of ScrollView children, call this with the selected index so the viewport tracks it. No-op if index is unknown (e.g. before the first render). Child geometry is selection-independent, so the last recorded layout is correct for the new selection.

Source

pub fn handle_event(&mut self, event: &Event) -> bool

Returns true if the event was a scroll input this state acted on.

Trait Implementations§

Source§

impl Clone for ScrollViewState

Source§

fn clone(&self) -> ScrollViewState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ScrollViewState

Source§

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

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

impl Default for ScrollViewState

Source§

fn default() -> ScrollViewState

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

impl Eq for ScrollViewState

Source§

impl Hash for ScrollViewState

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ScrollViewState

Source§

fn eq(&self, other: &ScrollViewState) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScrollViewState

Auto Trait Implementations§

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> Any for T
where T: Any,

Source§

impl<T> AnyHash for T
where T: Eq + Hash + 'static,

Source§

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

Source§

fn eq(&self, other: &(dyn AnyHash + 'static)) -> bool

Source§

fn hash(&self, hasher: &mut dyn Hasher)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more