pub struct ScrollView { /* private fields */ }Implementations§
Source§impl ScrollView
impl ScrollView
pub fn new<W>(child: W) -> ScrollViewwhere
W: Widget + 'static,
Sourcepub fn vertical<W>(child: W) -> ScrollViewwhere
W: Widget + 'static,
pub fn vertical<W>(child: W) -> ScrollViewwhere
W: Widget + 'static,
Examples found in repository?
3fn main() -> Result<()> {
4 let theme = DefaultTheme::dark();
5 let document = RichDocumentModel::from_markdown(
6 r#"# Deployment report
7
8SUI keeps this document selectable across blocks. Follow the [runbook](https://example.test/runbook) for details.
9
10- [x] Build artifacts
11- [x] Run tests
12- [ ] Publish release
13
14```rust
15let status = deploy().await?;
16assert!(status.ready());
17```
18"#,
19 );
20
21 let mut operation = RichExtensionBlock::new("operation-log", "Release operation");
22 operation.status = RichDocumentStatus::Running;
23 operation.summary = Some("2 of 3 stages complete".into());
24 operation.body = "build complete\ntest complete\npublish running".into();
25 document.append_extension(operation);
26
27 let view = RichDocumentView::new(document)
28 .theme(theme)
29 .on_link(|destination| println!("Application URL policy received: {destination}"));
30 let root = Surface::window(ScrollView::vertical(view).retain_content_layer())
31 .theme(theme)
32 .padding(Insets::all(24.0))
33 .fill();
34
35 App::new()
36 .window(Window::new("SUI Rich Document").root(root))
37 .run()
38}pub fn horizontal<W>(child: W) -> ScrollViewwhere
W: Widget + 'static,
pub fn both<W>(child: W) -> ScrollViewwhere
W: Widget + 'static,
pub fn axes(self, axes: ScrollAxes) -> ScrollView
pub fn overflow(self, overflow: Overflow) -> ScrollView
pub fn overflow_x(self, overflow: Overflow) -> ScrollView
pub fn overflow_y(self, overflow: Overflow) -> ScrollView
Sourcepub const fn content_width(self, extent: ContentExtent) -> ScrollView
pub const fn content_width(self, extent: ContentExtent) -> ScrollView
Select how the child width is derived when horizontal overflow is enabled.
Sourcepub const fn content_height(self, extent: ContentExtent) -> ScrollView
pub const fn content_height(self, extent: ContentExtent) -> ScrollView
Select how the child height is derived when vertical overflow is enabled.
Sourcepub const fn shrink_height(self, enabled: bool) -> ScrollView
pub const fn shrink_height(self, enabled: bool) -> ScrollView
Fit short content while retaining vertical scrolling when it exceeds the available height. Parent minimum constraints still take precedence.
pub fn name(self, name: impl Into<String>) -> ScrollView
pub fn theme(self, theme: DefaultTheme) -> ScrollView
pub fn theme_when<F>(self, theme: F) -> ScrollViewwhere
F: Fn() -> DefaultTheme + 'static,
pub fn state(self, state: ScrollState) -> ScrollView
Sourcepub fn overlay_scroll_bars(self, enabled: bool) -> ScrollView
pub fn overlay_scroll_bars(self, enabled: bool) -> ScrollView
Controls the built-in scroll bars beside overflowing content.
Disable this when composing a standalone ScrollBar with the same
ScrollState.
Compatibility name for scroll_bars. Built-in bars reserve layout space.
Sourcepub fn scroll_bars(self, enabled: bool) -> ScrollView
pub fn scroll_bars(self, enabled: bool) -> ScrollView
Show built-in scrollbars in their own gutters when content overflows.
pub const fn viewport_size_hint(self, enabled: bool) -> ScrollView
pub const fn viewport_width_hint(self, enabled: bool) -> ScrollView
pub const fn viewport_height_hint(self, enabled: bool) -> ScrollView
Sourcepub fn retain_content_layer(self) -> ScrollView
pub fn retain_content_layer(self) -> ScrollView
Retains the complete child subtree behind a paint boundary so scrolling can move it with a composition-only transform.
This is best for content that is expensive to repaint but cheap to composite. Very large text or deeply layered scenes may render faster with the default flattened path.
Examples found in repository?
3fn main() -> Result<()> {
4 let theme = DefaultTheme::dark();
5 let document = RichDocumentModel::from_markdown(
6 r#"# Deployment report
7
8SUI keeps this document selectable across blocks. Follow the [runbook](https://example.test/runbook) for details.
9
10- [x] Build artifacts
11- [x] Run tests
12- [ ] Publish release
13
14```rust
15let status = deploy().await?;
16assert!(status.ready());
17```
18"#,
19 );
20
21 let mut operation = RichExtensionBlock::new("operation-log", "Release operation");
22 operation.status = RichDocumentStatus::Running;
23 operation.summary = Some("2 of 3 stages complete".into());
24 operation.body = "build complete\ntest complete\npublish running".into();
25 document.append_extension(operation);
26
27 let view = RichDocumentView::new(document)
28 .theme(theme)
29 .on_link(|destination| println!("Application URL policy received: {destination}"));
30 let root = Surface::window(ScrollView::vertical(view).retain_content_layer())
31 .theme(theme)
32 .padding(Insets::all(24.0))
33 .fill();
34
35 App::new()
36 .window(Window::new("SUI Rich Document").root(root))
37 .run()
38}pub const fn current_offset(&self) -> Vector
pub fn set_offset(&mut self, offset: Vector)
pub fn child(&self) -> &WidgetPod
pub fn child_mut(&mut self) -> &mut WidgetPod
pub fn replace_child<W>(&mut self, child: W)where
W: Widget + 'static,
Trait Implementations§
Source§impl Widget for ScrollView
impl Widget for ScrollView
Source§fn supports_output_reuse(&self) -> bool
fn supports_output_reuse(&self) -> bool
fn event(&mut self, ctx: &mut EventCtx, event: &Event)
fn measure(&mut self, ctx: &mut MeasureCtx, constraints: Constraints) -> Size
fn arrange(&mut self, ctx: &mut ArrangeCtx, bounds: Rect)
fn paint(&self, ctx: &mut PaintCtx)
fn layer_options(&self) -> LayerOptions
fn semantics(&self, ctx: &mut SemanticsCtx)
fn accepts_focus(&self) -> bool
fn focus_changed(&mut self, ctx: &mut EventCtx, focused: bool)
Source§fn visit_children(&self, visitor: &mut dyn WidgetPodVisitor)
fn visit_children(&self, visitor: &mut dyn WidgetPodVisitor)
Source§fn visit_children_mut(&mut self, visitor: &mut dyn WidgetPodMutVisitor)
fn visit_children_mut(&mut self, visitor: &mut dyn WidgetPodMutVisitor)
Source§fn command(&mut self, _ctx: &mut EventCtx, _command: &Command<'_>)
fn command(&mut self, _ctx: &mut EventCtx, _command: &Command<'_>)
fn debug_name(&self) -> &'static str
Source§fn diagnostics(&self, _ctx: &mut WidgetDiagnosticsCtx)
fn diagnostics(&self, _ctx: &mut WidgetDiagnosticsCtx)
Source§fn measure_size(
&mut self,
ctx: &mut MeasureCtx,
constraints: Constraints,
) -> Size
fn measure_size( &mut self, ctx: &mut MeasureCtx, constraints: Constraints, ) -> Size
measure; it may mutate state.
Child measure calls still commit state. Use child size probes explicitly
when only their scalar results are needed.
Results must match measure for the same content and constraints.
A final measure is still required before arrangement after a probe miss.Source§fn measure_axis(
&mut self,
ctx: &mut MeasureCtx,
constraints: Constraints,
axis: Axis,
) -> f32
fn measure_axis( &mut self, ctx: &mut MeasureCtx, constraints: Constraints, axis: Axis, ) -> f32
measure_size under exactly the same constraints.
Overrides may avoid computing the other component, but must return the
same extent. Like size probes, this does not replace final measurement.Source§fn intrinsic_size(
&mut self,
ctx: &mut MeasureCtx,
axis: Axis,
available_cross: f32,
) -> IntrinsicSize
fn intrinsic_size( &mut self, ctx: &mut MeasureCtx, axis: Axis, available_cross: f32, ) -> IntrinsicSize
fn layer_properties(&self) -> LayerProperties
fn stack_host_options(&self) -> Option<StackHostOptions>
fn stack_surface_options(&self) -> Option<StackSurfaceOptions>
Source§fn overlay_options(&self) -> Option<OverlayOptions>
fn overlay_options(&self) -> Option<OverlayOptions>
Auto Trait Implementations§
impl !Freeze for ScrollView
impl !RefUnwindSafe for ScrollView
impl !Send for ScrollView
impl !Sync for ScrollView
impl !UnwindSafe for ScrollView
impl Unpin for ScrollView
impl UnsafeUnpin for ScrollView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.