Commit Graph

331 Commits

Author SHA1 Message Date
Emil Ernerfeldt 449678e617
Update to glow 0.13 (#3715) 2023-12-18 15:15:20 +01:00
Fredrik Fornwall 8e5959d55d
Update to winit 0.29 (#3649)
* Closes https://github.com/emilk/egui/issues/3542
* Closes https://github.com/emilk/egui/issues/2977
* Closes https://github.com/emilk/egui/issues/3303

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-12-18 14:53:14 +01:00
dependabot[bot] 60f46f7c40
Bump zerocopy from 0.7.21 to 0.7.31 (#3707)
Bumps [zerocopy](https://github.com/google/zerocopy) from 0.7.21 to
0.7.31.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/google/zerocopy/releases">zerocopy's
releases</a>.</em></p>
<blockquote>
<h2>v0.7.30</h2>
<h2>What's Changed</h2>
<ul>
<li>[policies] Document yanking policy by <a
href="https://github.com/joshlf"><code>@​joshlf</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/677">google/zerocopy#677</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/680">google/zerocopy#680</a></li>
<li>[readme] Link to GitHub Releases (<a
href="https://redirect.github.com/google/zerocopy/issues/692">#692</a>)
by <a href="https://github.com/joshlf"><code>@​joshlf</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/693">google/zerocopy#693</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/google/zerocopy/compare/v0.7.29...v0.7.30">https://github.com/google/zerocopy/compare/v0.7.29...v0.7.30</a></p>
<h2>v0.7.29</h2>
<h2>What's Changed</h2>
<ul>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/664">google/zerocopy#664</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/668">google/zerocopy#668</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/669">google/zerocopy#669</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/670">google/zerocopy#670</a></li>
<li>Implement <code>TryFromBytes</code> for <code>[T]</code> by <a
href="https://github.com/jswrenn"><code>@​jswrenn</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/666">google/zerocopy#666</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/673">google/zerocopy#673</a></li>
<li>[derive] Fix AsBytes for <code>#[repr(C, packed(N))]</code> by <a
href="https://github.com/maurer"><code>@​maurer</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/672">google/zerocopy#672</a></li>
<li>Release 0.7.29 by <a
href="https://github.com/joshlf"><code>@​joshlf</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/676">google/zerocopy#676</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/google/zerocopy/compare/v0.7.28...v0.7.29">https://github.com/google/zerocopy/compare/v0.7.28...v0.7.29</a></p>
<h2>v0.7.28</h2>
<h2>What's Changed</h2>
<ul>
<li>Improve <code>transmute*!</code> documentation by <a
href="https://github.com/jswrenn"><code>@​jswrenn</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/661">google/zerocopy#661</a></li>
<li>Improve <code>AsBytes</code> documentation by <a
href="https://github.com/jswrenn"><code>@​jswrenn</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/660">google/zerocopy#660</a></li>
<li>[docs] Fix typo in include_value! doc comment by <a
href="https://github.com/joshlf"><code>@​joshlf</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/662">google/zerocopy#662</a></li>
<li>Release 0.7.28 by <a
href="https://github.com/joshlf"><code>@​joshlf</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/663">google/zerocopy#663</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/google/zerocopy/compare/v0.7.27...v0.7.28">https://github.com/google/zerocopy/compare/v0.7.27...v0.7.28</a></p>
<h2>v0.7.27</h2>
<h2>What's Changed</h2>
<ul>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/618">google/zerocopy#618</a></li>
<li>Safety comments quote new bit validity guarantees by <a
href="https://github.com/joshlf"><code>@​joshlf</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/462">google/zerocopy#462</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/621">google/zerocopy#621</a></li>
<li>[CI] Bump github/codeql-action from 2.22.6 to 2.22.7 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/622">google/zerocopy#622</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/623">google/zerocopy#623</a></li>
<li>[CI] Bump step-security/harden-runner from 2.6.0 to 2.6.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/625">google/zerocopy#625</a></li>
<li>[ci] Roll pinned stable toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/624">google/zerocopy#624</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/626">google/zerocopy#626</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/628">google/zerocopy#628</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/629">google/zerocopy#629</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/631">google/zerocopy#631</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/634">google/zerocopy#634</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/635">google/zerocopy#635</a></li>
<li>[CI] Bump github/codeql-action from 2.22.7 to 2.22.8 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/google/zerocopy/pull/636">google/zerocopy#636</a></li>
<li>[ci] Roll pinned nightly toolchain by <a
href="https://github.com/google-pr-creation-bot"><code>@​google-pr-creation-bot</code></a>
in <a
href="https://redirect.github.com/google/zerocopy/pull/637">google/zerocopy#637</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/google/zerocopy/blob/main/CHANGELOG.md">zerocopy's
changelog</a>.</em></p>
<blockquote>
<h1>Changelog</h1>
<h2>Releases</h2>
<p>We track releases and release notes using <a
href="https://github.com/google/zerocopy/releases">GitHub
Releases</a>.</p>
<h2>Yanks and Regressions</h2>
<h3>0.7.27, 0.7.28</h3>
<p>These versions were briefly yanked due to a non-soundness regression
reported in
<a
href="https://redirect.github.com/google/zerocopy/issues/672">#672</a><a
href="https://redirect.github.com/google/zerocopy/pull/672">pull-672</a>.
After reconsidering our yanking policy in <a
href="https://redirect.github.com/google/zerocopy/issues/679">#679</a><a
href="https://redirect.github.com/google/zerocopy/issues/679">issue-679</a>,
we un-yanked these versions.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="7d3a8f9ea6"><code>7d3a8f9</code></a>
Fix soundness hole in Ref::into_ref and into_mut (<a
href="https://redirect.github.com/google/zerocopy/issues/721">#721</a>)</li>
<li><a
href="961612f110"><code>961612f</code></a>
[readme] Link to GitHub Releases (<a
href="https://redirect.github.com/google/zerocopy/issues/692">#692</a>)
(<a
href="https://redirect.github.com/google/zerocopy/issues/693">#693</a>)</li>
<li><a
href="449b78c67f"><code>449b78c</code></a>
[ci] Roll pinned nightly toolchain (<a
href="https://redirect.github.com/google/zerocopy/issues/680">#680</a>)</li>
<li><a
href="8f7d88b90e"><code>8f7d88b</code></a>
[policies] Document yanking policy (<a
href="https://redirect.github.com/google/zerocopy/issues/677">#677</a>)</li>
<li><a
href="5b76223e0e"><code>5b76223</code></a>
Release 0.7.29 (<a
href="https://redirect.github.com/google/zerocopy/issues/676">#676</a>)</li>
<li><a
href="941c83fb4c"><code>941c83f</code></a>
[derive] Fix AsBytes for <code>#[repr(C, packed(N))]</code> (<a
href="https://redirect.github.com/google/zerocopy/issues/672">#672</a>)</li>
<li><a
href="d18d233cf4"><code>d18d233</code></a>
[ci] Roll pinned nightly toolchain (<a
href="https://redirect.github.com/google/zerocopy/issues/673">#673</a>)</li>
<li><a
href="ac0c27e775"><code>ac0c27e</code></a>
implement <code>TryFromBytes</code> for <code>[T]</code> (<a
href="https://redirect.github.com/google/zerocopy/issues/666">#666</a>)</li>
<li><a
href="122828ed8a"><code>122828e</code></a>
[ci] Roll pinned nightly toolchain (<a
href="https://redirect.github.com/google/zerocopy/issues/670">#670</a>)</li>
<li><a
href="980dd98f9a"><code>980dd98</code></a>
[ci] Roll pinned nightly toolchain (<a
href="https://redirect.github.com/google/zerocopy/issues/669">#669</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/google/zerocopy/compare/v0.7.21...v0.7.31">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=zerocopy&package-manager=cargo&previous-version=0.7.21&new-version=0.7.31)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/emilk/egui/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-18 09:47:20 +01:00
Emil Ernerfeldt c8dd3dd01a
Update dependencies (#3700)
Also disable `regex` `env_logger` feature in examples to improve compile
times.
2023-12-12 12:59:40 +01:00
Emil Ernerfeldt b1721a3ce7
Release `egui_extras` 0.24.2 - Fix `Table` scrolling bug (#3691)
Includes:
* https://github.com/emilk/egui/pull/3690

---------

Co-authored-by: Antoine Beyeler <49431240+abey79@users.noreply.github.com>
2023-12-08 10:32:06 +01:00
Emil Ernerfeldt d17613c242 Release 0.24.1 - Bug fixes 2023-11-30 17:46:25 +01:00
Emil Ernerfeldt 4b1523ad51
eframe glow backend: Clear render target before calling `App::update` (#3665)
* Closes https://github.com/emilk/egui/issues/3659
2023-11-30 16:37:16 +01:00
Emil Ernerfeldt a1f3c71b7f
Remove dependency on `tts` (#3651)
We were using [`tts`](https://github.com/ndarilek/tts-rs) for the
web-only screen reader. This was overkill, to say the least. It is now
replaced with ten lines of `web-sys` calls.
2023-11-28 10:46:18 +01:00
Emil Ernerfeldt 8494cf854c
Update to wasm-bindgen 0.2.89 (#3644)
0.2.88 was recently yanked
2023-11-27 18:33:07 +01:00
Emil Ernerfeldt bd087ffb8d Release 0.24.0 - Multi-viewport 2023-11-23 15:56:46 +01:00
Emil Ernerfeldt 63e48dc855
Introduce global `zoom_factor` (#3608)
* Closes https://github.com/emilk/egui/issues/3602

You can now zoom any egui app by pressing Cmd+Plus, Cmd+Minus or Cmd+0,
just like in a browser. This will change the current `zoom_factor`
(default 1.0) which is persisted in the egui memory, and is the same for
all viewports.
You can turn off the keyboard shortcuts with `ctx.options_mut(|o|
o.zoom_with_keyboard = false);`

`zoom_factor` can also be explicitly read/written with
`ctx.zoom_factor()` and `ctx.set_zoom_factor()`.

This redefines `pixels_per_point` as `zoom_factor *
native_pixels_per_point`, where `native_pixels_per_point` is whatever is
the native scale factor for the monitor that the current viewport is in.

This adds some complexity to the interaction with winit, since we need
to know the current `zoom_factor` in a lot of places, because all egui
IO is done in ui points. I'm pretty sure this PR fixes a bunch of subtle
bugs though that used to be in this code.

`egui::gui_zoom::zoom_with_keyboard_shortcuts` is now gone, and is no
longer needed, as this is now the default behavior.

`Context::set_pixels_per_point` is still there, but it is recommended
you use `Context::set_zoom_factor` instead.
2023-11-22 20:34:51 +01:00
Emil Ernerfeldt 1bbd5a9fc8
Update puffin to 0.18 (#3600)
THe profiling macros now contain unsafe code (but in a safe way), so
`#[foribd(unsafe)]` had to become `#[deny(unsafe)]`
2023-11-21 17:58:33 +01:00
Emil Ernerfeldt e823491240
Update some crate dependencies (#3594)
Nothing major
2023-11-21 16:07:56 +01:00
Emil Ernerfeldt 7bfaf49636
Update to puffin 0.17 (#3581) 2023-11-19 21:28:42 +01:00
Konkitoman 83aa3109d3
Multiple viewports/windows (#3172)
* Closes #1044

---
(new PR description written by @emilk)

## Overview
This PR introduces the concept of `Viewports`, which on the native
eframe backend corresponds to native OS windows.

You can spawn a new viewport using `Context::show_viewport` and
`Cotext::show_viewport_immediate`.
These needs to be called every frame the viewport should be visible.

This is implemented by the native `eframe` backend, but not the web one.

## Viewport classes
The viewports form a tree of parent-child relationships.

There are different classes of viewports.

### Root vieport
The root viewport is the original viewport, and cannot be closed without
closing the application.

### Deferred viewports
These are created with `Context::show_viewport`.
Deferred viewports take a closure that is called by the integration at a
later time, perhaps multiple times.
Deferred viewports are repainted independenantly of the parent viewport.
This means communication with them need to done via channels, or
`Arc/Mutex`.

This is the most performant type of child viewport, though a bit more
cumbersome to work with compared to immediate viewports.

### Immediate viewports
These are created with `Context::show_viewport_immediate`.
Immediate viewports take a `FnOnce` closure, similar to other egui
functions, and is called immediately. This makes communication with them
much simpler than with deferred viewports, but this simplicity comes at
a cost: whenever tha parent viewports needs to be repainted, so will the
child viewport, and vice versa. This means that if you have `N`
viewports you are poentially doing `N` times as much CPU work. However,
if all your viewports are showing animations, and thus are repainting
constantly anyway, this doesn't matter.

In short: immediate viewports are simpler to use, but can waste a lot of
CPU time.

### Embedded viewports
These are not real, independenant viewports, but is a fallback mode for
when the integration does not support real viewports. In your callback
is called with `ViewportClass::Embedded` it means you need to create an
`egui::Window` to wrap your ui in, which will then be embedded in the
parent viewport, unable to escape it.


## Using the viewports
Only one viewport is active at any one time, identified wth
`Context::viewport_id`.
You can send commands to other viewports using
`Context::send_viewport_command_to`.

There is an example in
<https://github.com/emilk/egui/tree/master/examples/multiple_viewports/src/main.rs>.

## For integrations
There are several changes relevant to integrations.

* There is a [`crate::RawInput::viewport`] with information about the
current viewport.
* The repaint callback set by `Context::set_request_repaint_callback`
now points to which viewport should be repainted.
* `Context::run` now returns a list of viewports in `FullOutput` which
should result in their own independant windows
* There is a new `Context::set_immediate_viewport_renderer` for setting
up the immediate viewport integration
* If you support viewports, you need to call
`Context::set_embed_viewports(false)`, or all new viewports will be
embedded (the default behavior).


## Future work
* Make it easy to wrap child viewports in the same chrome as
`egui::Window`
* Automatically show embedded viewports using `egui::Window`
* Use the new `ViewportBuilder` in `eframe::NativeOptions`
* Automatically position new viewport windows (they currently cover each
other)
* Add a `Context` method for listing all existing viewports

Find more at https://github.com/emilk/egui/issues/3556




---

<details>
<summary>
Outdated PR description by @konkitoman
</summary>


## Inspiration
- Godot because the app always work desktop or single_window because of
embedding
- Dear ImGui viewport system

## What is a Viewport

A Viewport is a egui isolated component!
Can be used by the egui integration to create native windows!

When you create a Viewport is possible that the backend do not supports
that!
So you need to check if the Viewport was created or you are in the
normal egui context!
This is how you can do that:
```rust
if ctx.viewport_id() != ctx.parent_viewport_id() {
    // In here you add the code for the viewport context, like
    egui::CentralPanel::default().show(ctx, |ui|{
        ui.label("This is in a native window!");
    });
}else{
    // In here you add the code for when viewport cannot be created!
   // You cannot use CentralPanel in here because you will override the app CentralPanel
   egui::Window::new("Virtual Viewport").show(ctx, |ui|{
       ui.label("This is without a native window!\nThis is in a embedded viewport");
   });
}
```

This PR do not support for drag and drop between Viewports!

After this PR is accepted i will begin work to intregrate the Viewport
system in `egui::Window`!
The `egui::Window` i want to behave the same on desktop and web
The `egui::Window` will be like Godot Window

## Changes and new

These are only public structs and functions!

<details>
<summary>

## New
</summary>

- `egui::ViewportId`
- `egui::ViewportBuilder`
This is like winit WindowBuilder

- `egui::ViewportCommand`
With this you can set any winit property on a viewport, when is a native
window!

- `egui::Context::new`
- `egui::Context::create_viewport`
- `egui::Context::create_viewport_sync`
- `egui::Context::viewport_id`
- `egui::Context::parent_viewport_id`
- `egui::Context::viewport_id_pair`
- `egui::Context::set_render_sync_callback`
- `egui::Context::is_desktop`
- `egui::Context::force_embedding`
- `egui::Context::set_force_embedding`
- `egui::Context::viewport_command`
- `egui::Context::send_viewport_command_to`
- `egui::Context::input_for`
- `egui::Context::input_mut_for`
- `egui::Context::frame_nr_for`
- `egui::Context::request_repaint_for`
- `egui::Context::request_repaint_after_for`
- `egui::Context::requested_repaint_last_frame`
- `egui::Context::requested_repaint_last_frame_for`
- `egui::Context::requested_repaint`
- `egui::Context::requested_repaint_for`
- `egui::Context::inner_rect`
- `egui::Context::outer_rect`

- `egui::InputState::inner_rect`
- `egui::InputState::outer_rect`

- `egui::WindowEvent`

</details>

<details>
<summary>

## Changes
</summary>

- `egui::Context::run`
Now needs the viewport that we want to render!

- `egui::Context::begin_frame`
Now needs the viewport that we want to render!

- `egui::Context::tessellate`
Now needs the viewport that we want to render!

- `egui::FullOutput`
```diff
- repaint_after
+ viewports
+ viewport_commands
```

- `egui::RawInput`
```diff
+ inner_rect
+ outer_rect
```

- `egui::Event`
```diff
+ WindowEvent
```
</details>

### Async Viewport

Async means that is independent from other viewports!

Is created by `egui::Context::create_viewport`

To be used you will need to wrap your state in `Arc<RwLock<T>>`
Look at viewports example to understand how to use it!

### Sync Viewport

Sync means that is dependent on his parent!

Is created by `egui::Context::create_viewport_sync`

This will pause the parent then render itself the resumes his parent!

#### ⚠️ This currently will make the fps/2 for every sync
viewport

### Common

#### ⚠️ Attention

You will need to do this when you render your content
```rust
ctx.create_viewport(ViewportBuilder::new("Simple Viewport"), | ctx | {
    let content = |ui: &mut egui::Ui|{
        ui.label("Content");
    };

    // This will make the content a popup if cannot create a native window
    if ctx.viewport_id() != ctx.parent_viewport_id() {
        egui::CentralPanel::default().show(ctx, content);
    } else {
        egui::Area::new("Simple Viewport").show(ctx, |ui| {
            egui::Frame::popup(ui.style()).show(ui, content);
        });
    };
});
````

## What you need to know as egui user

### If you are using eframe

You don't need to change anything!

### If you have a manual implementation

Now `egui::run` or `egui::begin` and `egui::tessellate` will need the
current viewport id!
You cannot create a `ViewportId` only `ViewportId::MAIN`

If you make a single window app you will set the viewport id to be
`egui::ViewportId::MAIN` or see the `examples/pure_glow`
If you want to have multiples window support look at `crates/eframe`
glow or wgpu implementations!

## If you want to try this

- cargo run -p viewports

## This before was wanted to change

This will probably be in feature PR's

### egui::Window

To create a native window when embedded was set to false
You can try that in viewports example before:
[78a0ae8](78a0ae879e)

### egui popups, context_menu, tooltip

To be a native window

</details>

---------

Co-authored-by: Konkitoman <konkitoman@users.noreply.github.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Pablo Sichert <mail@pablosichert.com>
2023-11-16 11:25:05 +01:00
Andreas Reich cd46691423
Updated to latest wgpu (0.18.0) (#3505)
Tested on M1 Mac:
* native
* webgl, firefox
* webgpu, chrome

all looking normal


Updated minor ahash version because 0.8.1 got yanked. Added some deny
exceptions for now - we'll have to update winit soon to resolve glow
related cargo deny errors (not a big issue though since we don't expect
wgpu and glow backends to be used at the same time)
2023-11-11 21:58:32 +01:00
dependabot[bot] 33a034c42f
Bump rustix from 0.37.23 to 0.37.25 (#3487)
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.37.23
to 0.37.25.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="00b84d6aac"><code>00b84d6</code></a>
chore: Release rustix version 0.37.25</li>
<li><a
href="cad15a7076"><code>cad15a7</code></a>
Fixes for <code>Dir</code> on macOS, FreeBSD, and WASI.</li>
<li><a
href="df3c3a192c"><code>df3c3a1</code></a>
Merge pull request from GHSA-c827-hfw6-qwvm</li>
<li><a
href="b78aeff1a2"><code>b78aeff</code></a>
chore: Release rustix version 0.37.24</li>
<li><a
href="c0c3f01d7c"><code>c0c3f01</code></a>
Add GNU/Hurd support (<a
href="https://redirect.github.com/bytecodealliance/rustix/issues/852">#852</a>)</li>
<li><a
href="f416b6b27b"><code>f416b6b</code></a>
Fix the <code>test_ttyname_ok</code> test when /dev/stdin is
inaccessable. (<a
href="https://redirect.github.com/bytecodealliance/rustix/issues/821">#821</a>)</li>
<li><a
href="aee5b0954e"><code>aee5b09</code></a>
Downgrade dependencies and disable tests to compile under Rust
1.48.</li>
<li><a
href="6d42c38311"><code>6d42c38</code></a>
Disable MIPS in CI. (<a
href="https://redirect.github.com/bytecodealliance/rustix/issues/793">#793</a>)</li>
<li>See full diff in <a
href="https://github.com/bytecodealliance/rustix/compare/v0.37.23...v0.37.25">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rustix&package-manager=cargo&previous-version=0.37.23&new-version=0.37.25)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/emilk/egui/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-11 18:32:00 +01:00
Nolan Darilek d0ff09ac20
Update accesskit and accesskit_winit. (#3475)
* Update accesskit and accesskit_winit.

* Remove duplicated `libgtk-3-dev`

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-11-10 11:32:30 +01:00
Emil Ernerfeldt f218825d94
Update ahash 0.8.3 -> 0.8.6 (#3518)
Updating crates.io index
    Updating ahash v0.8.3 -> v0.8.6
      Adding zerocopy v0.7.21
      Adding zerocopy-derive v0.7.21
2023-11-01 17:04:48 +01:00
Clement Rey fd75adb3a0
migrate to mime_guess2 (#3456) 2023-10-11 14:24:55 +02:00
Emil Ernerfeldt 4cbe930d9a
Update ureq, plist, ron (#3446)
* Update ureq to 2.8.0

* Update ron and plist
2023-10-07 19:12:27 +02:00
Emil Ernerfeldt d975c1a401
Fix HTTP web demo (#3407)
* Revert ttf-parser from 0.19.2 to 0.19.1

0.19.2's doesn't work with wasm in debug builds

* Update to poll-promise 0.3.0

* Publish new web demo

* Fix typo in changelog

* Explain why image_viewer is not part of the official web demo app

* Fix typos

* Make rfd native-only dependency
2023-09-28 12:06:55 +02:00
Emil Ernerfeldt 5a0186fa2b Release 0.23.0 - New image API 2023-09-28 08:44:33 +02:00
Emil Ernerfeldt a9272e0e55
Update dependencies in Cargo.lock (#3401)
* Update to ehttp 0.3.1 with better error messages

* Explain why we are using an old cocoa

* cargo update

❯ cargo update
    Updating crates.io index
    Updating accesskit v0.11.0 -> v0.11.2
    Updating accesskit_consumer v0.15.0 -> v0.15.2
    Updating accesskit_macos v0.7.0 -> v0.9.0
    Updating accesskit_unix v0.5.0 -> v0.5.2
    Updating accesskit_windows v0.14.0 -> v0.14.3
    Updating accesskit_winit v0.14.0 -> v0.14.4
    Updating addr2line v0.19.0 -> v0.21.0
    Removing ahash v0.7.6
    Updating aho-corasick v1.0.1 -> v1.1.1
      Adding allocator-api2 v0.2.16
    Updating android-activity v0.4.1 -> v0.4.3
      Adding android-tzdata v0.1.1
    Updating anyhow v1.0.71 -> v1.0.75
    Updating arboard v3.2.0 -> v3.2.1
    Updating arrayvec v0.7.2 -> v0.7.4
    Updating async-channel v1.8.0 -> v1.9.0
    Updating async-executor v1.5.1 -> v1.5.3
      Adding async-fs v1.6.0
    Updating async-lock v2.7.0 -> v2.8.0
      Adding async-process v1.8.0
    Updating async-recursion v1.0.4 -> v1.0.5
      Adding async-signal v0.2.1
    Updating async-task v4.4.0 -> v4.4.1
    Updating async-trait v0.1.68 -> v0.1.73
      Adding atomic-waker v1.1.2
    Updating backtrace v0.3.67 -> v0.3.69
      Adding base64 v0.21.4
    Updating bindgen v0.65.1 -> v0.68.1
    Updating bitflags v2.3.1 -> v2.4.0
      Adding blocking v1.4.0
    Updating bumpalo v3.13.0 -> v3.14.0
    Updating bytemuck v1.13.1 -> v1.14.0
    Updating bytemuck_derive v1.4.1 -> v1.5.0
    Updating bytes v1.4.0 -> v1.5.0
    Updating calloop v0.10.5 -> v0.10.6
    Updating cc v1.0.79 -> v1.0.83
    Updating cfg-expr v0.15.1 -> v0.15.5
    Updating chrono v0.4.24 -> v0.4.31
    Updating cocoa-foundation v0.1.1 -> v0.1.2
    Updating concurrent-queue v2.2.0 -> v2.3.0
    Updating core-graphics-types v0.1.1 -> v0.1.2
    Updating cpufeatures v0.2.7 -> v0.2.9
    Updating crossbeam-utils v0.8.15 -> v0.8.16
      Adding deranged v0.3.8
    Removing dirs v4.0.0
    Removing dirs-sys v0.3.7
    Updating dlib v0.5.0 -> v0.5.2
    Updating dyn-clone v1.0.11 -> v1.0.14
    Updating either v1.8.1 -> v1.9.0
    Updating enum-map v2.5.0 -> v2.6.3
    Updating enum-map-derive v0.11.0 -> v0.14.0
    Updating enumflags2 v0.7.7 -> v0.7.8
    Updating enumflags2_derive v0.7.7 -> v0.7.8
    Updating enumn v0.1.8 -> v0.1.12
      Adding equivalent v1.0.1
    Updating errno v0.3.1 -> v0.3.3
      Adding event-listener v3.0.0
    Updating fancy-regex v0.7.1 -> v0.11.0
      Adding fastrand v2.0.1
      Adding fdeflate v0.3.0
    Updating flate2 v1.0.25 -> v1.0.27
    Updating form_urlencoded v1.1.0 -> v1.2.0
    Updating getrandom v0.2.9 -> v0.2.10
    Updating gimli v0.27.2 -> v0.28.0
    Updating glutin v0.30.8 -> v0.30.10
    Updating glutin_egl_sys v0.5.0 -> v0.5.1
    Updating gpu-descriptor v0.2.3 -> v0.2.4
    Updating gpu-descriptor-types v0.1.1 -> v0.1.2
      Adding hashbrown v0.14.0
    Updating hermit-abi v0.3.1 -> v0.3.3
    Updating iana-time-zone v0.1.56 -> v0.1.57
    Updating idna v0.3.0 -> v0.4.0
    Updating image v0.24.6 -> v0.24.7
      Adding indexmap v2.0.0
    Updating io-lifetimes v1.0.10 -> v1.0.11
    Updating is-terminal v0.4.7 -> v0.4.9
    Updating itoa v1.0.6 -> v1.0.9
    Updating libc v0.2.144 -> v0.2.148
      Adding linux-raw-sys v0.4.7
    Updating lock_api v0.4.9 -> v0.4.10
    Updating log v0.4.17 -> v0.4.20
    Updating memchr v2.5.0 -> v2.6.3
      Adding memoffset v0.7.1
    Updating miniz_oxide v0.6.2 -> v0.7.1
    Updating mio v0.8.6 -> v0.8.8
      Adding nix v0.26.4
    Updating num-traits v0.2.15 -> v0.2.16
      Adding num_enum v0.6.1
      Adding num_enum_derive v0.6.1
    Updating object v0.30.3 -> v0.32.1
    Updating once_cell v1.17.1 -> v1.18.0
    Updating orbclient v0.3.45 -> v0.3.46
    Updating os_str_bytes v6.5.0 -> v6.5.1
    Updating parking v2.1.0 -> v2.1.1
    Updating parking_lot_core v0.9.7 -> v0.9.8
    Updating paste v1.0.12 -> v1.0.14
    Updating percent-encoding v2.2.0 -> v2.3.0
    Updating pin-project-lite v0.2.9 -> v0.2.13
      Adding piper v0.2.1
    Updating plist v1.4.0 -> v1.5.0
    Updating png v0.17.7 -> v0.17.10
    Updating prettyplease v0.2.5 -> v0.2.15
    Updating proc-macro2 v1.0.58 -> v1.0.67
    Updating profiling v1.0.8 -> v1.0.11
    Updating quick-xml v0.26.0 -> v0.29.0
    Updating quote v1.0.27 -> v1.0.33
    Updating regex v1.8.2 -> v1.9.5
      Adding regex-automata v0.3.8
    Removing regex-syntax v0.6.29
    Removing regex-syntax v0.7.2
      Adding regex-syntax v0.7.5
    Updating ron v0.8.0 -> v0.8.1
    Removing rustix v0.37.19
      Adding rustix v0.37.23
      Adding rustix v0.38.14
    Updating rustls v0.20.8 -> v0.21.7
      Adding rustls-webpki v0.100.3
      Adding rustls-webpki v0.101.6
    Updating ryu v1.0.13 -> v1.0.15
    Updating scopeguard v1.1.0 -> v1.2.0
    Updating serde v1.0.163 -> v1.0.188
    Updating serde_derive v1.0.163 -> v1.0.188
    Updating serde_json v1.0.96 -> v1.0.107
    Updating serde_repr v0.1.12 -> v0.1.16
    Updating serde_spanned v0.6.2 -> v0.6.3
    Updating sha1 v0.10.5 -> v0.10.6
    Updating shlex v1.1.0 -> v1.2.0
      Adding signal-hook-registry v1.4.1
      Adding simd-adler32 v0.3.7
    Updating siphasher v0.3.10 -> v0.3.11
    Updating slab v0.4.8 -> v0.4.9
    Updating smallvec v1.10.0 -> v1.11.1
    Updating smithay-client-toolkit v0.16.0 -> v0.16.1
    Updating strict-num v0.1.0 -> v0.1.1
    Updating syn v2.0.16 -> v2.0.37
    Updating syntect v5.0.0 -> v5.1.0
    Updating system-deps v6.1.0 -> v6.1.1
    Updating target-lexicon v0.12.7 -> v0.12.11
    Updating tempfile v3.5.0 -> v3.8.0
    Updating termcolor v1.2.0 -> v1.3.0
    Updating thiserror v1.0.40 -> v1.0.49
    Updating thiserror-impl v1.0.40 -> v1.0.49
    Removing time v0.1.45
    Removing time v0.3.21
      Adding time v0.3.29
    Updating time-core v0.1.1 -> v0.1.2
    Updating time-macros v0.2.9 -> v0.2.15
    Updating toml v0.7.4 -> v0.7.8
    Updating toml_datetime v0.6.2 -> v0.6.3
    Updating toml_edit v0.19.9 -> v0.19.15
    Updating tracing-attributes v0.1.24 -> v0.1.26
    Updating ttf-parser v0.19.0 -> v0.19.2
    Updating tts v0.25.5 -> v0.25.6
    Updating typenum v1.16.0 -> v1.17.0
    Updating unicode-ident v1.0.8 -> v1.0.12
    Updating unicode-width v0.1.10 -> v0.1.11
    Updating ureq v2.6.2 -> v2.7.1
    Updating url v2.3.1 -> v2.4.1
    Updating waker-fn v1.1.0 -> v1.1.1
    Updating walkdir v2.3.3 -> v2.4.0
    Removing wasi v0.10.0+wasi-snapshot-preview1
    Updating wasm-bindgen-futures v0.4.36 -> v0.4.37
    Updating webbrowser v0.8.10 -> v0.8.11
    Removing webpki v0.22.1
    Updating webpki-roots v0.22.6 -> v0.23.1
    Updating which v4.4.0 -> v4.4.2
    Updating winapi-util v0.1.5 -> v0.1.6
      Adding windows v0.51.1
      Adding windows-core v0.51.1
    Updating windows-implement v0.44.0 -> v0.48.0
    Updating windows-interface v0.44.0 -> v0.48.0
    Updating windows-targets v0.48.0 -> v0.48.5
    Updating windows_aarch64_gnullvm v0.48.0 -> v0.48.5
    Updating windows_aarch64_msvc v0.48.0 -> v0.48.5
    Updating windows_i686_gnu v0.48.0 -> v0.48.5
    Updating windows_i686_msvc v0.48.0 -> v0.48.5
    Updating windows_x86_64_gnu v0.48.0 -> v0.48.5
    Updating windows_x86_64_gnullvm v0.48.0 -> v0.48.5
    Updating windows_x86_64_msvc v0.48.0 -> v0.48.5
    Updating winnow v0.4.6 -> v0.5.15
      Adding xdg-home v1.0.0
    Updating xml-rs v0.8.15 -> v0.8.19
    Updating zbus v3.10.0 -> v3.14.1
    Updating zbus_macros v3.10.0 -> v3.14.1
    Updating zbus_names v2.5.1 -> v2.6.0
    Updating zvariant v3.14.0 -> v3.15.0
    Updating zvariant_derive v3.14.0 -> v3.15.0

❯ cargo update -p ureq --precise 2.6.2
    Updating crates.io index
 Downgrading rustls v0.21.7 -> v0.20.9
    Removing rustls-webpki v0.100.3
    Removing rustls-webpki v0.101.6
 Downgrading ureq v2.7.1 -> v2.6.2
      Adding webpki v0.22.1
 Downgrading webpki-roots v0.23.1 -> v0.22.6

❯ cargo update -p plist --precise 1.4.0
    Updating crates.io index
 Downgrading plist v1.5.0 -> v1.4.0
 Downgrading quick-xml v0.29.0 -> v0.26.0

❯ cargo update -p ron --precise 0.8.0
    Updating crates.io index
    Removing base64 v0.21.4
 Downgrading ron v0.8.1 -> v0.8.0

* Remove unnecessary mut

* Silence over-eager clippy

* Add misisng `'static` lifetime to `run_simple_native`

* ❯ cargo update -p android-activity --precise 0.4.1

    Updating crates.io index
 Downgrading android-activity v0.4.2 -> v0.4.1
    Removing num_enum v0.6.1
    Removing num_enum_derive v0.6.1
2023-09-27 12:49:24 +02:00
Emil Ernerfeldt dff52eddfd
README.md: new images, better text (#3392)
* Update images in README.md

* Add ferris image to hello_world example

* Clean up and improve README.md, with top-level link to Rerun

* Move sections around
2023-09-26 21:17:43 +02:00
Emil Ernerfeldt 23ce4e70ca
Add option to show a callstack to the widget under the mouse (#3391) 2023-09-26 15:50:35 +02:00
Emil Ernerfeldt 5e785ae00a
Add syntax highlighing feature to `egui_extras` (#3333)
* Add syntax highlighing feature to egui_extras

Enable "syntect" feature for great syntax highlighting of any language.

If not a simple fallback is used that works fine for C++, Rust, Python

* Check --no-default-features of egui_extras on CI

* spelling

* Fix building egui_extras without additional features
2023-09-13 20:39:40 +02:00
Jan Procházka 2bc6814acc
Improved texture loading (#3315)
* rework loading around `Arc<Loaders>`

* use `Bytes` instead of splitting api

* remove unwraps in `texture_handle`

* make `FileLoader` optional under `file` feature

* hide http load error stack trace from UI

* implement image fit

* support more image sources

* center spinner if we know size ahead of time

* allocate final size for spinner

* improve image format guessing

* remove `ui.image`, `Image`, add `RawImage`

* deprecate `RetainedImage`

* `image2` -> `image`

* add viewer example

* update `examples/image` + remove `svg` and `download_image` exapmles

* fix lints and tests

* fix doc link

* add image controls to `images` example

* add more `From` str-like types

* add api to forget all images

* fix max size

* do not scale original size unless necessary

* fix doc link

* add more docs for `Image` and `RawImage`

* make paint_at `pub`

* update `ImageButton` to use new `Image` API

* fix double rendering

* `SizeHint::Original` -> `Scale` + remove `Option` wrapper

* Update crates/egui/src/load.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* remove special `None` value for `forget`

* Update crates/egui/src/load.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* add more examples to `ui.image` + add `include_image` macro

* Update crates/egui/src/ui.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* update `menu_image_button` to use `ImageSource`

* `OrderedFloat::get` -> `into_inner`

* derive `Eq` on `SizedTexture`

* add `id` to loaders + `is_installed` check

* move `images` to demo + simplify `images` example

* log trace when installing loaders

* fix lint

* fix doc link

* add more documentation

* more `egui_extras::loaders` docs

* Update examples/images/src/main.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* update `images` example screenshots + readme

* remove unused `rfd` from `images` example

* Update crates/egui_extras/src/loaders/ehttp_loader.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* add `must_use` on `Image` and `RawImage`

* document `loaders::install` multiple call safety

* Update crates/egui_extras/Cargo.toml

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* reshuffle `is_loader_installed`

* make `include_image` produce `ImageSource` + update docs

* update `include_image` docs

* remove `None` mentions from loader `forget`

* inline `From` texture id + size for `SizedTexture`

* add warning about statically known path

* change image load error + use in image button

* add `.size()` to `Image`

* Update crates/egui_demo_app/Cargo.toml

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* add explanations to image viewer ui

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-12 10:39:17 +02:00
Jan Procházka ec671e754f
Managed texture loading (#3297)
* add types from proposal

* add load methods on `egui::Context`

* implement loaders from proposal in `egui_extras`

* impl `From<Vec2>` for `SizeHint`

* re-export `SizeHint` from `egui` root

* rework `svg` example to use new managed `Image`

* split loaders into separate files + add logging

* add `log_trace`

* clean up `RetainedImage` from `svg` example

* refactor ehttp loader response to bytes mapping

* remove spammy trace

* load images even without extension

* fix lints

* remove unused imports

* use `Image2` in `download_image`

* use `visuals.error_fg_color` in `Image2` error state

* update lockfile

* use `Arc<ColorImage>` in `ImageData` + add `forget` API

* add `ui.image2`

* add byte size query api

* use iterators to sum loader byte sizes

* add static image loading

* use static image in `svg` example

* small refactor of `Image2::ui` texture loading code

* add `ImageFit` to size images properly

* remove println calls

* add bad image load to `download_image` example

* add loader file extension support tests

* fix lint errors in `loaders`

* remove unused `poll-promise` dependency

* add some docs to `Image2`

* add some docs to `egui_extras::loaders::install`

* explain `loaders::install` in examples

* fix lint

* upgrade `ehttp` to `0.3` for some crates

* Remove some unused dependencies

* Remove unnecessary context clone

* Turn on the `log` create feature of egui_extras in all examples

* rename `forget` and document it

* derive `Debug` on `SizeHint`

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* round when converting SizeHint from vec2

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* add `load` module docs

* docstring `add_loader` methods

* expose + document `load_include_bytes`

* cache texture handles in `DefaultTextureLoader`

* add `image2` doctest + further document `Image2`

* use `Default` for default `Image2` options

* update `image2` doc comment

* mention immediate-mode safety

* more fit calculation into inherent impl

* add hover text on spinner

* add `all-loaders` feature

* clarify `egui_extras::loaders::install` behavior

* explain how to enable image formats

* properly format `uri`

* use `thread::Builder` instead of `spawn`

* use eq op instead of `matches`

* inline `From<Arc<ColorImage>>` for `ImageData`

* allow non-`'static` bytes + `forget` in `DefaultTextureLoader`

* sort features

* change `ehttp` feature to `http`

* update `Image2` docs

* refactor loader cache type

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-06 10:51:51 +02:00
Emil Ernerfeldt 707ca04c08
Add opt-in `puffin` feature to `egui-extras` (#3307)
* Add opt-in `puffin` feature to `egui-extras`

Image loading can be slow.

Related to https://github.com/emilk/egui/pull/3297

* Silence warning
2023-09-05 14:11:29 +02:00
Emil Ernerfeldt 67168be069
Improve clippy, and add more docs (#3306)
* Silence a few clippy warnings

* Use named threads

* Remove some deprecated functions

* Document Context and Ui fully

* Use `parking_lot::Mutex` in `eframe`

* Expand clippy.toml files

* build fix
2023-09-05 14:11:22 +02:00
Emil Ernerfeldt 436996b79e
Update web-time to 0.2 (#3308) 2023-09-05 14:11:07 +02:00
Emil Ernerfeldt b9f9cab914
Update webpki 0.22.0 -> 0.22.1 (#3305) 2023-09-05 13:03:37 +02:00
Emil Ernerfeldt 9e86bb8d6a
Add opt-in `puffin` feature to egui (#3298)
* Add opt-in `puffin` feature to egui

* fix web build

* Fix web for realz
2023-09-04 15:01:22 +02:00
Emil Ernerfeldt 209cbeb030
Replace instant with web_time (#3296) 2023-09-04 09:37:35 +02:00
Emil Ernerfeldt 7b169ec13d
Break out plotting to own crate `egui_plot` (#3282)
This replaces `egui::plot` with the new crate `egui_plot`
2023-08-27 17:22:49 +02:00
Aaron Hill 98087029e0
Update to `wgpu` 0.17.0 (#3170)
* Bump `wgpu` to 0.17.0
This required bumping wasm-bindgen to 0.2.87
* cargo deny exception for `foreign-types`
* sort deny.toml
* Add fragile-send-sync-non-atomic-wasm feature to wgpu
* cargo deny: ignore children of foreign-types

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-08-11 17:10:10 +02:00
Emil Ernerfeldt f78db80840
Update to wasm-bindgen 0.2.87 (#3237)
* Update to wasm-bindgen 0.2.87

Required by the new `wgpu` version

* Catch unknown arguments to build_demo_web.sh
2023-08-11 15:34:16 +02:00
Emil Ernerfeldt dd5285cccb
Support multi-threaded Wasm (#3236)
Replace `atomic_refcell` with `parking_lot` on wasm32.

`parking_lot` has had problems running on wasm32 before
(https://github.com/emilk/egui/issues/1401)
but it works these days.
If we have problems again we can always switch to `std::sync::Mutex`.

Closes https://github.com/emilk/egui/issues/3102
2023-08-11 15:08:00 +02:00
hacknus 871041c4e7
Added an example to save plot to image (#2769)
* implement save_plot

* fix for check.sh

* clippy

* add save_plot to Cargo.lock

* adapted for PR #2676 (removes unsafe code)

* add some comments

* implemented the comments from emilk

* update comments in code

* rustfmt

* remove picked_path

* add more comments

* removed unused import

* use `inner.response.rect` as the plot position

* remove plot_location from MyApp members

* sort entries

* Update examples/save_plot/src/main.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* use env_logger instead of tracing subscriber

* use env_logger instead of tracing subscriber and combine if let

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-08-10 12:35:11 +02:00
dependabot[bot] 387b075681
Bump xml-rs from 0.8.13 to 0.8.15 (#3145)
Bumps [xml-rs](https://github.com/kornelski/xml-rs) from 0.8.13 to 0.8.15.
- [Changelog](https://github.com/kornelski/xml-rs/blob/main/Changelog.md)
- [Commits](https://github.com/kornelski/xml-rs/compare/0.8.13...0.8.15)

---
updated-dependencies:
- dependency-name: xml-rs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-09 11:15:37 +02:00
Emil Ernerfeldt 083d61fccd
Update to puffin 0.16 (#3144) 2023-07-10 12:29:01 +02:00
τ 073f49682d
Expose Raw Window and Display Handles (#3073)
* Expose raw window and display handles in eframe

* Ensure that no one implements `Clone` in the future

* Cleanup

---------

Co-authored-by: Matti Virkkunen <mvirkkunen@gmail.com>
2023-06-11 22:18:28 +02:00
Emil Ernerfeldt 307565efa5 Release 0.22.0 - A plethora of small improvements 2023-05-23 19:58:04 +02:00
Emil Ernerfeldt 8c5d235bfb
cargo update (#3018)
* cargo update

    Updating crates.io index
    Updating ab_glyph v0.2.20 -> v0.2.21
    Updating aho-corasick v0.7.20 -> v1.0.1
    Updating android-activity v0.4.0 -> v0.4.1
    Updating anyhow v1.0.69 -> v1.0.71
    Updating arrayref v0.3.6 -> v0.3.7
    Updating async-broadcast v0.5.0 -> v0.5.1
    Updating async-executor v1.5.0 -> v1.5.1
    Updating async-io v1.12.0 -> v1.13.0
    Updating async-lock v2.6.0 -> v2.7.0
    Updating async-recursion v1.0.2 -> v1.0.4
    Updating async-task v4.3.0 -> v4.4.0
    Updating async-trait v0.1.64 -> v0.1.68
    Updating atomic_refcell v0.1.9 -> v0.1.10
      Adding base64 v0.21.1
    Updating bindgen v0.64.0 -> v0.65.1
    Updating bitflags v2.1.0 -> v2.3.1
    Updating block-buffer v0.10.3 -> v0.10.4
    Updating bumpalo v3.12.0 -> v3.13.0
    Updating bytemuck v1.13.0 -> v1.13.1
    Updating bytemuck_derive v1.4.0 -> v1.4.1
    Updating cfg-expr v0.11.0 -> v0.15.1
    Updating chrono v0.4.23 -> v0.4.24
    Updating ciborium v0.2.0 -> v0.2.1
    Updating ciborium-io v0.2.0 -> v0.2.1
    Updating ciborium-ll v0.2.0 -> v0.2.1
    Updating clang-sys v1.4.0 -> v1.6.1
    Updating clap v3.2.23 -> v3.2.25
    Updating cocoa-foundation v0.1.0 -> v0.1.1
    Updating concurrent-queue v2.1.0 -> v2.2.0
    Updating core-foundation-sys v0.8.3 -> v0.8.4
    Updating cpufeatures v0.2.5 -> v0.2.7
    Updating crossbeam-utils v0.8.14 -> v0.8.15
    Removing cxx v1.0.89
    Removing cxx-build v1.0.89
    Removing cxxbridge-flags v1.0.89
    Removing cxxbridge-macro v1.0.89
    Updating digest v0.10.6 -> v0.10.7
    Updating dyn-clone v1.0.10 -> v1.0.11
    Updating enum-map v2.4.2 -> v2.5.0
    Updating enumn v0.1.6 -> v0.1.8
    Removing errno v0.2.8
    Updating fastrand v1.8.0 -> v1.9.0
      Adding fdeflate v0.3.0
    Updating flate2 v1.0.25 -> v1.0.26
    Updating futures-core v0.3.26 -> v0.3.28
    Updating futures-io v0.3.26 -> v0.3.28
    Updating futures-lite v1.12.0 -> v1.13.0
    Updating futures-sink v0.3.26 -> v0.3.28
    Updating futures-task v0.3.26 -> v0.3.28
    Updating futures-util v0.3.26 -> v0.3.28
    Updating generic-array v0.14.6 -> v0.14.7
    Updating getrandom v0.2.8 -> v0.2.9
    Updating gimli v0.27.1 -> v0.27.2
    Updating glutin v0.30.4 -> v0.30.8
    Updating glutin_egl_sys v0.4.0 -> v0.5.0
    Updating gpu-alloc v0.5.3 -> v0.5.4
      Adding home v0.5.5
    Updating iana-time-zone v0.1.53 -> v0.1.56
    Updating iana-time-zone-haiku v0.1.1 -> v0.1.2
    Updating image v0.24.5 -> v0.24.6
    Updating indexmap v1.9.2 -> v1.9.3
    Updating io-lifetimes v1.0.6 -> v1.0.10
    Updating itoa v1.0.5 -> v1.0.6
    Updating jni v0.20.0 -> v0.21.1
    Updating jobserver v0.1.25 -> v0.1.26
    Updating js-sys v0.3.61 -> v0.3.63
    Updating libc v0.2.139 -> v0.2.144
    Removing link-cplusplus v1.0.8
    Removing linux-raw-sys v0.1.4
    Removing linux-raw-sys v0.3.2
      Adding linux-raw-sys v0.3.8
    Updating memmap2 v0.5.8 -> v0.5.10
      Adding miniz_oxide v0.7.1
    Updating mio v0.8.5 -> v0.8.6
    Updating naga v0.12.0 -> v0.12.1
    Removing nom8 v0.2.0
    Updating num_enum v0.5.9 -> v0.5.11
    Updating num_enum_derive v0.5.9 -> v0.5.11
    Updating objc2 v0.3.0-beta.3 -> v0.3.0-beta.3.patch-leaks.3
    Updating once_cell v1.17.0 -> v1.17.1
    Updating orbclient v0.3.42 -> v0.3.45
    Updating ordered-stream v0.1.4 -> v0.2.0
    Updating os_str_bytes v6.4.1 -> v6.5.0
    Updating owned_ttf_parser v0.18.1 -> v0.19.0
    Updating parking v2.0.0 -> v2.1.0
    Updating paste v1.0.11 -> v1.0.12
    Updating pkg-config v0.3.26 -> v0.3.27
    Updating plist v1.4.0 -> v1.4.3
    Updating png v0.17.7 -> v0.17.8
    Updating polling v2.5.2 -> v2.8.0
      Adding prettyplease v0.2.5
    Updating proc-macro-crate v1.3.0 -> v1.3.1
    Updating proc-macro2 v1.0.56 -> v1.0.58
    Updating profiling v1.0.7 -> v1.0.8
    Updating puffin v0.14.2 -> v0.14.3
    Updating quick-xml v0.26.0 -> v0.28.2
    Updating quote v1.0.26 -> v1.0.27
    Updating range-alloc v0.1.2 -> v0.1.3
    Updating redox_syscall v0.3.4 -> v0.3.5
    Updating regex v1.7.1 -> v1.8.2
    Removing regex-syntax v0.6.28
      Adding regex-syntax v0.6.29
      Adding regex-syntax v0.7.2
    Updating rfd v0.11.0 -> v0.11.4
    Updating rgb v0.8.35 -> v0.8.36
    Updating rustc-demangle v0.1.21 -> v0.1.23
    Removing rustix v0.36.9
    Removing rustix v0.37.3
      Adding rustix v0.37.19
    Updating ruzstd v0.3.0 -> v0.3.1
    Updating ryu v1.0.12 -> v1.0.13
    Removing scratch v1.0.3
    Updating sctk-adwaita v0.5.3 -> v0.5.4
    Updating serde v1.0.152 -> v1.0.163
    Updating serde_derive v1.0.152 -> v1.0.163
    Updating serde_json v1.0.92 -> v1.0.96
    Updating serde_repr v0.1.10 -> v0.1.12
      Adding serde_spanned v0.6.2
      Adding simd-adler32 v0.3.5
    Updating slab v0.4.7 -> v0.4.8
    Updating socket2 v0.4.7 -> v0.4.9
    Removing syn v1.0.107
    Removing syn v2.0.15
      Adding syn v1.0.109
      Adding syn v2.0.16
    Updating system-deps v6.0.3 -> v6.1.0
      Adding target-lexicon v0.12.7
    Updating tempfile v3.4.0 -> v3.5.0
    Updating thiserror v1.0.38 -> v1.0.40
    Updating thiserror-impl v1.0.38 -> v1.0.40
    Updating time v0.3.17 -> v0.3.21
    Updating time-core v0.1.0 -> v0.1.1
    Updating time-macros v0.2.6 -> v0.2.9
    Updating tiny-skia v0.8.3 -> v0.8.4
    Updating tiny-skia-path v0.8.3 -> v0.8.4
    Updating toml v0.5.11 -> v0.7.4
    Updating toml_datetime v0.5.1 -> v0.6.2
    Updating toml_edit v0.18.1 -> v0.19.9
    Updating tracing-attributes v0.1.23 -> v0.1.24
    Updating tracing-core v0.1.30 -> v0.1.31
    Updating ttf-parser v0.18.1 -> v0.19.0
    Updating tts v0.25.0 -> v0.25.5
    Updating unicode-bidi v0.3.10 -> v0.3.13
    Updating unicode-ident v1.0.6 -> v1.0.8
    Updating walkdir v2.3.2 -> v2.3.3
    Updating wasm-bindgen-futures v0.4.34 -> v0.4.36
    Updating web-sys v0.3.61 -> v0.3.63
    Updating webbrowser v0.8.7 -> v0.8.10
    Removing wepoll-ffi v0.1.2
    Updating windows v0.43.0 -> v0.48.0
    Removing windows-sys v0.42.0
    Updating windows-targets v0.42.1 -> v0.42.2
    Updating windows_aarch64_gnullvm v0.42.1 -> v0.42.2
    Updating windows_aarch64_msvc v0.42.1 -> v0.42.2
    Updating windows_i686_gnu v0.42.1 -> v0.42.2
    Updating windows_i686_msvc v0.42.1 -> v0.42.2
    Updating windows_x86_64_gnu v0.42.1 -> v0.42.2
    Updating windows_x86_64_gnullvm v0.42.1 -> v0.42.2
    Updating windows_x86_64_msvc v0.42.1 -> v0.42.2
    Updating winit v0.28.1 -> v0.28.6
      Adding winnow v0.4.6
    Updating xml-rs v0.8.4 -> v0.8.13
    Updating zbus v3.9.0 -> v3.10.0
    Updating zbus_macros v3.9.0 -> v3.10.0
    Updating zbus_names v2.5.0 -> v2.5.1
    Updating zstd-sys v2.0.6+zstd.1.5.2 -> v2.0.8+zstd.1.5.5
    Updating zvariant v3.10.0 -> v3.14.0
    Updating zvariant_derive v3.10.0 -> v3.14.0
      Adding zvariant_utils v1.0.1

* Downgrade flate2 and png to avoid duplicated deps

* downgrade plist to avoid duplication of base64 crate

* Allow license `Apache-2.0 WITH LLVM-exception`

* Update to puffin 0.15
2023-05-23 09:25:39 +02:00
Emil Ernerfeldt b758e9dbf0
Update accesskit to 0.11 (#3012)
* Update accesskit to 0.11

* Add instructions on how to test the web viewer to CONTRIBUTING.md

Also removed dependency on `jq`

Closes https://github.com/emilk/egui/issues/2859
2023-05-22 19:20:58 +02:00
Emil Ernerfeldt 856afc8f7e
Update wasm-bindgen to 0.2.86 (#2995) 2023-05-17 11:08:35 +02:00
Emil Ernerfeldt ea71b7f20b
eframe web: detect and report panics during startup (#2992)
* Detect panics during initialization and show them to the user

* PanicHandler now also logs the panics

* Add example of how to call into your app from JS

* Refactor: break out AppRunner and AppRunnerRef to own files

* Hide AppRunner

* Simplify user code

* AppRunnerRef -> WebRunner

* Better docs

* Don't paint until first animation frame

* Update multiple_apps.html

* Update web demo

* Cleanup and fixes

* left-align panic message in html
2023-05-16 22:22:09 +02:00
Andreas Reich f76eefb98d
[wgpu] Expose wgpu::Adapter via RenderState (#2954)
* [wgpu] Expose adapter, better errors, better docs, more code sharing, use stencil bits

* doc fix

* remove unnecessary unsafe

* handle missing framebuffer format

* better handling of renderstate creation in winit.rs

* remove unnecessary use directive
2023-04-25 17:42:13 +02:00
Andreas Reich 0e6d69d4c4
Make egui work on WebGPU out of the box. (#2945)
* Make wgpu webgl/gles opt-in (but still work out of the box via feature flag), workaround canvas creation issue

* missing allow unsafe code annotations

* add breaking change not to eframe release notes

* Add --webgpu flag to build_demo_web.sh

* Improve CHANGELOG docs

* Clean up, and prepare for having to wasm:s

* put canvas without workaround under `if false`

* fix spelling

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-04-24 11:26:45 +02:00