zed/crates/gpui/examples
Jason Lee 1982a5aed1
gpui: Improve img element to support load from Assets (#15482)
Release Notes:

- N/A


Currently, the `img` element provided by GPUI only supports FilePath or
URL, but in actual applications we need to let `img` load an image
embedded in Assets.

The `svg` element can currently support this, but `img` cannot.

For example:

We have such an Assets directory:

```
assets
|- icons
|- images
|--- foo.png
```

```rs
// If give a path, considered an Asset
img("images/foo.png");
// If give a URI, considered a Remote image
img("https://foo.bar/images/foo.png");
// If give a PathBuf, considered a Local file
img(PathBuf::from("path/to/foo.png"));
```


## Example test

```
cargo run -p gpui --example image 
```

<img width="827" alt="image"
src="https://github.com/user-attachments/assets/e45dcf7f-4626-4fb0-aca9-9b6e1045a952">

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-07-30 10:55:48 -04:00
..
image gpui: Improve img element to support load from Assets (#15482) 2024-07-30 10:55:48 -04:00
animation.rs gpui example: Fix SVG not showing up when running from root (#13648) 2024-06-28 15:58:19 +02:00
gif_viewer.rs gpui: Add support for animated images (#13809) 2024-07-27 14:05:37 +02:00
hello_world.rs Linux window decorations (#13611) 2024-07-03 11:28:09 -07:00
input.rs Add mouse handling to gpui input example (#14350) 2024-07-15 12:10:25 -06:00
ownership_post.rs More adjustments for blog post 2024-01-18 07:01:46 -07:00
set_menus.rs gpui: Update Menu name to use SharedString type to support more types (#14791) 2024-07-19 08:51:31 -04:00
window_positioning.rs gpui: Fix cx.bounds, cx.open_window position on macOS (#14044) 2024-07-10 09:52:33 -06:00
window_shadow.rs Linux window decorations (#13611) 2024-07-03 11:28:09 -07:00