pub struct ScrollState {
pub scroll_y: i32,
pub max_scroll_y: i32,
pub viewport_height: i32,
pub content_height: i32,
pub scroll_x: i32,
pub max_scroll_x: i32,
pub viewport_width: i32,
pub content_width: i32,
}Expand description
Viewport scroll state
Fields§
§scroll_y: i32Current vertical scroll offset (pixels)
max_scroll_y: i32Maximum scroll offset (content_height - viewport_height)
viewport_height: i32Viewport height (pixels)
content_height: i32Total content height (pixels)
scroll_x: i32Horizontal scroll offset (pixels)
max_scroll_x: i32Maximum horizontal scroll
viewport_width: i32Viewport width
content_width: i32Total content width
Implementations§
Source§impl ScrollState
impl ScrollState
pub fn new(viewport_width: i32, viewport_height: i32) -> Self
Sourcepub fn set_content_size(&mut self, width: i32, height: i32)
pub fn set_content_size(&mut self, width: i32, height: i32)
Update content dimensions and recalculate max scroll
Sourcepub fn set_viewport_size(&mut self, width: i32, height: i32)
pub fn set_viewport_size(&mut self, width: i32, height: i32)
Update viewport dimensions
Sourcepub fn ensure_visible_y(&mut self, y: i32, height: i32)
pub fn ensure_visible_y(&mut self, y: i32, height: i32)
Scroll to make a vertical position visible
Sourcepub fn needs_v_scrollbar(&self) -> bool
pub fn needs_v_scrollbar(&self) -> bool
Whether a vertical scrollbar is needed
Sourcepub fn needs_h_scrollbar(&self) -> bool
pub fn needs_h_scrollbar(&self) -> bool
Whether a horizontal scrollbar is needed
Sourcepub fn v_scrollbar_thumb(&self, track_height: i32) -> (i32, i32)
pub fn v_scrollbar_thumb(&self, track_height: i32) -> (i32, i32)
Get scrollbar thumb position and size for vertical scrollbar. Returns (thumb_y, thumb_height) in pixels within the track.
Trait Implementations§
Source§impl Clone for ScrollState
impl Clone for ScrollState
Source§fn clone(&self) -> ScrollState
fn clone(&self) -> ScrollState
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScrollState
impl Debug for ScrollState
Source§impl Default for ScrollState
impl Default for ScrollState
Source§fn default() -> ScrollState
fn default() -> ScrollState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ScrollState
impl RefUnwindSafe for ScrollState
impl Send for ScrollState
impl Sync for ScrollState
impl Unpin for ScrollState
impl UnwindSafe for ScrollState
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)