panels-w12: review fixes (review-2)

This commit is contained in:
aiongg
2026-11-14 17:56:01 +00:00
parent a3b66978e3
commit bbd6f2b6af
@@ -489,6 +489,7 @@ enum Seen<K> {
Menu(K),
Reorder(EditEvent<ReorderMove<K>>),
Rename(EditEvent<Rename<K>>),
Delete(Vec<K>),
}
/// The events of a collection that the browser acts on, whatever its items report.
@@ -502,6 +503,7 @@ fn seen<K, E>(events: Vec<CollectionEvent<K, E>>) -> Vec<Seen<K>> {
CollectionEvent::ContextMenu(request) => Some(Seen::Menu(request.key)),
CollectionEvent::Reorder(edit) => Some(Seen::Reorder(edit)),
CollectionEvent::Rename(edit) => Some(Seen::Rename(edit)),
CollectionEvent::Delete(keys) => Some(Seen::Delete(keys)),
_ => None,
})
.collect()
@@ -695,6 +697,7 @@ impl<K: Clone + Eq + Hash + Send + Sync + 'static> PresetBrowser<'_, K> {
.tail(&tail)
.collapsible()
.rename(true)
.deletable(true)
.rows_stamp(stamp)
.can_rename(rename_row)
.can_drag(can_drag)
@@ -741,6 +744,7 @@ impl<K: Clone + Eq + Hash + Send + Sync + 'static> PresetBrowser<'_, K> {
.arrows_select(false)
.selection(Bind::given(selection))
.rename(true)
.deletable(true)
.rows_stamp(stamp)
.can_rename(rename_row)
.can_drag(can_drag)
@@ -887,6 +891,17 @@ impl<K: Clone + Eq + Hash + Send + Sync + 'static> PresetBrowser<'_, K> {
};
events.extend(edit.filter_map(moved).map(PresetEvent::Reorder));
}
// Delete and Backspace give the same event as the row menu's Delete and the footer button; an
// open rename field takes the keys itself.
Seen::Delete(keys) => {
for key in keys {
if let BrowserKey::Preset(key) = key
&& can_delete.as_ref().is_none_or(|test| test.passes(&key))
{
events.push(PresetEvent::Delete(key));
}
}
}
Seen::Rename(edit) => {
let ended = matches!(edit.phase(), Some(GesturePhase::Commit) | None);
if let (true, Some(rename)) = (ended, edit.value())