pub struct SelectionService { /* private fields */ }Expand description
The application-wide selection; see the module.
Thread-safe: an application’s worker may select too. Every change calls the subscribers once the lock is released and asks egui for a repaint.
Implementations§
Source§impl SelectionService
impl SelectionService
Sourcepub fn items(&self) -> Vec<SelectionItem>
pub fn items(&self) -> Vec<SelectionItem>
The selected items, in the order they were selected.
pub fn contains(&self, item: &SelectionItem) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn anchor(&self) -> Option<SelectionItem>
pub fn anchor(&self) -> Option<SelectionItem>
Where a range (Shift) starts: the item last clicked.
Sourcepub fn hovered(&self) -> Option<SelectionItem>
pub fn hovered(&self) -> Option<SelectionItem>
The item under the pointer, in whichever widget.
pub fn is_hovered(&self, item: &SelectionItem) -> bool
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
Bumped by each change of the selected items: a widget compares it with the one it last saw to know whether to look again.
Sourcepub fn hover_revision(&self) -> u64
pub fn hover_revision(&self) -> u64
Bumped by each change of the hovered item.
Sourcepub fn subscribe(
&self,
f: impl Fn(&Change) + Send + Sync + 'static,
) -> Subscription
pub fn subscribe( &self, f: impl Fn(&Change) + Send + Sync + 'static, ) -> Subscription
Calls f after each change (also of the hovered item), from the
thread making it, the lock released.
pub fn unsubscribe(&self, subscription: Subscription)
Sourcepub fn set(
&self,
items: impl IntoIterator<Item = SelectionItem>,
source: &str,
) -> bool
pub fn set( &self, items: impl IntoIterator<Item = SelectionItem>, source: &str, ) -> bool
Selects these items, and only them.
Sourcepub fn add(
&self,
items: impl IntoIterator<Item = SelectionItem>,
source: &str,
) -> bool
pub fn add( &self, items: impl IntoIterator<Item = SelectionItem>, source: &str, ) -> bool
Adds these items (those already selected stay where they are).
Sourcepub fn apply(
&self,
add: impl IntoIterator<Item = SelectionItem>,
remove: impl IntoIterator<Item = SelectionItem>,
source: &str,
) -> bool
pub fn apply( &self, add: impl IntoIterator<Item = SelectionItem>, remove: impl IntoIterator<Item = SelectionItem>, source: &str, ) -> bool
Adds add and removes remove, as one change (one step of the
history): what a widget’s Ctrl gesture does to its own items while
keeping the others’.
Sourcepub fn remove(
&self,
items: impl IntoIterator<Item = SelectionItem>,
source: &str,
) -> bool
pub fn remove( &self, items: impl IntoIterator<Item = SelectionItem>, source: &str, ) -> bool
Removes these items.
Sourcepub fn toggle(&self, item: &SelectionItem, source: &str) -> bool
pub fn toggle(&self, item: &SelectionItem, source: &str) -> bool
Adds the item, or removes it when selected.
Sourcepub fn click(
&self,
item: &SelectionItem,
gesture: Gesture,
order: &[SelectionItem],
source: &str,
) -> bool
pub fn click( &self, item: &SelectionItem, gesture: Gesture, order: &[SelectionItem], source: &str, ) -> bool
A click on item in a widget showing order (its items in the
order shown, for a range; empty when it has no order). A range
whose anchor is not in order selects the item alone. Returns
whether the selection changed.
Sourcepub fn hover(&self, source: &str, item: Option<&SelectionItem>)
pub fn hover(&self, source: &str, item: Option<&SelectionItem>)
What the widget source hovers this pass (None: nothing of
it). A widget says it every pass it is drawn: its None clears a
hover it said, never another widget’s; a hover no widget repeats
goes after a pass (the plugin sees to it).
Sourcepub fn hover_until_changed(&self, item: Option<&SelectionItem>, source: &str)
pub fn hover_until_changed(&self, item: Option<&SelectionItem>, source: &str)
Hovers an item until said otherwise (an agent’s), or none.
Sourcepub fn expire_hover(&self, before: u64)
pub fn expire_hover(&self, before: u64)
Clears a widget’s hover not said since pass before (the widget
is no longer drawn). The plugin calls it every pass.
Sourcepub fn can_forward(&self) -> bool
pub fn can_forward(&self) -> bool
Whether there is a selection to go forward to.
Sourcepub fn back(&self, source: &str) -> bool
pub fn back(&self, source: &str) -> bool
Back to the selection before; false when there is none.
Trait Implementations§
Source§impl Debug for SelectionService
impl Debug for SelectionService
Auto Trait Implementations§
impl !Freeze for SelectionService
impl RefUnwindSafe for SelectionService
impl Send for SelectionService
impl Sync for SelectionService
impl Unpin for SelectionService
impl UnsafeUnpin for SelectionService
impl UnwindSafe for SelectionService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more