Expand description
Avatar — circular (or rounded-square / square) user-identity widget.
Displays either a person’s image (clipped to the configured shape via a CPU-side anti-aliased alpha mask applied at construction time) or their initials over a hash-derived background colour. Optional presence indicator (Online / Offline / Away / Busy) and outer ring. Can be made activable to serve as a user-menu trigger.
// Image with a presence dot.
let _w = Avatar::with_image(&face)
.alt(lit!("Jane Doe"))
.presence(AvatarPresence::Online)
.size(AvatarSize::Medium);
// Hash-tinted initials, auto-derived from a name.
let _w = Avatar::with_name(lit!("Jane Doe")).size(AvatarSize::Large);
// Click target — opens a user menu via an intent.
let _w = Avatar::with_image(&face)
.label(lit!("Open user menu"))
.alt(lit!("Jane Doe"))
.on_activate_fn(|ctx| ctx.send_intent(Intent::new("app.open-user-menu")));The widget reuses ImageWidget for the image path and hands bg /
border / focus ring / presence to the active AvatarStyle, whose
default (RecipeAvatarStyle) draws them via Canvas. Hash-derived
background tints come from theme.colors.chart_palette (Okabe-Ito),
so they track the active theme automatically.
§Touch and pen
A tappable avatar activates on the release, like every other tap target.
The four shipped sizes (24 / 32 / 48 / 64 dp) already clear the 24 dp target
floor, but AvatarSize::Custom need not, so a clickable avatar declares a
Widget::hit_outset that lifts an undersized one to the density’s target —
zero for the shipped sizes, and zero for a decorative avatar, which takes no
press and must not punch a hole in what it sits on.
Structs§
- Avatar
- Circular (or rounded-square / square) user-identity widget showing either a photo or hash-tinted initials, with an optional presence dot.
Enums§
- Avatar
Corner - Where the presence dot is rendered relative to the avatar bounds.
- Avatar
Presence - Presence indicator dot drawn at one corner of the avatar.
- Avatar
Shape - Outer outline.
- Avatar
Size - Discrete avatar size variants.
Custom(px)accepts an arbitrary logical-pixel side length. The default size resolution table lives inteksilo_widgets::styles::recipe_avatar_style::avatar_pixel_size.