Skip to main content

ScrollView

Struct ScrollView 

Source
pub struct ScrollView {
    pub style: Style,
    pub show_scrollbar: bool,
    /* private fields */
}
Expand description

Vertical scrolling viewport over taller content (REND-00 §6).

Children live in content space: a child with bounds y = 0 sits at the top of the content, which coincides with the top of the viewport only while scroll_y == 0.

Fields§

§style: Style

Visual style of the viewport background.

§show_scrollbar: bool

Draw the optional built-in proportional scrollbar thumb (default false; the query seam is the supported contract for custom scrollbars).

Implementations§

Source§

impl ScrollView

Source

pub fn new(bounds: Rect, content_height: i32) -> Self

Create a viewport at bounds over content_height pixels of content. A content height ≤ the viewport height simply never scrolls.

Source

pub fn add_child(&mut self, child: Rc<RefCell<dyn Widget>>)

Add a child widget positioned in content space.

Source

pub fn set_content_height(&mut self, content_height: i32)

Replace the content extent (e.g. after adding rows). The current offset is re-clamped; a clamp that moves it marks the view dirty.

Source

pub fn viewport(&self) -> Rect

The viewport rect (the widget’s own bounds, screen space).

Source

pub fn content_height(&self) -> i32

Total content extent in pixels.

Source

pub fn scroll_y(&self) -> i32

Current per-pixel scroll offset (0..=max_scroll).

Source

pub fn max_scroll(&self) -> i32

Maximum reachable scroll offset.

Source

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

Scroll to an absolute offset, clamped to 0..=max_scroll. Marks the view dirty only when the effective offset changes.

Source

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

Scroll by a signed per-pixel delta (clamped; see scroll_to).

Source

pub fn take_dirty(&mut self) -> Option<Rect>

The region invalidated by scroll-offset changes since the last call: the viewport rect, once, then None until the next change (REND-00 §6.6 — a scrolled panel invalidates its viewport, not the whole frame).

Trait Implementations§

Source§

impl Widget for ScrollView

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

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

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more
Source§

fn set_bounds(&mut self, _bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more

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