semanticObjectsFor function
List<SemanticObject>
semanticObjectsFor(
- List<
SceneAnnouncement> announcements, { - required CameraNode camera,
- required Size size,
announcements projected through camera for a viewport of size.
Anything with no bounds, or entirely behind the eye, is dropped: a node a screen reader is told about but cannot be given a position for is a node whose focus ring has nowhere to go.
Implementation
List<SemanticObject> semanticObjectsFor(
List<SceneAnnouncement> announcements, {
required CameraNode camera,
required Size size,
}) {
if (size.isEmpty) return const <SemanticObject>[];
final viewProjection = camera.viewProjection(size.width / size.height);
return <SemanticObject>[
for (final it in announcements)
if (it.node.subtreeBounds case final Aabb3 box)
if (screenBoundsOfBox(
viewProjection,
box,
width: size.width,
height: size.height,
)
case final ScreenBounds at)
SemanticObject(
id: it.id,
label: it.label,
hint: it.hint,
selected: it.selected,
onTap: it.onTap,
bounds: Rect.fromLTRB(at.left, at.top, at.right, at.bottom),
),
];
}