Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

List rows inside their list for screen readers (#102) (#105)

Ahmed Nefzaoui2a80f2936832
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ff25b55..c554473c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -194,6 +194,11 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
their selected row; Download video's list is called Quality, Add torrent's Files and the
sounds' Sounds. Choosing a row from a screen reader (UI Automation's Select) now shows the new
choice at once: it used to wait for the next mouse move.
+- **List rows sit inside their list for screen readers** ([#102](https://github.com/anefzaoui/misterdownloadmanager/issues/102)):
+ they used to be listed beside it. A screen reader now says which row of how many ("4 of 12"),
+ choosing from the list itself works (UI Automation's Selection), and a tree's check box belongs
+ to its file's row. The language picker's list and the Options browser list and the Scheduler's
+ two lists have names now too.
- **Torrents: speed limits now work as they do for other downloads**
([#39](https://github.com/anefzaoui/misterdownloadmanager/issues/39)): a limit set in a
torrent's progress window changed every torrent's limit, a remembered limit was ignored, the
diff --git a/ROADMAP.md b/ROADMAP.md
index c2a87b90..9b66a8f3 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -61,7 +61,8 @@ Everything below ships together, in one release.
([#78](https://github.com/anefzaoui/misterdownloadmanager/issues/78))
- ✅ A file-type icon before every file name: the download list, Download File Info, Properties,
a torrent's files and the Scheduler's (Material Icon Theme, the same on every system), and every
- list's rows named for screen readers ([#95](https://github.com/anefzaoui/misterdownloadmanager/issues/95))
+ list's rows named for screen readers ([#95](https://github.com/anefzaoui/misterdownloadmanager/issues/95)),
+ inside their list, with their place in it ([#102](https://github.com/anefzaoui/misterdownloadmanager/issues/102))
- ✅ Website in European Portuguese, and an [intended use](https://misterdownloadmanager.com/intended-use.html) page
- ✅ Website: the [free IDM alternative](https://misterdownloadmanager.com/idm-alternative.html) page compares
MDM with IDM and with nine other free download managers, each checked on its own site, with
diff --git a/crates/app/src/langpick.rs b/crates/app/src/langpick.rs
index 84b4e918..38c803fa 100644
--- a/crates/app/src/langpick.rs
+++ b/crates/app/src/langpick.rs
@@ -209,11 +209,40 @@ impl Picker {
pos2(inner_right, list.bottom() - 1.0),
)));
let first = self.top.floor() as usize;
+ // The list as one node, its rows inside it (#102): a screen reader says "4 of
+ // 87", and UI Automation's Selection finds them under it. Hover only, so the rows
+ // keep their clicks.
+ let list_resp = ui.interact(
+ shown_list,
+ egui::Id::unique("language-list"),
+ egui::Sense::hover(),
+ );
+ // Reachable by a screen reader's focus and click, as the shared lists are (the
+ // keys already act on the list wherever the focus is); it senses only hover, so
+ // neither takes the focus from the filter box.
+ ui.ctx().accesskit_node_builder(list_resp.id, |n| {
+ n.add_action(egui::accesskit::Action::Focus);
+ n.add_action(egui::accesskit::Action::Click);
+ });
+ // i18n: window title (the interface language)
+ winui::expose(
+ &list_resp,
+ egui::Role::ListBox,
+ crate::i18n::t("Language"),
+ true,
+ None,
+ );
+ let count = rows.len();
+ let rows_ui = ui.new_child(
+ egui::UiBuilder::new()
+ .max_rect(shown_list)
+ .accessibility_parent(list_resp.id),
+ );
for (k, entry) in rows.iter().enumerate().skip(first).take(page as usize + 1) {
let y = list.top() + 1.0 + (k - first) as f32 * ROW;
let row =
Rect::from_min_max(pos2(list.left() + 1.0, y), pos2(inner_right, y + ROW));
- let resp = ui.interact(
+ let resp = rows_ui.interact(
winui::rect(row),
egui::Id::unique(("language-row", k)),
winui::pointer_only(),
@@ -291,8 +320,11 @@ impl Picker {
format!("{name}, {english}")
};
winui::expose(&resp, egui::Role::ListBoxOption, &spoken, true, None);
- ui.ctx()
- .accesskit_node_builder(resp.id, |n| n.set_selected(on));
+ rows_ui.ctx().accesskit_node_builder(resp.id, |n| {
+ n.set_selected(on);
+ n.set_position_in_set(k + 1);
+ n.set_size_of_set(count);
+ });
let shown = winui::ellipsize(&clip, &winui::tahoma(), &name, room);
winui::text(&clip, row.left() + 36.0, y + 17.0, &shown, fg);
if !english.is_empty() {
diff --git a/crates/app/src/options.rs b/crates/app/src/options.rs
index 2d7f9966..e7b42876 100644
--- a/crates/app/src/options.rs
+++ b/crates/app/src/options.rs
@@ -281,6 +281,8 @@ impl OptionsDialog {
// Check list: one row per browser in the shared row list (Space ticks the selected
// one; the box and its name tick it too).
let browsers = &mut s.browsers;
+ // Named by its group's caption, which says what the list is (#102).
+ self.browser_rows.name = crate::i18n::t("Capture downloads from the following browsers:");
let ev = winui::row_list(
ui,
"browsers",
diff --git a/crates/app/src/scheduler.rs b/crates/app/src/scheduler.rs
index 4fff9587..2300b9d4 100644
--- a/crates/app/src/scheduler.rs
+++ b/crates/app/src/scheduler.rs
@@ -503,6 +503,8 @@ impl Scheduler {
let queues = &self.queues;
let n = queues.len() + 1;
self.tree_rows.selected = Some(self.selected);
+ // Named for screen readers (#102), as the tree's caption reads.
+ self.tree_rows.name = crate::i18n::t("Queues");
let ev = winui::row_list(
ui,
"sched-tree",
@@ -880,6 +882,8 @@ impl Scheduler {
let by_id: std::collections::HashMap<u64, &Item> =
items.iter().map(|i| (i.id, i)).collect();
let rows: Vec<&Item> = ids.iter().filter_map(|id| by_id.get(id).copied()).collect();
+ // Named for screen readers (#102), as its tab reads.
+ self.files_rows.name = crate::i18n::t("Files in the queue");
let ev = winui::row_list(
ui,
"sched-files",
diff --git a/crates/app/src/winui.rs b/crates/app/src/winui.rs
index 67c9e895..de415328 100644
--- a/crates/app/src/winui.rs
+++ b/crates/app/src/winui.rs
@@ -1201,10 +1201,18 @@ pub fn row_list(
st.first = st.first.min(max_first);
ev.focused = focused;
let clip = p.with_clip_rect(rect(area));
+ // The rows (and what their painters put in them: a tree's check boxes) are the list's
+ // children in the accessibility tree, not its siblings (#102): a screen reader then says
+ // "4 of 12", and UI Automation's Selection finds them under the list.
+ let mut rows_ui = ui.new_child(
+ egui::UiBuilder::new()
+ .max_rect(rect(inner))
+ .accessibility_parent(resp.id),
+ );
for i in st.first..n.min(st.first + page) {
let top = inner.top() + 1.0 + row_h * (i - st.first) as f32;
let row = Rect::from_min_max(pos2(inner.left(), top), pos2(right, top + row_h));
- let r = ui.interact(rect(row), id.with(i), pointer_only());
+ let r = rows_ui.interact(rect(row), id.with(i), pointer_only());
let selected = st.selected == Some(i);
let fill = if selected && focused {
Some(ROW_SELECTED())
@@ -1248,14 +1256,27 @@ pub fn row_list(
},
name: String::new(),
};
- paint(ui, &clip, i, row, &mut look);
+ // What the painter puts in the row (a tree's check box) belongs to the row: the row's
+ // node made first (named below, once its painter has said what it shows), so those
+ // controls find it as their parent.
+ ui.ctx().accesskit_node_builder(r.id, |_| {});
+ let mut row_ui = rows_ui.new_child(
+ egui::UiBuilder::new()
+ .max_rect(rect(row))
+ .accessibility_parent(r.id),
+ );
+ paint(&mut row_ui, &clip, i, row, &mut look);
// Named by what its painter drew (#95: rows were read as blank items, and alike rows
// couldn't be told apart by UI Automation).
expose(&r, egui::Role::ListBoxOption, &look.name, true, None);
// Selected as a list's item (UI Automation's SelectionItem), as the download list does;
// expose's `on` would make it "toggled".
- ui.ctx()
- .accesskit_node_builder(r.id, |n| n.set_selected(selected));
+ // Its place among all the rows, not only those drawn (only the rows in view exist).
+ ui.ctx().accesskit_node_builder(r.id, |node| {
+ node.set_selected(selected);
+ node.set_position_in_set(i + 1);
+ node.set_size_of_set(n);
+ });
if selected && focused {
focus_ring(&clip, rect(row));
}
diff --git a/i18n/en.tsv b/i18n/en.tsv
index f3adc10b..fcb0ba8f 100644
--- a/i18n/en.tsv
+++ b/i18n/en.tsv
@@ -213,7 +213,7 @@
Cannot read the file: {error} Cannot read the file: {error}
#. text in errors.rs
cannot resume: {detail} cannot resume: {detail}
-#. group box title in the Options window
+#. group box title in the Options window; text in the Options window
Capture downloads from the following browsers: Capture downloads from the following browsers:
#. text in extension.rs
#. the headline of the window that offers the browser extension
@@ -577,7 +577,7 @@
#. text in the Add torrent window
#. {folder} = the folder the torrent's files are saved in
Files go to: {folder} Files go to: {folder}
-#. tab in the Scheduler window
+#. text in the Scheduler window; tab in the Scheduler window
Files in the queue Files in the queue
#. button in the Find window
#. verb: button that starts the search