Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
accessibility_tree.hpp
Go to the documentation of this file.
1#pragma once
2
3// Accessibility tree snapshot.
4//
5// Walks a pulp::view::View subtree and produces a flat inventory of
6// (role, label, value, actions) tuples. Used by cross-platform a11y
7// tests to verify that view metadata is set correctly without needing
8// a real screen reader attached. Platform bridges (macOS / iOS / Android
9// / Windows UIA / Linux AT-SPI) serve the same data to their respective
10// accessibility clients, so an offline mismatch here will surface as a
11// bridge regression later.
12
13#include <pulp/view/view.hpp>
14
15#include <string>
16#include <vector>
17
18namespace pulp::view {
19
21 const View* view = nullptr;
23 std::string label;
24 std::string value;
25
26 // True when the platform bridges put this View in the accessibility
27 // tree — pulp::view::is_accessibility_element(view), the same gate the
28 // macOS / iOS / UIA / AT-SPI / TalkBack collectors call. A role alone is
29 // not enough: a name-only role (button, link, tab, label ...) with an
30 // empty label is excluded rather than announced as a nameless control.
31 bool exposed = false;
32
33 // Numeric range information when the view exposes
34 // AccessibilityValueInterface. Present fields are filled; otherwise
35 // has_value is false and callers should ignore min/max/current.
36 bool has_value = false;
37 double min_value = 0.0;
38 double max_value = 0.0;
39 double current_value = 0.0;
40 std::string value_string;
41
42 // ARIA state attributes. Tri-state per ARIA 1.2:
43 // `true` / `false` / `mixed` / unset (empty string). Platform AT
44 // bridges read these to expose the toggle/checkbox state.
45 // Stored on View::access_pressed_/_checked_/_disabled_/_hidden_;
46 // surfaced through this snapshot for the cross-platform tree path.
47 std::string pressed; // aria-pressed
48 std::string checked; // aria-checked
49 std::string disabled; // aria-disabled
50 std::string hidden; // aria-hidden
51
52 // Nesting depth under the root; the root itself is depth 0.
53 int depth = 0;
54};
55
60std::vector<AccessibilityNodeSnapshot> snapshot_accessibility_tree(const View& root);
61
66std::size_t count_announceable(const View& root);
67
71const View* find_by_role_and_label(const View& root,
73 std::string_view label);
74
75} // namespace pulp::view
Definition view.hpp:73
AccessRole
Screen-reader role.
Definition view.hpp:988
@ none
Definition view.hpp:989
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
std::vector< AccessibilityNodeSnapshot > snapshot_accessibility_tree(const View &root)
Depth-first snapshot of root and every descendant.
std::size_t count_announceable(const View &root)
Count nodes the platform bridges actually expose (snapshot node exposed — role != none AND named when...
const View * find_by_role_and_label(const View &root, View::AccessRole role, std::string_view label)
Find the first descendant whose access_label exactly matches label and whose role equals role.
Definition accessibility_tree.hpp:20
bool exposed
Definition accessibility_tree.hpp:31
double current_value
Definition accessibility_tree.hpp:39
std::string disabled
Definition accessibility_tree.hpp:49
std::string hidden
Definition accessibility_tree.hpp:50
std::string label
Definition accessibility_tree.hpp:23
int depth
Definition accessibility_tree.hpp:53
double min_value
Definition accessibility_tree.hpp:37
double max_value
Definition accessibility_tree.hpp:38
const View * view
Definition accessibility_tree.hpp:21
std::string value_string
Definition accessibility_tree.hpp:40
View::AccessRole role
Definition accessibility_tree.hpp:22
bool has_value
Definition accessibility_tree.hpp:36
std::string pressed
Definition accessibility_tree.hpp:47
std::string value
Definition accessibility_tree.hpp:24
std::string checked
Definition accessibility_tree.hpp:48