Skip to main content

Indicator

Struct Indicator 

Source
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: String

The event names it follows (a prefix: job.).

§command: Option<CommandId>

Run on a click.

§weight: i32

Lighter first, from the end of the status bar.

§when: Option<String>

Where it shows: a when clause over the context keys (none: everywhere).

§align: Alignment

Which end of the bar it sits at.

§priority: i32

On 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

Source

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.

Source

pub fn reduce(self, f: impl Fn(&mut IndicatorState, &Event) + 'static) -> Self

How an event changes the state.

Source

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).

Source

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).

Source

pub fn weight(self, weight: i32) -> Self

Source

pub fn align(self, align: Alignment) -> Self

Which end of the bar it sits at (the end by default).

Source

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.

Source

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.

Source

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.

Source

pub fn hover( self, f: impl Fn(&IndicatorState, &AppHandle) -> Card + 'static, ) -> Self

A rich hover card (Card: formatted text, rows, live values, command links) in place of the plain tooltip (detail), built from the state each time it shows. Ctrl+K Ctrl+I opens it on the item with the keyboard focus; agents read it in status.

Source

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).

Source

pub fn initial(self, state: IndicatorState) -> Self

The state before any event.

Source

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).

Source

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.

Source

pub fn clause(&self) -> Option<Result<&When, &str>>

Its clause, parsed (None without one).

Source

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§

Source§

impl Clone for Indicator

Source§

fn clone(&self) -> Indicator

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Indicator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,