mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Add Image::uri() (#4720)
`uri()` for image The advantages of this are : 1. No need for `ctx()` and `source()` 2. Displays `name.gif#0` as `name.gif`
This commit is contained in:
@@ -283,6 +283,20 @@ impl<'a> Image<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the URI of the image.
|
||||
///
|
||||
/// For GIFs, returns the URI without the frame number.
|
||||
#[inline]
|
||||
pub fn uri(&self) -> Option<&str> {
|
||||
let uri = self.source.uri()?;
|
||||
|
||||
if let Ok((gif_uri, _index)) = decode_gif_uri(uri) {
|
||||
Some(gif_uri)
|
||||
} else {
|
||||
Some(uri)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn image_options(&self) -> &ImageOptions {
|
||||
&self.image_options
|
||||
|
||||
Reference in New Issue
Block a user