pub trait RenderAbstractViewport: RenderObject {
// Required method
fn get_offset_to_reveal(
self: RenderHandle<Self>,
app: &App,
target: AnyRenderObject,
alignment: f64,
rect: Option<Rect>,
axis: Option<Axis>,
) -> RevealedOffset;
// Provided method
fn as_abstract_viewport(
self: RenderHandle<Self>,
) -> AnyRenderAbstractViewport { ... }
}Expand description
An interface for render objects that are bigger on the inside.
Some render objects, such as RenderViewport, present a portion of their content, which
can be controlled by a crate::ViewportOffset. This interface lets the framework recognize
such render objects and interact with them without having specific knowledge of all the
various types of viewports.
Answer RenderObject::interface for AnyRenderAbstractViewport with
as_abstract_viewport so that
AnyRenderAbstractViewport::maybe_of can find this render object.
Required Methods§
Sourcefn get_offset_to_reveal(
self: RenderHandle<Self>,
app: &App,
target: AnyRenderObject,
alignment: f64,
rect: Option<Rect>,
axis: Option<Axis>,
) -> RevealedOffset
fn get_offset_to_reveal( self: RenderHandle<Self>, app: &App, target: AnyRenderObject, alignment: f64, rect: Option<Rect>, axis: Option<Axis>, ) -> RevealedOffset
Returns the offset that would be needed to reveal the target render object.
This is used by show_in_viewport, which is itself used by
RenderObject::show_on_screen for RenderViewportBase.
The optional rect parameter describes which area of that target object should be
revealed in the viewport. If rect is None, the entire target (as defined by its
paint bounds) will be revealed. If rect is provided it has to be given in the
coordinate system of the target object.
The alignment argument describes where the target should be positioned after applying
the returned offset. If alignment is 0.0, the child must be positioned as close to the
leading edge of the viewport as possible. If alignment is 1.0, the child must be
positioned as close to the trailing edge of the viewport as possible. If alignment is
0.5, the child must be positioned as close to the center of the viewport as possible.
The target might not be a direct child of this viewport but it must be a descendant of
the viewport. Other viewports in between this viewport and the target will not be
adjusted.
This method assumes that the content of the viewport moves linearly, i.e. when the offset
of the viewport is changed by x then target also moves by x within the viewport.
The optional Axis determines which of two axes to compute an offset for.
One-dimensional viewports ignore it, since there is only one Axis.
Provided Methods§
Sourcefn as_abstract_viewport(self: RenderHandle<Self>) -> AnyRenderAbstractViewport
fn as_abstract_viewport(self: RenderHandle<Self>) -> AnyRenderAbstractViewport
The type-erased RenderAbstractViewport handle. Free: the vtable is a const, and the
id is copied.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".