Skip to main content

aetna_core/state/
selection.rs

1//! Selection traversal state helpers for [`UiState`](super::UiState).
2
3use crate::event::UiTarget;
4use crate::tree::El;
5
6use super::UiState;
7
8impl UiState {
9    /// Walk the laid-out tree and rebuild the selectable-text order.
10    /// Same shape as [`Self::sync_focus_order`] but filters for
11    /// `selectable` keyed leaves instead of `focusable` ones. Should
12    /// run on every frame post-layout, before the selection manager
13    /// processes pointer events.
14    pub fn sync_selection_order(&mut self, root: &El) {
15        let order = crate::focus::selection_order(root, self);
16        self.selection.order = order;
17    }
18
19    /// Read access to the current document-order list of selectable
20    /// leaves. Mainly for tests; the selection manager uses internal
21    /// access.
22    pub fn selection_order(&self) -> &[UiTarget] {
23        &self.selection.order
24    }
25}