Expand description
The application-wide selection: what the user selected and what the pointer is over, shared by every panel.
Experimental: may change in any release
(docs/stability.md).
A tree, a list and a canvas showing the same things select and hover
them together: a click in one highlights the item in the others, and
hovering a row lights up the same item everywhere. The selection is
one SelectionService (the SELECTION token), provided by
SelectionPlugin; widgets opt in (TreeView::shared,
ListView::shared in egui_pop_views, or a canvas of the
application’s calling SelectionService::click and
SelectionService::hover).
- Items are
SelectionItems: a string id each, a path such asphotos/2024/0012.raworentity:/world/points. Widgets with different keys meet on it. - Gestures (
Gesture): a click replaces, Ctrl (Cmd on macOS) toggles, Shift selects a range in the order the widget clicked gives, Ctrl+Shift adds that range. - Hover: one item at most, said by the widget under the pointer each pass; it goes when that widget says it hovers nothing, or stops saying anything.
- Changes: each bumps a revision; subscribers are called
(
SelectionService::subscribe), the journal saysselection.changed, and the context keys follow:hasSelection,selectionCount,selectionCanBackandselectionCanForward. - History: the past selections, walked by
selection.backandselection.forward(Alt+Left and Alt+Right while the focus is in a widget bound to the selection, itsSURFACE). A selection is not an edit: undo does not see it. - Agents: the
selectioncollector, and theselection.set,selection.add,selection.clearandselection.hovercommands.
use egui_pop_api::selection::{Gesture, SelectionItem, SelectionService};
let s = SelectionService::new();
let order: Vec<SelectionItem> = ["a", "b", "c", "d"].map(SelectionItem::from).to_vec();
s.click(&order[1], Gesture::Replace, &order, "list");
s.click(&order[3], Gesture::Range, &order, "list");
assert_eq!(s.items(), order[1..].to_vec());
s.click(&order[2], Gesture::Toggle, &order, "list");
assert_eq!(s.items(), vec![order[1].clone(), order[3].clone()]);
assert!(s.back("test"));
assert_eq!(s.len(), 3);Structs§
- Change
- What changed, as subscribers get it.
- Selection
Item - An item of the selection: a string id the application chooses, the
same in every widget showing the item (a path,
kind:id, a number). - Selection
Plugin - The application-wide selection: its service, commands, keys, context keys and collector.
- Selection
Service - The application-wide selection; see the module.
- Subscription
- A subscription, to give back to
SelectionService::unsubscribe.
Enums§
- Gesture
- What a click does to the selection.
Constants§
- CMD_ADD
- Adds items to the selection.
- CMD_
BACK - Back to the selection before (Alt+Left in a bound widget).
- CMD_
CLEAR - Selects nothing.
- CMD_
FORWARD - Forward to the selection gone back from (Alt+Right in a bound widget).
- CMD_
HOVER - Hovers an item, or none.
- CMD_SET
- Selects these items, and only them.
- CONTEXT_
CAN_ BACK - The context key:
selection.backhas a selection to go back to. - CONTEXT_
CAN_ FORWARD - The context key:
selection.forwardhas a selection to go to. - CONTEXT_
COUNT - The context key: how many items are selected.
- CONTEXT_
HAS - The context key: something is selected (
trueorfalse). - EVENT_
CHANGED - The journal’s event after a change of the selection or of the hovered item.
- HISTORY_
CAP - How many past selections the history keeps.
- SELECTION
- The selection service.
- SELECTION_
PLUGIN - The plugin’s id.
- SOURCE_
COMMAND - The source a change made by an agent’s command names.
- SURFACE
- The focus surface of the widgets bound to the selection: Alt+Left and
Alt+Right go back and forward through the selections there, and the
context stack’s
nav.backkeeps them elsewhere.