#[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: AzStringStable 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: AzStringHuman-readable application name (SNI Title).
icon: TrayIconSourceWhere the icon’s pixels come from - a named icon-pack entry (preferred) or explicit RGBA bitmaps.
attention_icon: TrayIconSourceShown when status == NeedsAttention on SNI hosts. Ignored elsewhere.
tooltip: OptionString§category: TrayCategory§status: TrayStatusThe 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
impl TrayIconData
pub fn new(id: AzString, title: AzString) -> Self
Sourcepub fn with_named_icon(self, spec: AzString) -> Self
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.
Sourcepub fn with_icon(self, icon: TrayIconImage) -> Self
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.
pub fn with_tooltip(self, tooltip: AzString) -> Self
Sourcepub fn best_icon(&self, target_px: u32) -> OptionTrayIconImage
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
impl Clone for TrayIconData
Source§fn clone(&self) -> TrayIconData
fn clone(&self) -> TrayIconData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more