pub struct AnnotatedRegionLayer { /* private fields */ }Expand description
A composited layer which annotates its children with a value. Pushing this layer to the tree is the common way of adding an annotation.
An annotation is an optional object of any type that, when attached with a layer, can be
retrieved using AnyLayer::find or AnyLayer::find_all_annotations with a position. The
search process is done recursively, controlled by a concept of being opaque to a type of
annotation, explained in the document of Layer::find_annotations.
When an annotation search arrives, this layer defers the same search to each of this layer’s children, respecting their opacity. Then it adds this layer’s annotation if all of the following restrictions are met:
- The target type must be identical to the annotated type
T. - If
sizeis provided, the target position must be contained within the rectangle formed bysizeandoffset.
This layer is opaque to a type of annotation if any child is also opaque, or if
opaque is true and the layer’s annotation is added.
Implementations§
Source§impl AnnotatedRegionLayer
impl AnnotatedRegionLayer
Sourcepub fn new(app: &mut App, value: Rc<dyn Any>) -> Handle<AnnotatedRegionLayer>
pub fn new(app: &mut App, value: Rc<dyn Any>) -> Handle<AnnotatedRegionLayer>
Creates a new layer that annotates its children with value.
Sourcepub fn value(self: Handle<Self>, app: &App) -> &Rc<dyn Any>
pub fn value(self: Handle<Self>, app: &App) -> &Rc<dyn Any>
The annotated object, which is added to the result if all restrictions are met.
Sourcepub fn offset(self: Handle<Self>, app: &App) -> Offset
pub fn offset(self: Handle<Self>, app: &App) -> Offset
The position of the annotated object.
The offset defaults to Offset::ZERO if not provided, and is ignored
if size is not set.
The offset only offsets the clipping rectangle, and does not affect how
the painting or annotation search is propagated to its children.
Sourcepub fn opaque(self: Handle<Self>, app: &App) -> bool
pub fn opaque(self: Handle<Self>, app: &App) -> bool
Whether the annotation of this layer should be opaque during an annotation search of type
T, preventing siblings visually behind it from being searched.
If opaque is true, and this layer does add its annotation
value, then the layer will always be opaque during the search.
If opaque is false, or if this layer does not add its annotation, then
the opacity of this layer will be the one returned by the children, meaning that it will
be opaque if any child is opaque.
The opaque defaults to false.
The opaque is effectively useless during AnyLayer::find (more
specifically, Layer::find_annotations with only_first: true), since the search
process then skips the remaining tree after finding the first annotation.
See also:
Layer::find_annotations, which explains the concept of being opaque to a type of annotation as the return value.HitTestBehavior, which controls similar logic when hit-testing in the render tree.
Trait Implementations§
Source§impl ContainerLayer for AnnotatedRegionLayer
impl ContainerLayer for AnnotatedRegionLayer
Source§fn container_layer_data(self: Handle<Self>, app: &App) -> &ContainerLayerData
fn container_layer_data(self: Handle<Self>, app: &App) -> &ContainerLayerData
Source§fn container_layer_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut ContainerLayerData
fn container_layer_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut ContainerLayerData
container_layer_data.Source§const AS_OFFSET: Option<fn() -> &'static OffsetLayerVTable> = None
const AS_OFFSET: Option<fn() -> &'static OffsetLayerVTable> = None
extends OffsetLayer;
container_layer_accessors!(offset) sets it. Dart’s layer is OffsetLayer.Source§fn as_container_layer(self: Handle<Self>) -> AnyContainerLayer
fn as_container_layer(self: Handle<Self>) -> AnyContainerLayer
ContainerLayer.Source§fn apply_transform(
self: Handle<Self>,
app: &App,
child: Option<AnyLayer>,
transform: &mut Matrix4,
)
fn apply_transform( self: Handle<Self>, app: &App, child: Option<AnyLayer>, transform: &mut Matrix4, )
Source§fn fire_composition_callbacks(
self: Handle<Self>,
app: &mut App,
include_children: bool,
)
fn fire_composition_callbacks( self: Handle<Self>, app: &mut App, include_children: bool, )
ContainerLayer._fireCompositionCallbacks.Source§fn supports_rasterization(self: Handle<Self>, app: &App) -> bool
fn supports_rasterization(self: Handle<Self>, app: &App) -> bool
ContainerLayer.supportsRasterization.Source§fn find_annotations(
self: Handle<Self>,
app: &App,
result: &mut AnnotationSearch,
local_position: Offset,
only_first: bool,
) -> bool
fn find_annotations( self: Handle<Self>, app: &App, result: &mut AnnotationSearch, local_position: Offset, only_first: bool, ) -> bool
ContainerLayer.findAnnotations.Source§fn redepth_children(self: Handle<Self>, app: &mut App)
fn redepth_children(self: Handle<Self>, app: &mut App)
ContainerLayer.redepthChildren.Source§fn add_to_scene(self: Handle<Self>, app: &mut App, builder: &mut SceneBuilder)
fn add_to_scene(self: Handle<Self>, app: &mut App, builder: &mut SceneBuilder)
ContainerLayer.addToScene.Source§impl Layer for AnnotatedRegionLayer
impl Layer for AnnotatedRegionLayer
Source§fn find_annotations(
self: Handle<Self>,
app: &App,
result: &mut AnnotationSearch,
local_position: Offset,
only_first: bool,
) -> bool
fn find_annotations( self: Handle<Self>, app: &App, result: &mut AnnotationSearch, local_position: Offset, only_first: bool, ) -> bool
Searches the subtree for annotations of the searched type at the location local_position,
then adds the annotation value if applicable.
This method always searches its children, and if any child returns true, the remaining
children are skipped. Regardless of what the children return, this method then adds this
layer’s annotation if all of the following restrictions are met:
- The target type must be identical to the annotated type
T. - If
sizeis provided, the target position must be contained within the rectangle formed bysizeandoffset.
This search process respects only_first, meaning that when only_first is true, the
search will stop when it finds the first annotation from the children, and the layer’s
own annotation is checked only when none is given by the children.
The return value is true if any child returns true, or if opaque is
true and the layer’s annotation is added.
For explanation of layer annotations, parameters and return value, refer to
Layer::find_annotations.
Source§const AS_CONTAINER: Option<fn() -> &'static ContainerLayerVTable>
const AS_CONTAINER: Option<fn() -> &'static ContainerLayerVTable>
extends ContainerLayer; layer_accessors!(container)
sets it. Dart’s layer is ContainerLayer.Source§fn layer_data(self: Handle<Self>, app: &App) -> &LayerData
fn layer_data(self: Handle<Self>, app: &App) -> &LayerData
layer ([layer_accessors!]).Source§fn layer_data_mut(self: Handle<Self>, app: &mut App) -> &mut LayerData
fn layer_data_mut(self: Handle<Self>, app: &mut App) -> &mut LayerData
layer_data.Source§fn supports_rasterization(self: Handle<Self>, app: &App) -> bool
fn supports_rasterization(self: Handle<Self>, app: &App) -> bool
Scene.toImage. Read moreSource§fn dispose(self: Handle<Self>, app: &mut App)
fn dispose(self: Handle<Self>, app: &mut App)
Source§fn attach(self: Handle<Self>, app: &mut App, owner: HandleId)
fn attach(self: Handle<Self>, app: &mut App, owner: HandleId)
Source§fn detach(self: Handle<Self>, app: &mut App)
fn detach(self: Handle<Self>, app: &mut App)
Source§fn redepth_children(self: Handle<Self>, app: &mut App)
fn redepth_children(self: Handle<Self>, app: &mut App)
Source§fn add_to_scene(self: Handle<Self>, app: &mut App, builder: &mut SceneBuilder)
fn add_to_scene(self: Handle<Self>, app: &mut App, builder: &mut SceneBuilder)
Source§fn fire_composition_callbacks(
self: Handle<Self>,
app: &mut App,
include_children: bool,
)
fn fire_composition_callbacks( self: Handle<Self>, app: &mut App, include_children: bool, )
_fireCompositionCallbacks; ContainerLayer recurses into its children.