#[non_exhaustive]pub struct SceneItemA11yContext {
pub view_transform: Transform2D,
pub scene_bounds: Rect,
pub item_id: ItemId,
pub local_to_scene: Transform2D,
}Expand description
Context handed to SceneItem::accessibility.
§The space every rectangle here is in
Scene coordinates, and so is everything the item emits. An item’s
AccessKit node carries its scene-space rectangle, and the view transform is
declared once, on the node at the top of the scene subtree, via
to_accesskit_affine.
The consumer composes that chain for bounding_box() and inverts it per
step when hit-testing, so the projection happens where AccessKit expects it
— which is what makes an item’s rectangle, its per-character text geometry
and an explore-by-touch probe all agree at any pan, zoom or rotation.
It is also what keeps the two tiers in one space: a heavyweight card’s arena bounds are scene coordinates too, and the framework walker declares the same transform on it. An item that projected its own geometry into window space instead would have it transformed a second time.
So: never multiply an emitted rectangle by the view transform. The same rule the framework states for the device scale factor, one level down.
§A box, not a silhouette
The box reported for an item is its local_bounds rectangle, not its
ItemShape. AccessKit has no other shape to offer, so
an item whose silhouette is narrower than its box — a rounded
RectItem, a stroke-only PathItem —
advertises ground a pointer aimed there would miss. That is deliberate and
it does not cost an AT client the element: a client identifies an element by
node id, announces and spatially navigates by this rectangle, and an
AccessKit action arrives addressed to the node rather than as a synthetic
press at a coordinate. Advertising the narrower rectangle instead would be
strictly worse — it would shrink what the element is said to cover without
making any more of it reachable. The per-item magnitude is on
RectItem::shape.
#[non_exhaustive]: the crate hands this to every SceneItem
implementation, out-of-tree ones included, and an item’s accessibility call
may learn to be told more. Build one with new.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.view_transform: Transform2DView transform (pan/zoom/rotation) at AT-build time.
Not for projecting geometry — see the type’s own documentation. It is here for an item whose content depends on the camera: how much detail to describe at the current zoom, say.
scene_bounds: RectThe item’s bounds in scene coordinates — the box written onto its AccessKit node.
item_id: ItemIdThe id under which this item is being emitted.
local_to_scene: Transform2DThe item’s own local coordinates mapped into scene coordinates — its
scene_transform.
An item emitting sub-element geometry of its own (a
TextItem’s AccessKit text runs, whose per-character
positions and widths live in the same space as the node’s box) needs
this rather than scene_bounds, which is an
axis-aligned box and says nothing about where a point inside the item
lands.
Implementations§
Source§impl SceneItemA11yContext
impl SceneItemA11yContext
Sourcepub fn new(
view_transform: Transform2D,
scene_bounds: Rect,
item_id: ItemId,
local_to_scene: Transform2D,
) -> Self
pub fn new( view_transform: Transform2D, scene_bounds: Rect, item_id: ItemId, local_to_scene: Transform2D, ) -> Self
An accessibility context stated field by field — the constructor
#[non_exhaustive] takes the place of a struct literal for.
The view builds its own; this exists so an item author can call their
own accessibility from a test.
Auto Trait Implementations§
impl Freeze for SceneItemA11yContext
impl RefUnwindSafe for SceneItemA11yContext
impl Send for SceneItemA11yContext
impl Sync for SceneItemA11yContext
impl Unpin for SceneItemA11yContext
impl UnsafeUnpin for SceneItemA11yContext
impl UnwindSafe for SceneItemA11yContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more