diff --git a/crates/ui-panels/tests/it/focus/keys.rs b/crates/ui-panels/tests/it/focus/keys.rs index bc56bc432..d1a9d8dc9 100644 --- a/crates/ui-panels/tests/it/focus/keys.rs +++ b/crates/ui-panels/tests/it/focus/keys.rs @@ -205,7 +205,6 @@ fn drive_fixture(in_modal: bool) -> (craft_ui::testing::Fixture, std::rc::Rc ListManager<'a> { list = list.empty(empty.clone()); } if searchable { - // P3(pdf-forms-w3): L-70 — the closure gives several texts. list = list.filter(&session.name, |at| vec![Label::from(entries[*at].name.clone())]); } let events = list diff --git a/crates/ui-widgets/src/list/view.rs b/crates/ui-widgets/src/list/view.rs index d429fbd70..dffa086bd 100644 --- a/crates/ui-widgets/src/list/view.rs +++ b/crates/ui-widgets/src/list/view.rs @@ -14,7 +14,7 @@ use crate::primitives::HAlign; use crate::runtime::env::{Env, Label}; use crate::style::{ComponentStyle, StyleCx}; use craft_behavior::{ColumnKey, DisplayOrder, ItemSource, Metrics, Selection, SizeHint, SpanLayout}; -use craft_i18n::matcher::Matcher; +use craft_i18n::matcher::{Matcher, Rank}; use egui::{Rect, Ui}; use std::borrow::Cow; use std::hash::{DefaultHasher, Hash, Hasher}; @@ -34,8 +34,7 @@ pub struct DocumentRows { impl DocumentRows { /// Rows whose labels are document text in `font` at `size`, aligned `align`. pub fn new(font: FontRef, size: f32, align: HAlign) -> Self { - let _ = (font, size, align); - todo!("FM-PF11a") + DocumentRows { font, size, align } } } @@ -105,6 +104,8 @@ pub struct List<'a, K: Clone + Eq + Hash + Send + Sync + 'static> { /// The kept rows are in order of how well they match the query. #[prop] ranked: bool, + /// The rows' labels are document text, set by `document_rows`. + document: Option, } impl<'a, K: Clone + Eq + Hash + Send + Sync + 'static> List<'a, K> { @@ -128,15 +129,16 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + 'static> List<'a, K> { row_menu: false, filter: None, ranked: false, + document: None, } .label(label) } /// The rows' labels are document text at the document's font, size and alignment; UI text keeps its tokens. #[must_use] - pub fn document_rows(self, rows: DocumentRows) -> Self { - let _ = rows; - todo!("FM-PF11a") + pub fn document_rows(mut self, rows: DocumentRows) -> Self { + self.document = Some(rows); + self } /// The options list of a value picker's popup (completions, number presets, `PopupList`): one selection, a click @@ -155,16 +157,23 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + 'static> List<'a, K> { .listbox() } - /// Only the rows whose `label` matches `query` reach the item step, folded for the scope's language (case and - /// accents ignored); an empty query keeps every row. The rows stamp folds in the query, so the lead starts over - /// on the first shown row and the layout rebuilds when the query changes. Sets the rows stamp. + /// Only the rows of which one of the `texts` matches `query` reach the item step, folded for the scope's language + /// (case and accents ignored); a row ranks by its best matching text. An empty query keeps every row. + /// + /// A `ranked` list shows the matches alone, best first. Any other list keeps its display order and, with each + /// match, the rows it sits under: its ancestors in a tree and the section row heading it. A section row with no + /// match under it goes; a section row never matches by its own text. The row whose rename runs stays, so it is + /// named in place, with its ancestors and heading. + /// + /// The rows stamp folds in the query, so the lead starts over on the first shown row and the layout rebuilds when + /// the query changes. Sets the rows stamp. #[must_use] pub fn filter(mut self, query: &str, texts: impl Fn(&K) -> Vec