Skip to main content

RenderViewportBase

Trait RenderViewportBase 

Source
pub trait RenderViewportBase:
    RenderBox
    + RenderAbstractViewport
    + ContainerRenderObjectMixin<ChildType = AnyRenderSliver> {
Show 47 methods // Required methods fn viewport_data( self: RenderHandle<Self>, app: &App, ) -> &RenderViewportBaseData; fn viewport_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderViewportBaseData; fn has_visual_overflow(self: RenderHandle<Self>, app: &App) -> bool; fn update_out_of_band_data( self: RenderHandle<Self>, app: &mut App, growth_direction: GrowthDirection, child_layout_geometry: SliverGeometry, ); fn update_child_layout_offset( self: RenderHandle<Self>, app: &mut App, child: AnyRenderSliver, layout_offset: f64, growth_direction: GrowthDirection, ); fn paint_offset_of( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, ) -> Offset; fn scroll_offset_of( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, scroll_offset_within_child: f64, ) -> f64; fn max_scroll_obstruction_extent_before( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, ) -> f64; fn compute_child_main_axis_position( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, parent_main_axis_position: f64, ) -> f64; fn index_of_first_child(self: RenderHandle<Self>, app: &App) -> i32; fn label_for_child(self: RenderHandle<Self>, index: i32) -> String; // Provided methods fn axis_direction(self: RenderHandle<Self>, app: &App) -> AxisDirection { ... } fn set_axis_direction( self: RenderHandle<Self>, app: &mut App, value: AxisDirection, ) { ... } fn cross_axis_direction( self: RenderHandle<Self>, app: &App, ) -> AxisDirection { ... } fn set_cross_axis_direction( self: RenderHandle<Self>, app: &mut App, value: AxisDirection, ) { ... } fn axis(self: RenderHandle<Self>, app: &App) -> Axis { ... } fn offset(self: RenderHandle<Self>, app: &App) -> AnyViewportOffset { ... } fn set_offset( self: RenderHandle<Self>, app: &mut App, value: AnyViewportOffset, ) { ... } fn mark_needs_layout_listener(self: RenderHandle<Self>) -> Listener { ... } fn scroll_cache_extent( self: RenderHandle<Self>, app: &App, ) -> ScrollCacheExtent { ... } fn set_scroll_cache_extent( self: RenderHandle<Self>, app: &mut App, value: Option<ScrollCacheExtent>, ) { ... } fn cache_extent(self: RenderHandle<Self>, app: &App) -> f64 { ... } fn set_cache_extent( self: RenderHandle<Self>, app: &mut App, value: Option<f64>, ) { ... } fn cache_extent_style( self: RenderHandle<Self>, app: &App, ) -> CacheExtentStyle { ... } fn set_cache_extent_style( self: RenderHandle<Self>, app: &mut App, value: CacheExtentStyle, ) { ... } fn paint_order(self: RenderHandle<Self>, app: &App) -> SliverPaintOrder { ... } fn set_paint_order( self: RenderHandle<Self>, app: &mut App, value: SliverPaintOrder, ) { ... } fn clip_behavior(self: RenderHandle<Self>, app: &App) -> Clip { ... } fn set_clip_behavior(self: RenderHandle<Self>, app: &mut App, value: Clip) { ... } fn did_attach( self: RenderHandle<Self>, app: &mut App, owner: Handle<PipelineOwner>, ) { ... } fn did_detach(self: RenderHandle<Self>, app: &mut App) { ... } fn debug_throw_if_not_checking_intrinsics(self: RenderHandle<Self>) -> bool { ... } fn compute_min_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64 { ... } fn compute_max_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64 { ... } fn compute_min_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64 { ... } fn compute_max_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64 { ... } fn layout_child_sequence( self: RenderHandle<Self>, app: &mut App, child: Option<AnyRenderSliver>, scroll_offset: f64, overlap: f64, layout_offset: f64, remaining_paint_extent: f64, main_axis_extent: f64, cross_axis_extent: f64, growth_direction: GrowthDirection, advance: &SliverAdvance<Self>, remaining_cache_extent: f64, cache_origin: f64, ) -> f64 { ... } fn paint( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, ) { ... } fn dispose(self: RenderHandle<Self>, app: &mut App) { ... } fn paint_contents( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, ) { ... } fn hit_test_children( self: RenderHandle<Self>, app: &mut App, result: &mut BoxHitTestResult<'_>, position: Offset, ) -> bool { ... } fn get_offset_to_reveal( self: RenderHandle<Self>, app: &App, target: AnyRenderObject, alignment: f64, rect: Option<Rect>, _axis: Option<Axis>, ) -> RevealedOffset { ... } fn compute_absolute_paint_offset( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, layout_offset: f64, growth_direction: GrowthDirection, ) -> Offset { ... } fn children_in_paint_order( self: RenderHandle<Self>, app: &App, ) -> Vec<AnyRenderSliver> { ... } fn children_in_hit_test_order( self: RenderHandle<Self>, app: &App, ) -> Vec<AnyRenderSliver> { ... } fn children_last_to_first( self: RenderHandle<Self>, app: &App, ) -> Vec<AnyRenderSliver> { ... } fn show_on_screen( self: RenderHandle<Self>, app: &mut App, descendant: Option<AnyRenderObject>, rect: Option<Rect>, duration: Duration, curve: Rc<dyn Curve>, ) { ... }
}
Expand description

A base class for render objects that are bigger on the inside.

This render object provides the shared code for render objects that host AnyRenderSliver render objects inside a RenderBox. The viewport establishes an axis_direction, which orients the sliver’s coordinate system, which is based on scroll offsets rather than Cartesian coordinates.

The viewport also listens to an offset, which determines the SliverConstraints::scroll_offset input to the sliver layout protocol.

Implementors typically override RenderObject::perform_layout and call layout_child_sequence, perhaps multiple times.

Flutter’s RenderViewportBase; the state lives in a RenderViewportBaseData field.

Required Methods§

Source

fn viewport_data(self: RenderHandle<Self>, app: &App) -> &RenderViewportBaseData

Mixin field access.

Source

fn viewport_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderViewportBaseData

Source

fn has_visual_overflow(self: RenderHandle<Self>, app: &App) -> bool

Whether the contents of this viewport would paint outside the bounds of the viewport if paint did not clip.

This property enables an optimization whereby paint can skip applying a clip if the contents of the viewport are known to paint entirely within its bounds.

Source

fn update_out_of_band_data( self: RenderHandle<Self>, app: &mut App, growth_direction: GrowthDirection, child_layout_geometry: SliverGeometry, )

Called during layout_child_sequence for each child.

Typically used by implementors to update any out-of-band data, such as the max scroll extent, for each child.

Source

fn update_child_layout_offset( self: RenderHandle<Self>, app: &mut App, child: AnyRenderSliver, layout_offset: f64, growth_direction: GrowthDirection, )

Called during layout_child_sequence to store the layout offset for the given child.

Different implementors use different representations for their children’s layout offset (e.g., logical or physical coordinates). This function lets them transform the child’s layout offset before storing it in the child’s parent data.

Source

fn paint_offset_of( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, ) -> Offset

The offset at which the given child should be painted.

The returned offset is from the top left corner of the inside of the viewport to the top left corner of the paint coordinate system of the child.

See also:

  • compute_absolute_paint_offset, which computes the paint offset from an explicit layout offset and growth direction instead of using the values computed for the child during layout.
Source

fn scroll_offset_of( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, scroll_offset_within_child: f64, ) -> f64

Returns the scroll offset within the viewport for the given scroll_offset_within_child within the given child.

The returned value is an estimate that assumes the slivers within the viewport do not change the layout extent in response to changes in their scroll offset.

Source

fn max_scroll_obstruction_extent_before( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, ) -> f64

Returns the total scroll obstruction extent of all slivers in the viewport before child.

This is the extent by which the actual area in which content can scroll is reduced. For example, an app bar that is pinned at the top will reduce the area in which content can actually scroll by the height of the app bar.

Source

fn compute_child_main_axis_position( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, parent_main_axis_position: f64, ) -> f64

Converts the parent_main_axis_position into the child’s coordinate system.

The parent_main_axis_position is a distance from the top edge (for vertical viewports) or left edge (for horizontal viewports) of the viewport bounds. This describes a line, perpendicular to the viewport’s main axis, heretofore known as the target line.

The child’s coordinate system’s origin in the main axis is at the leading edge of the given child, as given by the child’s SliverConstraints::axis_direction and SliverConstraints::growth_direction.

This method returns the distance from the leading edge of the given child to the target line described above.

Source

fn index_of_first_child(self: RenderHandle<Self>, app: &App) -> i32

The index of the first child of the viewport relative to the center child.

For example, the center child has index zero and the first child in the reverse growth direction has index -1.

Source

fn label_for_child(self: RenderHandle<Self>, index: i32) -> String

A short string to identify the child with the given index.

Provided Methods§

Source

fn axis_direction(self: RenderHandle<Self>, app: &App) -> AxisDirection

The direction in which the SliverConstraints::scroll_offset increases.

For example, if the axis direction is AxisDirection::Down, a scroll offset of zero is at the top of the viewport and increases towards the bottom of the viewport.

Source

fn set_axis_direction( self: RenderHandle<Self>, app: &mut App, value: AxisDirection, )

Source

fn cross_axis_direction(self: RenderHandle<Self>, app: &App) -> AxisDirection

The direction in which child should be laid out in the cross axis.

For example, if the axis_direction is AxisDirection::Down, this property is typically AxisDirection::Left if the ambient text direction is right-to-left and AxisDirection::Right if it is left-to-right.

Source

fn set_cross_axis_direction( self: RenderHandle<Self>, app: &mut App, value: AxisDirection, )

Source

fn axis(self: RenderHandle<Self>, app: &App) -> Axis

The axis along which the viewport scrolls.

For example, if the axis_direction is AxisDirection::Down, then the axis is Axis::Vertical and the viewport scrolls vertically.

Source

fn offset(self: RenderHandle<Self>, app: &App) -> AnyViewportOffset

Which part of the content inside the viewport should be visible.

The crate::ViewportOffset::pixels value determines the scroll offset that the viewport uses to select which part of its content to display. As the user scrolls the viewport, this value changes, which changes the content that is displayed.

Source

fn set_offset(self: RenderHandle<Self>, app: &mut App, value: AnyViewportOffset)

Sets offset.

Source

fn mark_needs_layout_listener(self: RenderHandle<Self>) -> Listener

Dart’s _offset.addListener(markNeedsLayout) tear-off.

Source

fn scroll_cache_extent(self: RenderHandle<Self>, app: &App) -> ScrollCacheExtent

The viewport has an area before and after the visible area to cache items that are about to become visible when the user scrolls.

Items that fall in this cache area are laid out even though they are not (yet) visible on screen. The scroll cache extent describes how much the cache area extends before the leading edge and after the trailing edge of the viewport.

The total extent, which the viewport will try to cover with children, is the scroll cache extent before the leading edge + extent of the main axis + the scroll cache extent after the trailing edge.

Source

fn set_scroll_cache_extent( self: RenderHandle<Self>, app: &mut App, value: Option<ScrollCacheExtent>, )

Source

fn cache_extent(self: RenderHandle<Self>, app: &App) -> f64

👎Deprecated:

Use scroll_cache_extent instead.

Deprecated. Use scroll_cache_extent instead.

Source

fn set_cache_extent(self: RenderHandle<Self>, app: &mut App, value: Option<f64>)

👎Deprecated:

Use set_scroll_cache_extent instead.

Deprecated. Use set_scroll_cache_extent instead.

None resets the value to AnyRenderAbstractViewport::DEFAULT_CACHE_EXTENT pixels, in which case the style becomes CacheExtentStyle::Pixel.

Source

fn cache_extent_style(self: RenderHandle<Self>, app: &App) -> CacheExtentStyle

👎Deprecated:

Use scroll_cache_extent instead.

Deprecated. Use scroll_cache_extent instead.

Source

fn set_cache_extent_style( self: RenderHandle<Self>, app: &mut App, value: CacheExtentStyle, )

👎Deprecated:

Use set_scroll_cache_extent instead.

Deprecated. Use set_scroll_cache_extent instead.

Source

fn paint_order(self: RenderHandle<Self>, app: &App) -> SliverPaintOrder

The order in which to paint the slivers; equivalently, the order in which to arrange them in the z-direction.

Whichever order the slivers are painted in, they will be hit-tested in the opposite order.

The default is SliverPaintOrder::FirstIsTop.

Source

fn set_paint_order( self: RenderHandle<Self>, app: &mut App, value: SliverPaintOrder, )

Source

fn clip_behavior(self: RenderHandle<Self>, app: &App) -> Clip

The content will be clipped (or not) according to this option.

Defaults to Clip::HardEdge.

Source

fn set_clip_behavior(self: RenderHandle<Self>, app: &mut App, value: Clip)

Source

fn did_attach( self: RenderHandle<Self>, app: &mut App, owner: Handle<PipelineOwner>, )

The body of Flutter’s attach override: listens to the offset.

Source

fn did_detach(self: RenderHandle<Self>, app: &mut App)

The body of Flutter’s detach override: stops listening to the offset.

Source

fn debug_throw_if_not_checking_intrinsics(self: RenderHandle<Self>) -> bool

Panics saying that the object does not support returning intrinsic dimensions if, in debug mode, we are not in the debug_checking_intrinsics mode.

This is used by compute_min_intrinsic_width et al because viewports do not generally support returning intrinsic dimensions. See the discussion at RenderBox::compute_min_intrinsic_width.

Source

fn compute_min_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64

Zero; a viewport has no intrinsic dimensions.

Source

fn compute_max_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64

Zero; a viewport has no intrinsic dimensions.

Source

fn compute_min_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64

Zero; a viewport has no intrinsic dimensions.

Source

fn compute_max_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64

Zero; a viewport has no intrinsic dimensions.

Source

fn layout_child_sequence( self: RenderHandle<Self>, app: &mut App, child: Option<AnyRenderSliver>, scroll_offset: f64, overlap: f64, layout_offset: f64, remaining_paint_extent: f64, main_axis_extent: f64, cross_axis_extent: f64, growth_direction: GrowthDirection, advance: &SliverAdvance<Self>, remaining_cache_extent: f64, cache_origin: f64, ) -> f64

Determines the size and position of some of the children of the viewport.

This function is the workhorse of perform_layout implementations in implementors.

Layout starts with child, proceeds according to the advance callback, and stops once advance returns None.

Returns the first non-zero SliverGeometry::scroll_offset_correction encountered, if any. Otherwise returns 0.0. Typical callers will call this function repeatedly until it returns 0.0.

Source

fn paint( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, )

The body of Flutter’s paint override.

Source

fn dispose(self: RenderHandle<Self>, app: &mut App)

Flutter’s dispose: drop the clip layer handle, then super.dispose().

Source

fn paint_contents( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, )

Flutter’s _paintContents.

Source

fn hit_test_children( self: RenderHandle<Self>, app: &mut App, result: &mut BoxHitTestResult<'_>, position: Offset, ) -> bool

The body of Flutter’s hitTestChildren override.

Source

fn get_offset_to_reveal( self: RenderHandle<Self>, app: &App, target: AnyRenderObject, alignment: f64, rect: Option<Rect>, _axis: Option<Axis>, ) -> RevealedOffset

The body of Flutter’s getOffsetToReveal override.

Source

fn compute_absolute_paint_offset( self: RenderHandle<Self>, app: &App, child: AnyRenderSliver, layout_offset: f64, growth_direction: GrowthDirection, ) -> Offset

The offset at which the given child should be painted.

The returned offset is from the top left corner of the inside of the viewport to the top left corner of the paint coordinate system of the child.

See also:

  • paint_offset_of, which uses the layout offset and growth direction computed for the child during layout.
Source

fn children_in_paint_order( self: RenderHandle<Self>, app: &App, ) -> Vec<AnyRenderSliver>

Walks the children of the viewport, in the order that they should be painted.

This is the reverse order of children_in_hit_test_order.

Source

fn children_in_hit_test_order( self: RenderHandle<Self>, app: &App, ) -> Vec<AnyRenderSliver>

Walks the children of the viewport, in the order that hit-testing should use.

This is the reverse order of children_in_paint_order.

Source

fn children_last_to_first( self: RenderHandle<Self>, app: &App, ) -> Vec<AnyRenderSliver>

Flutter’s _childrenLastToFirst.

Source

fn show_on_screen( self: RenderHandle<Self>, app: &mut App, descendant: Option<AnyRenderObject>, rect: Option<Rect>, duration: Duration, curve: Rc<dyn Curve>, )

The body of Flutter’s showOnScreen override.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§