pub struct Indicator {
pub id: String,
pub label: String,
pub prefix: String,
pub command: Option<CommandId>,
pub weight: i32,
pub when: Option<String>,
pub align: Alignment,
pub priority: i32,
pub panel: Option<PanelId>,
/* private fields */
}Expand description
An indicator, as declared.
Fields§
§id: String§label: String§prefix: StringThe event names it follows (a prefix: job.).
command: Option<CommandId>Run on a click.
weight: i32Lighter first, from the end of the status bar.
when: Option<String>Where it shows: a when clause over the context keys (none:
everywhere).
align: AlignmentWhich end of the bar it sits at.
priority: i32On a narrow bar, the items of higher priority stay longer; among equals, the lighter.
panel: Option<PanelId>The panel it speaks for (Indicator::panel): shown on that
panel’s icon in a folded side area’s strip instead of in the
status bar.
Implementations§
Source§impl Indicator
impl Indicator
Sourcepub fn new(id: &str, label: &str, prefix: &str) -> Self
pub fn new(id: &str, label: &str, prefix: &str) -> Self
An indicator following the events named prefix...; its text is
label until an event says otherwise.
Sourcepub fn reduce(self, f: impl Fn(&mut IndicatorState, &Event) + 'static) -> Self
pub fn reduce(self, f: impl Fn(&mut IndicatorState, &Event) + 'static) -> Self
How an event changes the state.
Sourcepub fn command(self, id: CommandId) -> Self
pub fn command(self, id: CommandId) -> Self
Runs a command on a click. Without an icon of its own, the item
shows the command’s (CommandSpec::icon, icon_on while the
command’s checked clause holds).
Sourcepub fn icon(self, name: &str) -> Self
pub fn icon(self, name: &str) -> Self
Its icon, by name (egui-pop’s, phosphor:<name> or a plugin’s),
drawn before its text; a reducer may change it
(IndicatorState::icon). An item whose text is empty shows the
icon alone (a connection, a sync), named by its label for screen
readers. Checked with the other declared icons (unknown-icon).
pub fn weight(self, weight: i32) -> Self
Sourcepub fn align(self, align: Alignment) -> Self
pub fn align(self, align: Alignment) -> Self
Which end of the bar it sits at (the end by default).
Sourcepub fn priority(self, priority: i32) -> Self
pub fn priority(self, priority: i32) -> Self
How long it stays on a narrow bar: the higher, the longer (0 by
default). Items that give way go into the bar’s … menu.
Sourcepub fn panel(self, panel: &PanelId) -> Self
pub fn panel(self, panel: &PanelId) -> Self
Speaks for a panel, keyed by its id: while the panel is not
shown (its side area folded, or another tab in front), the
strip of its folded area shows the state on the panel’s icon (a
count as a badge, else errors or warnings, else a dot in its
tone; detail joins the icon’s tooltip). It is not a status bar
item; agents read it in workbench::strip and the workbench
collector.
Sourcepub fn popover(self, f: impl Fn(&mut Ui, &AppHandle) + 'static) -> Self
pub fn popover(self, f: impl Fn(&mut Ui, &AppHandle) + 'static) -> Self
A popover opened by a click (Enter from the keyboard, or
status.item.open): a small layout next to the item, closed by
Escape or a click outside, the focus back on the item. It takes
the click from Indicator::command, which its content can
still run.
Sourcepub fn card(&self, state: &IndicatorState, app: &AppHandle) -> Option<Card>
pub fn card(&self, state: &IndicatorState, app: &AppHandle) -> Option<Card>
Its hover card in a state (none without Indicator::hover, or
when the card is empty).
Sourcepub fn initial(self, state: IndicatorState) -> Self
pub fn initial(self, state: IndicatorState) -> Self
The state before any event.
Sourcepub fn when(self, clause: &str) -> Self
pub fn when(self, clause: &str) -> Self
Shows it only where a when clause holds over the context keys
(place == 'photos.album', mode.edit == 'masks'), the grammar
of commands. Hidden, it keeps reducing events; only its drawing
is skipped. A clause that does not parse keeps it hidden and is
reported when it is added (indicator-when).
Sourcepub fn during(self, frame: &FrameSpec) -> Self
pub fn during(self, frame: &FrameSpec) -> Self
Shows it only while a frame of the context stack is on: its
clause (FrameSpec::clause: the top place, or the mode on in
its group), so a frame’s own status items need no clause written
by hand.
Sourcepub fn applies(&self, cx: &WhenContext) -> bool
pub fn applies(&self, cx: &WhenContext) -> bool
Whether its clause holds over the context keys (always without one; never when it does not parse).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Indicator
impl !RefUnwindSafe for Indicator
impl !Send for Indicator
impl !Sync for Indicator
impl Unpin for Indicator
impl UnsafeUnpin for Indicator
impl !UnwindSafe for Indicator
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> 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