pub struct ScrollView { /* private fields */ }Expand description
ScrollView - A scrollable container.
Provides vertical scrolling with optional follow-end behavior. In constrained layout, the child is measured at unbounded height and clipped to the allocated viewport.
Implementations§
Source§impl ScrollView
impl ScrollView
Sourcepub fn new(child: Arc<dyn Component>, options: ScrollViewOptions) -> Self
pub fn new(child: Arc<dyn Component>, options: ScrollViewOptions) -> Self
Create a new ScrollView with the given child.
Sourcepub fn simple(child: Arc<dyn Component>) -> Self
pub fn simple(child: Arc<dyn Component>) -> Self
Create a simple ScrollView with default options.
Sourcepub fn primary(child: Arc<dyn Component>) -> Self
pub fn primary(child: Arc<dyn Component>) -> Self
Create a primary ScrollView with follow-end behavior.
Sourcepub fn scroll_top(&self) -> usize
pub fn scroll_top(&self) -> usize
Get the current scroll position.
Sourcepub fn is_following_end(&self) -> bool
pub fn is_following_end(&self) -> bool
Check if following the end.
Sourcepub fn follows_end(&self) -> bool
pub fn follows_end(&self) -> bool
Whether this view can automatically follow newly appended content.
Sourcepub fn viewport_height(&self) -> usize
pub fn viewport_height(&self) -> usize
Get the viewport height.
Sourcepub fn content_height(&self) -> usize
pub fn content_height(&self) -> usize
Get the content height.
Sourcepub fn is_primary(&self) -> bool
pub fn is_primary(&self) -> bool
Check if this is the primary scroll view.
Sourcepub fn is_scrollbar_visible(&self) -> bool
pub fn is_scrollbar_visible(&self) -> bool
Check if scrollbar is visible.
Sourcepub fn get_content_width(&self, width: usize) -> usize
pub fn get_content_width(&self, width: usize) -> usize
Get the content width (accounting for scrollbar).
Sourcepub fn scroll_by(&self, delta: i32) -> i32
pub fn scroll_by(&self, delta: i32) -> i32
Scroll by the given number of lines.
Returns the unused delta if scrolling hit the boundary. This enables scroll chaining for nested scroll views.
Sourcepub fn scroll_to_start(&self)
pub fn scroll_to_start(&self)
Scroll to the start.
Sourcepub fn scroll_to_end(&self)
pub fn scroll_to_end(&self)
Scroll to the end.
Sourcepub fn update_layout(
&self,
content_height: usize,
viewport_height: usize,
request_render: Option<Arc<dyn Fn() + Send + Sync>>,
)
pub fn update_layout( &self, content_height: usize, viewport_height: usize, request_render: Option<Arc<dyn Fn() + Send + Sync>>, )
Update layout information (called by the layout system).
Sourcepub fn render_with_viewport(&self, width: usize, height: usize) -> Vec<String>
pub fn render_with_viewport(&self, width: usize, height: usize) -> Vec<String>
Render fresh child content, applying scroll for a fixed viewport.
Normal UI updates use this path so streamed text and mutable tool components are reflected immediately. The result also primes the cache used by subsequent pure scroll frames.
Sourcepub fn render_with_cached_content(
&self,
width: usize,
height: usize,
) -> Vec<String>
pub fn render_with_cached_content( &self, width: usize, height: usize, ) -> Vec<String>
Apply the viewport to the last rendered child content when possible. A width change automatically falls back to a fresh render.
Sourcepub fn scrollbar_style(&self, text: &str) -> String
pub fn scrollbar_style(&self, text: &str) -> String
Get the scrollbar style (can be customized).