pub trait RenderObject: 'static + Sized {
Show 20 methods
// Required methods
fn render_object_data(
self: RenderHandle<Self>,
app: &App,
) -> &RenderObjectData;
fn render_object_data_mut(
self: RenderHandle<Self>,
app: &mut App,
) -> &mut RenderObjectData;
fn perform_layout(self: RenderHandle<Self>, app: &mut App);
// Provided methods
fn as_render_object(self: RenderHandle<Self>, app: &App) -> AnyRenderObject { ... }
fn perform_resize(self: RenderHandle<Self>, _app: &mut App) { ... }
fn visit_children(
self: RenderHandle<Self>,
app: &App,
visitor: &mut dyn FnMut(AnyRenderObject),
) { ... }
fn setup_parent_data(
self: RenderHandle<Self>,
app: &mut App,
child: AnyRenderObject,
) { ... }
fn did_attach(
self: RenderHandle<Self>,
app: &mut App,
owner: Handle<PipelineOwner>,
) { ... }
fn did_detach(self: RenderHandle<Self>, app: &mut App) { ... }
fn redepth_children(self: RenderHandle<Self>, app: &mut App) { ... }
fn sized_by_parent(self: RenderHandle<Self>, _app: &App) -> bool { ... }
fn apply_paint_transform(
self: RenderHandle<Self>,
app: &App,
child: AnyRenderObject,
transform: &mut Matrix4,
) { ... }
fn is_repaint_boundary(self: RenderHandle<Self>, _app: &App) -> bool { ... }
fn always_needs_compositing(self: RenderHandle<Self>, _app: &App) -> bool { ... }
fn mouse_tracker_annotation(
self: RenderHandle<Self>,
_app: &App,
) -> Option<MouseTrackerAnnotation> { ... }
fn update_composited_layer(
self: RenderHandle<Self>,
app: &mut App,
old_layer: Option<AnyOffsetLayer>,
) -> AnyOffsetLayer { ... }
fn show_on_screen(
self: RenderHandle<Self>,
app: &mut App,
descendant: Option<AnyRenderObject>,
rect: Option<Rect>,
duration: Duration,
curve: Rc<dyn Curve>,
) { ... }
fn interface(self: RenderHandle<Self>, id: TypeId) -> Option<Box<dyn Any>> { ... }
fn dispose(self: RenderHandle<Self>, app: &mut App) { ... }
fn paint(
self: RenderHandle<Self>,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
) { ... }
}Expand description
Class-specific render object: the data accessors and the virtuals, nothing else. Methods
take RenderHandle<Self> so they can re-enter the same slot through App.
Tree operations (mark_needs_layout, adopt_child, parent, …) live on the erased
AnyRenderObject; a typed handle reaches them through its protocol trait,
crate::RenderBox or crate::RenderSliver.
Required Methods§
Sourcefn render_object_data(self: RenderHandle<Self>, app: &App) -> &RenderObjectData
fn render_object_data(self: RenderHandle<Self>, app: &App) -> &RenderObjectData
Mixin field access.
Sourcefn render_object_data_mut(
self: RenderHandle<Self>,
app: &mut App,
) -> &mut RenderObjectData
fn render_object_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderObjectData
See render_object_data.
Sourcefn perform_layout(self: RenderHandle<Self>, app: &mut App)
fn perform_layout(self: RenderHandle<Self>, app: &mut App)
Do the work of computing the layout for this render object.
Do not call this function directly: call layout on the protocol handle instead.
Read the constraints with constraints on the protocol trait.
Provided Methods§
Sourcefn as_render_object(self: RenderHandle<Self>, app: &App) -> AnyRenderObject
fn as_render_object(self: RenderHandle<Self>, app: &App) -> AnyRenderObject
Dart’s implicit upcast of a concrete render object to RenderObject: this object’s
type-erased handle, through the vtable the protocol recorded when it created it.
Sourcefn perform_resize(self: RenderHandle<Self>, _app: &mut App)
fn perform_resize(self: RenderHandle<Self>, _app: &mut App)
Updates the render object’s size using only the constraints.
Called by layout only when sized_by_parent is true.
A box overrides crate::RenderBox::compute_dry_layout instead: the box protocol’s
crate::RenderBox::perform_resize sizes itself from it.
Sourcefn visit_children(
self: RenderHandle<Self>,
app: &App,
visitor: &mut dyn FnMut(AnyRenderObject),
)
fn visit_children( self: RenderHandle<Self>, app: &App, visitor: &mut dyn FnMut(AnyRenderObject), )
Calls visitor for each immediate child.
Sourcefn setup_parent_data(
self: RenderHandle<Self>,
app: &mut App,
child: AnyRenderObject,
)
fn setup_parent_data( self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject, )
Sets up parent data for child if it has none.
For a box, override crate::RenderBox::setup_parent_data instead; an implementation
here is not called for boxes.
Sourcefn did_attach(
self: RenderHandle<Self>,
app: &mut App,
owner: Handle<PipelineOwner>,
)
fn did_attach( self: RenderHandle<Self>, app: &mut App, owner: Handle<PipelineOwner>, )
The body of Flutter’s attach override after super.attach(owner); the base body has
already run. The default attaches the children reported by
visit_children.
Sourcefn did_detach(self: RenderHandle<Self>, app: &mut App)
fn did_detach(self: RenderHandle<Self>, app: &mut App)
The body of Flutter’s detach override after super.detach(). The default detaches
the children reported by visit_children.
Sourcefn redepth_children(self: RenderHandle<Self>, app: &mut App)
fn redepth_children(self: RenderHandle<Self>, app: &mut App)
Adjusts the depth of each child reported by visit_children.
Sourcefn sized_by_parent(self: RenderHandle<Self>, _app: &App) -> bool
fn sized_by_parent(self: RenderHandle<Self>, _app: &App) -> bool
Whether the constraints are the only input to the sizing algorithm.
Sourcefn apply_paint_transform(
self: RenderHandle<Self>,
app: &App,
child: AnyRenderObject,
transform: &mut Matrix4,
)
fn apply_paint_transform( self: RenderHandle<Self>, app: &App, child: AnyRenderObject, transform: &mut Matrix4, )
Applies the transform that would be applied when painting the given child to the given matrix.
Used by coordinate conversion functions (AnyRenderObject::get_transform_to) to
translate coordinates local to one render object into coordinates local to another
render object.
Some RenderObjects will provide a zeroed out matrix in this method, indicating that
the child should not paint anything or respond to hit tests currently. A parent may
supply a non-zero matrix even if it does not paint its child currently, for example
if the parent is a RenderOffstage with offstage set to true. In both of these
cases, the parent must return false from paintsChild.
The box protocol’s default translates by the child’s BoxParentData offset; this
object-level default only asserts, as Dart’s RenderObject.applyPaintTransform.
Sourcefn is_repaint_boundary(self: RenderHandle<Self>, _app: &App) -> bool
fn is_repaint_boundary(self: RenderHandle<Self>, _app: &App) -> bool
Whether this render object repaints separately from its parent.
Override this in subclasses to indicate that instances of your class ought to repaint independently. For example, render objects that repaint frequently might want to repaint themselves without requiring their parent to repaint.
If this getter returns true, the paint_bounds are applied to this
object and all descendants. The framework invokes
update_composited_layer to create an OffsetLayer
and assigns it to the layer field.
Render objects that declare themselves as repaint boundaries must not replace
the layer created by the framework.
If the value of this getter changes, AnyRenderObject::mark_needs_compositing_bits_update
must be called.
Sourcefn always_needs_compositing(self: RenderHandle<Self>, _app: &App) -> bool
fn always_needs_compositing(self: RenderHandle<Self>, _app: &App) -> bool
Whether this render object always needs compositing.
Override this in subclasses to indicate that your paint function always creates at least one composited layer. For example, videos should return true if they use hardware decoders.
You must call AnyRenderObject::mark_needs_compositing_bits_update if the value of this
getter changes. (This is implied when AnyRenderObject::adopt_child or
AnyRenderObject::drop_child are called.)
Sourcefn mouse_tracker_annotation(
self: RenderHandle<Self>,
_app: &App,
) -> Option<MouseTrackerAnnotation>
fn mouse_tracker_annotation( self: RenderHandle<Self>, _app: &App, ) -> Option<MouseTrackerAnnotation>
Dart’s this is MouseTrackerAnnotation: the annotation this render object implements,
read live each time the mouse tracker consults it. None for a render object that is
not an annotation, which is the default.
Sourcefn update_composited_layer(
self: RenderHandle<Self>,
app: &mut App,
old_layer: Option<AnyOffsetLayer>,
) -> AnyOffsetLayer
fn update_composited_layer( self: RenderHandle<Self>, app: &mut App, old_layer: Option<AnyOffsetLayer>, ) -> AnyOffsetLayer
Update the composited layer owned by this render object.
This method is called by the framework when is_repaint_boundary
is true.
If old_layer is None, this method must return a new OffsetLayer
(or subtype thereof). If old_layer is not None, then this method must
reuse the layer instance that is provided — it is an error to create a new
layer in this instance. The layer will be disposed by the framework when
either the render object is disposed or if it is no longer a repaint
boundary.
The OffsetLayerMixin::offset property will be managed
by the framework and must not be updated by this method.
If a property of the composited layer needs to be updated, the render object
must call AnyRenderObject::mark_needs_composited_layer_update which will schedule this
method to be called without repainting children. If this widget was marked as
needing to paint and needing a composited layer update, this method is only
called once.
Sourcefn show_on_screen(
self: RenderHandle<Self>,
app: &mut App,
descendant: Option<AnyRenderObject>,
rect: Option<Rect>,
duration: Duration,
curve: Rc<dyn Curve>,
)
fn show_on_screen( self: RenderHandle<Self>, app: &mut App, descendant: Option<AnyRenderObject>, rect: Option<Rect>, duration: Duration, curve: Rc<dyn Curve>, )
Attempt to make (a portion of) this or a descendant RenderObject visible on screen.
If descendant is provided, that render object is made visible. If descendant is
omitted, this render object is made visible.
The optional rect parameter describes which area of that render object should be
shown on screen. If rect is None, the entire render object (as defined by its
paint bounds) will be revealed. The rect parameter is interpreted relative to the
coordinate system of descendant if that argument is provided and relative to this
render object otherwise.
The duration parameter can be set to a non-zero value to bring the target object on
screen in an animation defined by curve.
See also:
crate::show_in_viewport, whichRenderViewportBasedelegates this method to.
Sourcefn interface(self: RenderHandle<Self>, id: TypeId) -> Option<Box<dyn Any>>
fn interface(self: RenderHandle<Self>, id: TypeId) -> Option<Box<dyn Any>>
Dart’s object is RenderAbstractViewport for any interface: the erased handle of the
interface id names, if this type implements it.
An implementor answers each interface it implements with that interface’s type-erased
handle, boxed; AnyRenderObject::interface unboxes it. The default implements none.
Sourcefn dispose(self: RenderHandle<Self>, app: &mut App)
fn dispose(self: RenderHandle<Self>, app: &mut App)
Release any resources held by this render object.
The object that creates a RenderObject is in charge of disposing it. If this render
object has created any children directly, it must dispose of those children in this method
as well. It must not dispose of any children that were created by some other object, such
as a RenderObjectElement. Those children will be disposed when that element unmounts,
which may be delayed if the element is moved to another part of the tree.
Implementations of this method must end with a call to the inherited method,
RenderObjectBase::dispose(self, app), as in Dart’s super.dispose().
The object is no longer usable after calling dispose. The arena has no collector, so
AnyRenderObject::dispose destroys the slot after this hook returns.
Sourcefn paint(
self: RenderHandle<Self>,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
)
fn paint( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, )
Paint this render object into the given context at the given offset.
Do not call this function directly: PaintingContext::paint_child does. Paint children
with context.paint_child(app, child, offset + child_offset); do not use the canvas to
translate, and do not use it after painting a child.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".