pub struct Viewport {
pub width: f32,
pub height: f32,
pub scroll_offset: f32,
pub total_content_height: f32,
pub top_offset: f32,
pub pinned_to_bottom: bool,
}Expand description
Tracks the visible portion of the block stream.
Fields§
§width: f32§height: f32§scroll_offset: f32§total_content_height: f32§top_offset: f32Physical-pixel offset from the top of the window where the block stream begins. Lets a tab strip (or other chrome) render above the blocks without overlap.
pinned_to_bottom: boolTrue when the user is at (or near) the bottom and auto-scroll should track new content. Set to false when the user explicitly scrolls up; restored when they return to the bottom.
Implementations§
Source§impl Viewport
impl Viewport
pub fn new(width: f32, height: f32) -> Self
Sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Snap to the top.
Sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Snap to the bottom (show latest content).
Sourcepub fn scroll_to(&mut self, y: f32)
pub fn scroll_to(&mut self, y: f32)
Scroll so a content-space y position is visible, aligned near the top.
pub fn resize(&mut self, width: f32, height: f32)
Sourcepub fn is_visible(&self, y: f32, h: f32) -> bool
pub fn is_visible(&self, y: f32, h: f32) -> bool
Is a y-coordinate (in content space) visible?
Sourcepub fn content_to_screen_y(&self, content_y: f32) -> f32
pub fn content_to_screen_y(&self, content_y: f32) -> f32
Convert content-space y to screen-space y.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin for Viewport
impl UnsafeUnpin for Viewport
impl UnwindSafe for Viewport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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