Skip to main content

TrayIconData

Struct TrayIconData 

Source
#[repr(C)]
pub struct TrayIconData { pub id: AzString, pub title: AzString, pub icon: TrayIconSource, pub attention_icon: TrayIconSource, pub tooltip: OptionString, pub category: TrayCategory, pub status: TrayStatus, pub menu: OptionMenu, }
Expand description

Everything a tray icon shows.

This is state: set it, mutate it, and the backend republishes. It is deliberately not a set of imperative calls, because the Linux backend has to be able to answer the panel’s GetLayout at any moment.

Fields§

§id: AzString

Stable identifier for this app’s tray item. Used as SNI’s Id, and as the seed for macOS’s NSStatusItem.autosaveName (which is what makes the item keep its position in the menu bar across launches).

Must be stable across runs and must NOT be derived from a path or pid. Reverse-DNS is the convention: "org.example.myapp".

§title: AzString

Human-readable application name (SNI Title).

§icon: TrayIconSource

Where the icon’s pixels come from - a named icon-pack entry (preferred) or explicit RGBA bitmaps.

§attention_icon: TrayIconSource

Shown when status == NeedsAttention on SNI hosts. Ignored elsewhere.

§tooltip: OptionString§category: TrayCategory§status: TrayStatus§menu: OptionMenu

The retained context menu. None means “no menu”: on Windows and macOS a context-menu request then just reports TrayEventType::ContextMenu, and on Linux the Menu property is left unset and hosts fall back to calling ContextMenu().

Implementations§

Source§

impl TrayIconData

Source

pub fn new(id: AzString, title: AzString) -> Self

Source

pub fn with_named_icon(self, spec: AzString) -> Self

Use an icon from the icon registry, by the same spec an <icon> node takes - "settings", "mypack:logo", or a fallback list. Preferred: it renders at whatever size each platform asks for.

Source

pub fn with_icon(self, icon: TrayIconImage) -> Self

Use an explicit RGBA bitmap. Prefer Self::with_named_icon unless the icon genuinely is not in a pack.

Source

pub fn with_menu(self, menu: Menu) -> Self

Source

pub fn with_tooltip(self, tooltip: AzString) -> Self

Source

pub fn best_icon(&self, target_px: u32) -> OptionTrayIconImage

The icon closest to target_px, preferring the smallest one that is at least target_px (upscaling a small icon looks far worse than downscaling a large one - this is why Windows’ own LoadIconMetric scales down from a larger frame rather than up). Only meaningful for TrayIconSource::Rgba; a Named icon is rasterized at the exact size instead, so it never needs picking.

Returns an owned OptionTrayIconImage rather than Option<&_> because a borrow cannot cross the C ABI. The clone is one U8Vec bump.

Trait Implementations§

Source§

impl Clone for TrayIconData

Source§

fn clone(&self) -> TrayIconData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TrayIconData

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for TrayIconData

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for TrayIconData

Source§

fn eq(&self, other: &TrayIconData) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TrayIconData

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
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.