Avatar
画像を表示し、読み込めない場合はフォールバックを表示します。
デモを読み込み中…
avatar("user", "Ada Lovelace").size(40.0, 40.0).rounded(20.0)#インポート
quickgui から avatar をインポートします。
use quickgui::*;#使い方
avatar("user", "Ada Lovelace").size(40.0, 40.0).rounded(20.0)#構成
avatar::rootavatar::imageavatar::fallback
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
Avatar
ソースを見るpub fn new(root_id: impl Into<ElementId>, label: impl Into<Arc<str>>) -> SelfDeclare an avatar with the accessible name assistive technology announces.
root_idpub fn root_id(&self) -> ElementId—
labelpub fn label(&self) -> &Arc<str>—
image_idpub fn image_id(&self) -> ElementId—
fallback_idpub fn fallback_id(&self) -> ElementId—
apply_loading_statuspub fn apply_loading_status<V: 'static>( view: &mut V, cx: &mut EventContext, access: &StateAccessor<V, AvatarState>, status: AvatarLoadingStatus, now: Instant, on_loading_status_change: impl FnOnce(&mut V, AvatarLoadingStatus, &mut EventContext), ) -> bool—
Apply a load status reported by the application and notify the owner exactly once. QuickGUI decodes images on a worker pool without a per-element completion event, so the application reports the status it already knows — from its own `cx.spawn` load, an [`crate::ImageResource`] loader, or a hosted renderer — and this is the `onLoadingStatusChange` counterpart: the retained status changes, the exact fallback deadline is re-armed, and `on_loading_status_change` runs only for a real transition. Returns whether the retained state changed.
pub fn apply_loading_status<V: 'static>( view: &mut V, cx: &mut EventContext, access: &StateAccessor<V, AvatarState>, status: AvatarLoadingStatus, now: Instant, on_loading_status_change: impl FnOnce(&mut V, AvatarLoadingStatus, &mut EventContext), ) -> boolソースを見るschedulepub fn schedule<V: 'static>(cx: &mut ViewContext<'_, V>, state: &AvatarState)—
Ask for the one repaint an armed fallback deadline needs. Call this while rendering. A settled avatar requests nothing, so the window stays asleep.
pub fn schedule<V: 'static>(cx: &mut ViewContext<'_, V>, state: &AvatarState)ソースを見るAvatar::root_with
ソースを見るpub fn root_with(&self, root: Element) -> ElementDecorate an application-owned root without adding layout or appearance. The root carries the whole avatar's Image role and accessible name, so swapping between the image and the fallback never changes what is announced.
Avatar::root
ソースを見るpub fn root(&self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
Avatar::image_with
ソースを見るpub fn image_with(&self, image: Element) -> ElementDecorate the application-owned image without adding appearance. Pass a [`crate::img`] built from the caller's own source. Mount it only while [`AvatarState::shows_image`] is true; the part is hidden from assistive technology because the root already names the avatar.
Avatar::image
ソースを見るpub fn image(&self) -> ElementCreate the unstyled image part. Use [`Self::image_with`] to supply an existing element.
Avatar::fallback_with
ソースを見るpub fn fallback_with(&self, fallback: Element) -> ElementDecorate the application-owned fallback without adding appearance. Mount it only while [`AvatarState::shows_fallback`] is true.
Avatar::fallback
ソースを見るpub fn fallback(&self) -> ElementCreate the unstyled fallback part. Use [`Self::fallback_with`] to supply an existing element.
avatar
ソースを見るpub fn avatar(id: impl Into<ElementId>, label: impl Into<Arc<str>>) -> ElementCreate an unstyled avatar root. This shorthand is equivalent to `Avatar::new(id, label).root_with(div())`.
