Skip to main content

KeepVisible

Struct KeepVisible 

Source
pub struct KeepVisible {
    pub key: u64,
    pub rect: Rect,
    pub centre: bool,
}
Expand description

A box a scroll region has been asked to keep in view, and which box it is.

A tab bar wider than its window is what this is for. Declared by the content through Widget::keep_visible, carried on the region so it survives a repaint boundary like everything else about the region, and acted on by crate::Runtime::sync_visible.

Fields§

§key: u64

Which box this is. The region acts when this changes and not otherwise: the box moves as the region scrolls, so a region chasing the box itself would pin the content in place and no finger could move it.

§rect: Rect

The box: in the declaring widget’s own coordinates when it comes back from Widget::keep_visible, and in the frame’s — as it would sit at offset zero — when it reaches the region.

At rest rather than where it is actually drawn, and that is the whole reason the answer can be trusted. A box recorded where it is drawn is a box whose position already contains the current offset, so the offset that would centre it can only be worked out relative to wherever the region happens to be — and on the first frame, before anything has been retained, there is no wherever to be relative to. Recorded at rest, the answer is absolute: the same number on the first frame and the hundredth.

§centre: bool

Put it in the middle of the window rather than merely inside it. What a tab bar wants: a selected tab flush against the edge reads as the end of the row. Clamped either way, so the first tab still rests at the start.

Trait Implementations§

Source§

impl Clone for KeepVisible

Source§

fn clone(&self) -> Self

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 Copy for KeepVisible

Source§

impl Debug for KeepVisible

Source§

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

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

impl PartialEq for KeepVisible

Source§

fn eq(&self, other: &Self) -> 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 KeepVisible

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> 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<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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.