Trace Link Info readout accessibility during layout

This commit is contained in:
yoriswind committed 2026-11-26 18:07:37 -08:00
1 parent 376a6c473f
commit d352b3a5bd
3 files changed
+44 -5

No files matched your search

+13
View File
@@ -98,8 +98,21 @@ pub(crate) fn copy_shown(ui: &mut Ui, shown: &egui::Response, value: &str) -> bo
});
}
ui.ctx().accesskit_node_builder(shown.id, |node| {
// TEMPORARY diagnostic: MUST REMOVE before publication.
if value.contains("Überlagerung") {
eprintln!(
"LINK_LOCATION_COPY_BEFORE id={:?} role={:?} label={:?} value={:?} description={:?} bounds={:?} children={:?}",
shown.id, node.role(), node.label(), node.value(), node.description(), node.bounds(), node.children()
);
}
node.set_description(tl!("Copy"));
node.add_action(egui::accesskit::Action::Click);
if value.contains("Überlagerung") {
eprintln!(
"LINK_LOCATION_COPY_AFTER id={:?} role={:?} label={:?} value={:?} description={:?} bounds={:?} children={:?}",
shown.id, node.role(), node.label(), node.value(), node.description(), node.bounds(), node.children()
);
}
});
let activated = ui.input(|i| i.num_accesskit_action_requests(shown.id, egui::accesskit::Action::Click) > 0);
eligible
+5 -5
View File
@@ -287,10 +287,10 @@ fn a_link_inside_a_symbol_is_listed_and_picked_in_the_panel() {
let row = list["links"].as_array().unwrap().iter().find(|r| r["name"] == "inside.png").unwrap_or_else(|| panic!("{list}")).clone();
assert_eq!(row["owner"]["kind"], "symbol", "{list}");
let mut h = Panel::new(app, super::links::show);
assert!(h.shows("20 × 20 px"), "Link Info of the selected image in the layers");
assert!(h.label_has_value("Dimensions", "20 × 20 px"), "Link Info of the selected image in the layers");
h.click_with("inside.png", egui::Modifiers::NONE);
assert!(selected(&h.app()).is_empty(), "the canvas can't select it");
assert!(h.shows("30 × 20 px"), "Link Info of the symbol's image");
assert!(h.label_has_value("Dimensions", "30 × 20 px"), "Link Info of the symbol's image");
// Copy Info without ids copies the row picked in the panel.
assert!(crate::menus::enabled(&h.app(), "links.copyInfo"));
assert_eq!(h.app().run("links.copyInfo", json!({})).unwrap()["text"], "inside.png");
@@ -302,13 +302,13 @@ fn a_link_inside_a_symbol_is_listed_and_picked_in_the_panel() {
h.advance(1.0);
h.click_with("layer.png", egui::Modifiers::COMMAND);
assert!(selected(&h.app()).is_empty());
assert!(h.shows("30 × 20 px"), "the symbol's image is still picked");
assert!(h.label_has_value("Dimensions", "30 × 20 px"), "the symbol's image is still picked");
h.app().run("select.set", json!({"ids": [layer]})).unwrap();
h.frame();
assert!(h.shows("20 × 20 px"));
assert!(h.label_has_value("Dimensions", "20 × 20 px"));
h.app().run("select.set", json!({"ids": []})).unwrap();
h.frame();
assert!(!h.shows("30 × 20 px") && !h.shows("20 × 20 px"), "nothing is picked");
assert!(!h.label_has_value("Dimensions", "30 × 20 px") && !h.label_has_value("Dimensions", "20 × 20 px"), "nothing is picked");
// Go To clears the selection and says the link has no place on the canvas.
h.app().run("select.set", json!({"ids": [layer]})).unwrap();
super::links::go_to(&mut h.app(), row["id"].as_u64().unwrap());
+26
View File
@@ -364,6 +364,14 @@ impl Panel {
self.fixture.tree().value_of(self.look_role(name, role).node).map(str::to_owned)
}
/// Whether a label named `name` has exactly `value`, where a field's static label may share its name and role.
pub(crate) fn label_has_value(&self, name: &str, value: &str) -> bool {
let tree = self.fixture.tree();
tree.keys().into_iter().any(|key| {
tree.role_of(key) == Some(craft::ui::contract::Role::LABEL) && tree.name_of(key) == Some(name) && tree.value_of(key) == Some(value)
})
}
/// The description of the control named `name` (a list row's trailing texts).
pub(crate) fn description(&self, name: &str) -> Option<String> {
self.fixture.tree().description_of(self.look(name).node).map(str::to_owned)
@@ -476,6 +484,24 @@ pub(crate) fn floated(mut app: VectorcraftApp, panel: &str, lang: &str, place: P
crate::i18n::set_current(crate::i18n::Lang::EN);
let rect = |node: &Node| node.bounds().map(|b| Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32)));
let by_id: HashMap<NodeId, &Node> = nodes.iter().map(|(id, n)| (*id, n)).collect();
// TEMPORARY diagnostic: MUST REMOVE before publication.
if panel == "links" && names.iter().any(|(asked, _)| asked.contains("Überlagerung") || asked.contains("location-width")) {
for (root, _) in nodes.iter().filter(|(_, node)| node.role() == Role::TabPanel) {
let mut todo = vec![(*root, vec![*root])];
while let Some((id, ancestry)) = todo.pop() {
let Some(node) = by_id.get(&id) else { continue };
eprintln!(
"LINK_LOCATION_FINAL lang={lang} id={id:?} role={:?} label={:?} value={:?} description={:?} bounds={:?} children={:?} tab_panel_ancestry={ancestry:?}",
node.role(), node.label(), node.value(), node.description(), node.bounds(), node.children()
);
for child in node.children() {
let mut child_ancestry = ancestry.clone();
child_ancestry.push(*child);
todo.push((*child, child_ancestry));
}
}
}
}
let under = |root: NodeId| {
let mut found = Vec::new();
let mut todo = vec![root];