⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

ScrollState

Struct ScrollState 

Source
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: i32

Current vertical scroll offset (pixels)

§max_scroll_y: i32

Maximum scroll offset (content_height - viewport_height)

§viewport_height: i32

Viewport height (pixels)

§content_height: i32

Total content height (pixels)

§scroll_x: i32

Horizontal scroll offset (pixels)

§max_scroll_x: i32

Maximum horizontal scroll

§viewport_width: i32

Viewport width

§content_width: i32

Total content width

Implementations§

Source§

impl ScrollState

Source

pub fn new(viewport_width: i32, viewport_height: i32) -> Self

Source

pub fn set_content_size(&mut self, width: i32, height: i32)

Update content dimensions and recalculate max scroll

Source

pub fn set_viewport_size(&mut self, width: i32, height: i32)

Update viewport dimensions

Source

pub fn scroll_by(&mut self, dx: i32, dy: i32)

Scroll by a delta (positive = down/right)

Source

pub fn scroll_to(&mut self, x: i32, y: i32)

Scroll to an absolute position

Source

pub fn ensure_visible_y(&mut self, y: i32, height: i32)

Scroll to make a vertical position visible

Source

pub fn needs_v_scrollbar(&self) -> bool

Whether a vertical scrollbar is needed

Source

pub fn needs_h_scrollbar(&self) -> bool

Whether a horizontal scrollbar is needed

Source

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

Source§

fn clone(&self) -> ScrollState

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ScrollState

Source§

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

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

impl Default for ScrollState

Source§

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.