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: StyleVisual style of the viewport background.
show_scrollbar: boolDraw the optional built-in proportional scrollbar thumb
(default false; the query seam is the supported contract for
custom scrollbars).
Implementations§
Source§impl ScrollView
impl ScrollView
Sourcepub fn new(bounds: Rect, content_height: i32) -> Self
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.
Sourcepub fn add_child(&mut self, child: Rc<RefCell<dyn Widget>>)
pub fn add_child(&mut self, child: Rc<RefCell<dyn Widget>>)
Add a child widget positioned in content space.
Sourcepub fn set_content_height(&mut self, content_height: i32)
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.
Sourcepub fn content_height(&self) -> i32
pub fn content_height(&self) -> i32
Total content extent in pixels.
Sourcepub fn max_scroll(&self) -> i32
pub fn max_scroll(&self) -> i32
Maximum reachable scroll offset.
Sourcepub fn scroll_to(&mut self, y: i32)
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.
Sourcepub fn scroll_by(&mut self, dy: i32)
pub fn scroll_by(&mut self, dy: i32)
Scroll by a signed per-pixel delta (clamped; see
scroll_to).
Sourcepub fn take_dirty(&mut self) -> Option<Rect>
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
impl Widget for ScrollView
Source§fn handle_event(&mut self, event: &Event) -> bool
fn handle_event(&mut self, event: &Event) -> bool
true if it was consumed. Read moreSource§fn clear_region(&mut self) -> Option<Rect>
fn clear_region(&mut self) -> Option<Rect>
None. Read more