Skip to main content

StatusItem

Struct StatusItem 

Source
pub struct StatusItem { /* private fields */ }
Expand description

What a status item shows: its icon, text and menu. Built by the closure handed to status_item, which re-runs whenever a signal it reads changes.

Implementations§

Source§

impl StatusItem

Source

pub fn new() -> StatusItem

An item with nothing set yet.

Source

pub fn icon(self, symbol: Symbol) -> StatusItem

A platform symbol as the icon, drawn in the menu bar’s or panel’s own color.

Source

pub fn vector(self, name: impl Into<VectorName>) -> StatusItem

A bundled vector glyph as the icon (res::vectors::…), drawn as a template: the shape in the menu bar’s or panel’s own color. The usual choice for a status item.

Source

pub fn image(self, name: impl Into<ImageName>) -> StatusItem

A bundled image as the icon (res::images::…), drawn as it is. Call template for a monochrome glyph that should take the menu bar’s color instead.

Source

pub fn raster(self, image: StatusImage) -> Self

A runtime RGBA image, preserving its logical width (a chart or compact status grid). AppKit renders this in color; template opts into a monochrome template. Other backends keep using the icon/vector/image fallback, if supplied. The image owns its pixels and survives closing the window that produced it.

Source

pub fn template(self) -> StatusItem

Draw the image by its shape alone, in the menu bar’s or panel’s own color, so one glyph reads in light and dark (a macOS template image). What icon and vector already do; this opts an image or a raster in.

Source

pub fn title<M>(self, title: impl IntoText<M>) -> StatusItem

Text beside the icon where the platform shows it (the macOS menu bar): a timer, a count, a short status. A literal, a localized text, a signal or a closure; live.

Source

pub fn tooltip<M>(self, tooltip: impl IntoText<M>) -> StatusItem

The hover text. The same sources as title.

Source

pub fn menu<M>(self, entries: impl MenuContent<M>) -> StatusItem

The item’s menu, built from the same entries as app_menu (a list or a derived closure). Include a menu_role(MenuRole::Quit) (or an item calling day::quit()) in an app that keeps running without a window, or the user has no way to end it.

Source

pub fn on_activate(self, f: impl Fn() + 'static) -> StatusItem

Run f when the user clicks the item itself, where the platform tells a click apart from opening the menu (a left click on macOS and Windows; a Linux tray’s primary action). The menu then opens on a right click. Without it, any click opens the menu.

Trait Implementations§

Source§

impl Default for StatusItem

Source§

fn default() -> Self

Returns the “default value” for a type. 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
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
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.
Day API ↩ Guides· daybrite.dev