pub struct ImageWidget {
pub source: ImageSource,
pub fit: ImageFit,
pub width: f32,
pub height: f32,
pub placeholder_color: Color,
pub alt: Option<String>,
}Expand description
A widget that renders an image from a file path or raw bytes.
Falls back to a colored placeholder when the image cannot be decoded.
Fields§
§source: ImageSource§fit: ImageFit§width: f32§height: f32§placeholder_color: Color§alt: Option<String>Accessible/SEO alt text (D107/Phase 25) — None produces no
semantics entry at all (an image with no .alt(...) call is
decorative, matching HTML’s own convention of an empty/absent
alt attribute), not an empty-string placeholder.
Implementations§
Source§impl ImageWidget
impl ImageWidget
Sourcepub fn asset(self, name: impl AssetRef) -> Self
pub fn asset(self, name: impl AssetRef) -> Self
Load the image from a bundled asset by logical name — resolved
per-platform via rosace_core::asset (dev: assets/<name>; mobile:
the app bundle). Prefer this over file for shipped
images: it’s portable across platforms and hot-reloads under rsc dev.
ⓘ
ImageWidget::new().asset("logo.png").fit(ImageFit::Contain)Sourcepub fn placeholder_color(self, c: Color) -> Self
pub fn placeholder_color(self, c: Color) -> Self
Set the placeholder background color shown when no image is available.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageWidget
impl RefUnwindSafe for ImageWidget
impl Send for ImageWidget
impl Sync for ImageWidget
impl Unpin for ImageWidget
impl UnsafeUnpin for ImageWidget
impl UnwindSafe for ImageWidget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more