Skip to main content

SceneItemA11yContext

Struct SceneItemA11yContext 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§view_transform: Transform2D

View 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: Rect

The item’s bounds in scene coordinates — the box written onto its AccessKit node.

§item_id: ItemId

The id under which this item is being emitted.

§local_to_scene: Transform2D

The 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

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more