pub trait RenderSliver: RenderObject {
Show 32 methods
// Required methods
fn render_sliver_data(
self: RenderHandle<Self>,
app: &App,
) -> &RenderSliverData;
fn render_sliver_data_mut(
self: RenderHandle<Self>,
app: &mut App,
) -> &mut RenderSliverData;
// Provided methods
fn constraints(self: RenderHandle<Self>, app: &App) -> SliverConstraints { ... }
fn geometry(self: RenderHandle<Self>, app: &App) -> SliverGeometry { ... }
fn set_geometry(
self: RenderHandle<Self>,
app: &mut App,
geometry: SliverGeometry,
) { ... }
fn paint_bounds(self: RenderHandle<Self>, app: &App) -> Rect { ... }
fn center_offset_adjustment(self: RenderHandle<Self>, _app: &App) -> f64 { ... }
fn hit_test(
self: RenderHandle<Self>,
app: &mut App,
result: &mut SliverHitTestResult<'_>,
main_axis_position: f64,
cross_axis_position: f64,
) -> bool { ... }
fn hit_test_self(
self: RenderHandle<Self>,
_app: &App,
_main_axis_position: f64,
_cross_axis_position: f64,
) -> bool { ... }
fn hit_test_children(
self: RenderHandle<Self>,
_app: &mut App,
_result: &mut SliverHitTestResult<'_>,
_main_axis_position: f64,
_cross_axis_position: f64,
) -> bool { ... }
fn handle_event(
self: RenderHandle<Self>,
_app: &mut App,
_event: &PointerEvent,
_entry: &SliverHitTestEntry,
) { ... }
fn calculate_paint_offset(
self: RenderHandle<Self>,
_app: &App,
constraints: SliverConstraints,
from: f64,
to: f64,
) -> f64 { ... }
fn calculate_cache_offset(
self: RenderHandle<Self>,
_app: &App,
constraints: SliverConstraints,
from: f64,
to: f64,
) -> f64 { ... }
fn child_main_axis_position(
self: RenderHandle<Self>,
_app: &App,
_child: AnyRenderObject,
) -> f64 { ... }
fn child_cross_axis_position(
self: RenderHandle<Self>,
_app: &App,
_child: AnyRenderObject,
) -> f64 { ... }
fn child_scroll_offset(
self: RenderHandle<Self>,
app: &App,
child: AnyRenderObject,
) -> Option<f64> { ... }
fn get_absolute_size_relative_to_origin(
self: RenderHandle<Self>,
app: &App,
) -> Size { ... }
fn get_absolute_size(self: RenderHandle<Self>, app: &App) -> Size { ... }
fn get_max_paint_rect(self: RenderHandle<Self>, app: &App) -> Rect { ... }
fn layout(
self: RenderHandle<Self>,
app: &mut App,
constraints: SliverConstraints,
parent_uses_size: bool,
) { ... }
fn as_sliver(self: RenderHandle<Self>) -> AnyRenderSliver { ... }
fn as_object(self: RenderHandle<Self>) -> AnyRenderObject { ... }
fn adopt_child(
self: RenderHandle<Self>,
app: &mut App,
child: AnyRenderObject,
) { ... }
fn drop_child(
self: RenderHandle<Self>,
app: &mut App,
child: AnyRenderObject,
) { ... }
fn mark_needs_layout(self: RenderHandle<Self>, app: &mut App) { ... }
fn mark_needs_paint(self: RenderHandle<Self>, app: &mut App) { ... }
fn mark_needs_composited_layer_update(
self: RenderHandle<Self>,
app: &mut App,
) { ... }
fn schedule_initial_layout(self: RenderHandle<Self>, app: &mut App) { ... }
fn parent(self: RenderHandle<Self>, app: &App) -> Option<AnyRenderObject> { ... }
fn owner(
self: RenderHandle<Self>,
app: &App,
) -> Option<Handle<PipelineOwner>> { ... }
fn attached(self: RenderHandle<Self>, app: &App) -> bool { ... }
fn debug_needs_layout(self: RenderHandle<Self>, app: &App) -> bool { ... }
}Expand description
A render object using the sliver protocol.
Flutter’s counterpart is RenderSliver. RenderObject::perform_layout is the leaf
override; AnyRenderSliver::layout is the framework wrapper. RenderObject’s tree
operations are provided here and forward to as_object.
Required Methods§
Sourcefn render_sliver_data(self: RenderHandle<Self>, app: &App) -> &RenderSliverData
fn render_sliver_data(self: RenderHandle<Self>, app: &App) -> &RenderSliverData
Mixin field access.
Sourcefn render_sliver_data_mut(
self: RenderHandle<Self>,
app: &mut App,
) -> &mut RenderSliverData
fn render_sliver_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderSliverData
See render_sliver_data.
Provided Methods§
Sourcefn constraints(self: RenderHandle<Self>, app: &App) -> SliverConstraints
fn constraints(self: RenderHandle<Self>, app: &App) -> SliverConstraints
The sliver constraints most recently supplied by the parent.
Sourcefn geometry(self: RenderHandle<Self>, app: &App) -> SliverGeometry
fn geometry(self: RenderHandle<Self>, app: &App) -> SliverGeometry
The amount of space this sliver occupies.
Sourcefn set_geometry(
self: RenderHandle<Self>,
app: &mut App,
geometry: SliverGeometry,
)
fn set_geometry( self: RenderHandle<Self>, app: &mut App, geometry: SliverGeometry, )
Sets the geometry of this sliver. Call from RenderObject::perform_layout.
Sourcefn paint_bounds(self: RenderHandle<Self>, app: &App) -> Rect
fn paint_bounds(self: RenderHandle<Self>, app: &App) -> Rect
An estimate of the bounds within which this render object will paint: the paint extent along the main axis by the cross axis extent.
Sourcefn center_offset_adjustment(self: RenderHandle<Self>, _app: &App) -> f64
fn center_offset_adjustment(self: RenderHandle<Self>, _app: &App) -> f64
For a center sliver, the distance before the absolute zero scroll offset that this sliver can cover.
For example, if an AxisDirection::Down viewport with a
crate::RenderViewport::anchor of 0.5 has a single sliver with a height of 100.0 and
its center_offset_adjustment returns 50.0, then the sliver will be centered in the
viewport when the scroll offset is 0.0.
The distance here is in the opposite direction of the viewport’s axis direction, so values will typically be positive.
Sourcefn hit_test(
self: RenderHandle<Self>,
app: &mut App,
result: &mut SliverHitTestResult<'_>,
main_axis_position: f64,
cross_axis_position: f64,
) -> bool
fn hit_test( self: RenderHandle<Self>, app: &mut App, result: &mut SliverHitTestResult<'_>, main_axis_position: f64, cross_axis_position: f64, ) -> bool
Determines the set of render objects located at the given position.
Returns true if the given point is contained in this render object or one of its descendants. Adds any render objects that contain the point to the given hit test result.
The caller is responsible for providing the position in the local coordinate space of the callee. The callee is responsible for checking whether the given position is within its bounds.
§Coordinates for RenderSliver objects
The main_axis_position is the distance in the AxisDirection (after applying the
GrowthDirection) from the edge of the sliver’s painted area. This can be an unusual
direction, for example in the AxisDirection::Up case this is a distance from the
bottom of the sliver’s painted area.
The cross_axis_position is the distance in the other axis. If the cross axis is
horizontal (i.e. the SliverConstraints::axis_direction is either
AxisDirection::Down or AxisDirection::Up), then the cross_axis_position is a
distance from the left edge of the sliver. Otherwise it is a distance from the top edge.
§Implementing hit testing for slivers
The most straight-forward way to implement hit testing for a new sliver render object is
to override its hit_test_self and
hit_test_children methods.
Sourcefn hit_test_self(
self: RenderHandle<Self>,
_app: &App,
_main_axis_position: f64,
_cross_axis_position: f64,
) -> bool
fn hit_test_self( self: RenderHandle<Self>, _app: &App, _main_axis_position: f64, _cross_axis_position: f64, ) -> bool
Override this method if this render object can be hit even if its children were not hit.
Used by hit_test. If you override hit_test and do not call this
function, then you don’t need to implement this function.
Sourcefn hit_test_children(
self: RenderHandle<Self>,
_app: &mut App,
_result: &mut SliverHitTestResult<'_>,
_main_axis_position: f64,
_cross_axis_position: f64,
) -> bool
fn hit_test_children( self: RenderHandle<Self>, _app: &mut App, _result: &mut SliverHitTestResult<'_>, _main_axis_position: f64, _cross_axis_position: f64, ) -> bool
Override this method to check whether any children are located at the given position.
Typically children should be hit-tested in reverse paint order so that hit tests at locations where children overlap hit the child that is visually “on top” (i.e., paints later).
Used by hit_test. If you override hit_test and do not call this
function, then you don’t need to implement this function.
Sourcefn handle_event(
self: RenderHandle<Self>,
_app: &mut App,
_event: &PointerEvent,
_entry: &SliverHitTestEntry,
)
fn handle_event( self: RenderHandle<Self>, _app: &mut App, _event: &PointerEvent, _entry: &SliverHitTestEntry, )
Override to handle pointer events that hit this render object.
Sourcefn calculate_paint_offset(
self: RenderHandle<Self>,
_app: &App,
constraints: SliverConstraints,
from: f64,
to: f64,
) -> f64
fn calculate_paint_offset( self: RenderHandle<Self>, _app: &App, constraints: SliverConstraints, from: f64, to: f64, ) -> f64
Computes the portion of the region from from to to that is visible, assuming that
only the region from the SliverConstraints::scroll_offset that is
SliverConstraints::remaining_paint_extent high is visible, and that the relationship
between scroll offsets and paint offsets is linear.
For example, if the constraints have a scroll offset of 100 and a remaining paint extent of 100, and the arguments to this method describe the region 50..150, then the returned value would be 50 (from scroll offset 100 to scroll offset 150).
This method is not useful if there is not a 1:1 relationship between consumed scroll offset and consumed paint extent.
Sourcefn calculate_cache_offset(
self: RenderHandle<Self>,
_app: &App,
constraints: SliverConstraints,
from: f64,
to: f64,
) -> f64
fn calculate_cache_offset( self: RenderHandle<Self>, _app: &App, constraints: SliverConstraints, from: f64, to: f64, ) -> f64
Computes the portion of the region from from to to that is within the cache extent
of the viewport, assuming that only the region from the
SliverConstraints::cache_origin that is
SliverConstraints::remaining_cache_extent high is visible, and that the relationship
between scroll offsets and paint offsets is linear.
This method is not useful if there is not a 1:1 relationship between consumed scroll offset and consumed cache extent.
Sourcefn child_main_axis_position(
self: RenderHandle<Self>,
_app: &App,
_child: AnyRenderObject,
) -> f64
fn child_main_axis_position( self: RenderHandle<Self>, _app: &App, _child: AnyRenderObject, ) -> f64
Returns the distance from the leading visible edge of the sliver to the side of the given child closest to that edge.
For example, if the constraints describe this sliver as having an
axis direction of AxisDirection::Down, then this is the distance from the top of the
visible portion of the sliver to the top of the child. On the other hand, if the axis
direction is AxisDirection::Up, then this is the distance from the bottom of the
visible portion of the sliver to the bottom of the child. In both cases, this is the
direction of increasing SliverConstraints::scroll_offset and
SliverLogicalParentData::layout_offset.
For children that are slivers, the leading edge of the child will be the leading visible edge of the child, not the part of the child that would locally be at scroll offset 0.0. For box children it is the actual distance to the edge of the box, since those boxes do not know how to handle being scrolled.
This method differs from child_scroll_offset in that it
gives the distance from the leading visible edge of the sliver whereas
child_scroll_offset gives the distance from the sliver’s zero scroll offset.
Calling this for a child that is not visible is not valid.
Sourcefn child_cross_axis_position(
self: RenderHandle<Self>,
_app: &App,
_child: AnyRenderObject,
) -> f64
fn child_cross_axis_position( self: RenderHandle<Self>, _app: &App, _child: AnyRenderObject, ) -> f64
Returns the distance along the cross axis from the zero of the cross axis in this sliver’s paint coordinate space to the nearest side of the given child.
For example, if the constraints describe this sliver as having an
axis direction of AxisDirection::Down or AxisDirection::Up, then this is the
distance from the left of the sliver to the left of the child. If the axis direction is
AxisDirection::Left or AxisDirection::Right, then it is the distance from the
top of the sliver to the top of the child.
Calling this for a child that is not visible is not valid.
Sourcefn child_scroll_offset(
self: RenderHandle<Self>,
app: &App,
child: AnyRenderObject,
) -> Option<f64>
fn child_scroll_offset( self: RenderHandle<Self>, app: &App, child: AnyRenderObject, ) -> Option<f64>
Returns the scroll offset for the leading edge of the given child.
The child must be a child of this sliver.
If there are pinned slivers before child, the offset should be reduced by the extent
of the pinned children.
This method differs from child_main_axis_position in
that child_main_axis_position gives the distance from the leading visible edge of
the sliver whereas this gives the distance from the sliver’s zero scroll offset.
Sourcefn get_absolute_size_relative_to_origin(
self: RenderHandle<Self>,
app: &App,
) -> Size
fn get_absolute_size_relative_to_origin( self: RenderHandle<Self>, app: &App, ) -> Size
This returns a Size with dimensions relative to the leading edge of the sliver,
specifically the same offset that is given to the RenderObject::paint method. This
means that the dimensions may be negative.
This is only valid after layout has completed.
See also:
get_absolute_size, which returns absolute size.
Sourcefn get_absolute_size(self: RenderHandle<Self>, app: &App) -> Size
fn get_absolute_size(self: RenderHandle<Self>, app: &App) -> Size
This returns the absolute Size of the sliver.
The dimensions are always positive and calling this is only valid after layout has completed.
See also:
get_absolute_size_relative_to_origin, which returns the size relative to the leading edge of the sliver.
Sourcefn get_max_paint_rect(self: RenderHandle<Self>, app: &App) -> Rect
fn get_max_paint_rect(self: RenderHandle<Self>, app: &App) -> Rect
Returns the Rect that covers the total paint extent of the sliver.
The rect is expressed in the sliver’s local coordinate system, which is axis-aligned
with the painting context’s canvas. The coordinate system’s origin (0,0) corresponds to
the offset argument passed to RenderObject::paint.
Sourcefn layout(
self: RenderHandle<Self>,
app: &mut App,
constraints: SliverConstraints,
parent_uses_size: bool,
)
fn layout( self: RenderHandle<Self>, app: &mut App, constraints: SliverConstraints, parent_uses_size: bool, )
Sourcefn as_sliver(self: RenderHandle<Self>) -> AnyRenderSliver
fn as_sliver(self: RenderHandle<Self>) -> AnyRenderSliver
The type-erased RenderSliver handle. Free: the vtable is a const, and the id is copied.
Sourcefn as_object(self: RenderHandle<Self>) -> AnyRenderObject
fn as_object(self: RenderHandle<Self>) -> AnyRenderObject
The type-erased RenderObject handle, through as_sliver.
Sourcefn adopt_child(self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject)
fn adopt_child(self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject)
Sourcefn drop_child(self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject)
fn drop_child(self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject)
Sourcefn mark_needs_layout(self: RenderHandle<Self>, app: &mut App)
fn mark_needs_layout(self: RenderHandle<Self>, app: &mut App)
Sourcefn mark_needs_paint(self: RenderHandle<Self>, app: &mut App)
fn mark_needs_paint(self: RenderHandle<Self>, app: &mut App)
Sourcefn mark_needs_composited_layer_update(self: RenderHandle<Self>, app: &mut App)
fn mark_needs_composited_layer_update(self: RenderHandle<Self>, app: &mut App)
Sourcefn schedule_initial_layout(self: RenderHandle<Self>, app: &mut App)
fn schedule_initial_layout(self: RenderHandle<Self>, app: &mut App)
Sourcefn parent(self: RenderHandle<Self>, app: &App) -> Option<AnyRenderObject>
fn parent(self: RenderHandle<Self>, app: &App) -> Option<AnyRenderObject>
Sourcefn owner(self: RenderHandle<Self>, app: &App) -> Option<Handle<PipelineOwner>>
fn owner(self: RenderHandle<Self>, app: &App) -> Option<Handle<PipelineOwner>>
Sourcefn attached(self: RenderHandle<Self>, app: &App) -> bool
fn attached(self: RenderHandle<Self>, app: &App) -> bool
Sourcefn debug_needs_layout(self: RenderHandle<Self>, app: &App) -> bool
fn debug_needs_layout(self: RenderHandle<Self>, app: &App) -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".