pub struct ToolbarMirror { /* private fields */ }Expand description
A backend’s copy of one window’s toolbar, kept in step with the ToolbarOps and
ToolbarPatches that reach it, and the one place a backend works out where a new item
goes (docs/toolbars.md).
Every backend lays its bar out as a few groups (the leading and trailing ends of a header
bar, the columns of a split window, the primary and overflow commands of a command bar) and
keeps model order within each. So an inserted item always goes right after
ToolbarMirror::prev_where its own group, or first in the group when that is None, and
nothing already on the bar moves.
Implementations§
Source§impl ToolbarMirror
impl ToolbarMirror
Sourcepub fn items(&self) -> &[ToolbarItem]
pub fn items(&self) -> &[ToolbarItem]
The bar’s items, in model order.
pub fn is_empty(&self) -> bool
Sourcepub fn get(&self, id: &str) -> Option<&ToolbarItem>
pub fn get(&self, id: &str) -> Option<&ToolbarItem>
The item with this id.
Sourcepub fn by_action(&self, action: u64) -> Option<&ToolbarItem>
pub fn by_action(&self, action: u64) -> Option<&ToolbarItem>
The item dispatching action: how a backend whose native bar reports only an action
id (a menu tap) finds what was tapped.
Sourcepub fn remove(&mut self, id: &str) -> Option<ToolbarItem>
pub fn remove(&mut self, id: &str) -> Option<ToolbarItem>
Take the item with id out, returning it.
Sourcepub fn insert(&mut self, index: usize, item: ToolbarItem)
pub fn insert(&mut self, index: usize, item: ToolbarItem)
Put item at index (clamped to the end).
Sourcepub fn apply(&mut self, op: &ToolbarOp)
pub fn apply(&mut self, op: &ToolbarOp)
Apply one op to the model: what a backend that repaints its whole native bar from the model (a menu of actions) does with each.
Sourcepub fn patch(&mut self, patch: &ToolbarPatch) -> bool
pub fn patch(&mut self, patch: &ToolbarPatch) -> bool
Write a value patch into the model. false when no item takes it.
Sourcepub fn prev_where(
&self,
index: usize,
same_group: impl Fn(&ToolbarItem) -> bool,
) -> Option<&ToolbarItem>
pub fn prev_where( &self, index: usize, same_group: impl Fn(&ToolbarItem) -> bool, ) -> Option<&ToolbarItem>
The nearest item before index that same_group accepts: the native item a new one at
index goes right after, in that group. None = it goes first in the group.
Trait Implementations§
Source§impl Clone for ToolbarMirror
impl Clone for ToolbarMirror
Source§fn clone(&self) -> ToolbarMirror
fn clone(&self) -> ToolbarMirror
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more