Commit Graph

2849 Commits

Author SHA1 Message Date
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 8d4de866d4
Remove deprecated functions (#3692) 2023-12-08 11:02:57 +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
Antoine Beyeler d8a795598f
Fix `egui_extras::Table` scrolling bug (#3690)
`egui_extras::Table` now uses the clip rectangle to decide which rows to
draw when using `TableBody::rows()`.

- Closes #3682
- Closes #3670
2023-12-08 09:08:27 +01:00
Brian Janssen 4e75f4313e
Fix typos in viewports docs (`then` vs `than`) (#3681)
I looked through the new viewport docs and noticed these small typos.
This PR fixes them.
2023-12-05 16:38:21 +01:00
Emil Ernerfeldt a4e389431d
Simplify `egui_winit::State` (#3678)
By storing a clone of the egui context in it, we can be sure to always
use the correct `pixels_per_point`
2023-12-05 11:45:25 +01:00
Emil Ernerfeldt 80d7143b15
Log all available wgpu adapters during startup (#3671)
Useful when debugging, e.g. if the default choice is one of many, and
perhaps the other ones would be better.

**EDIT**: Oh, `enumerate_adapters` doesn't work on web… will fix.
2023-12-04 15:59:13 +01:00
Sebastian Urban 36c6b6304d
Make glow Send + Sync again. (#3646)
* Reverts #3598
* Closes #3645
2023-12-04 15:58:05 +01:00
Emil Ernerfeldt 84a6d6f2ab Fix code example in `egui_demo_lib` 2023-11-30 17:53:34 +01:00
Emil Ernerfeldt d17613c242 Release 0.24.1 - Bug fixes 2023-11-30 17:46:25 +01:00
Emil Ernerfeldt 8ccd9b73e2 Make sure `check.sh` installs all tools it uses 2023-11-30 17:45:15 +01:00
Emil Ernerfeldt be1f6cd699 Use `panic = "abort"` for slightly faster compilation 2023-11-30 17:28:33 +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 bd9bc252aa
Fix buggy text withviewports on monitors with different scales (#3666)
* Closes https://github.com/emilk/egui/issues/3664

Bonus: optimize color conversions and font atlas upload, especially in
debug builds.
2023-11-30 15:56:05 +01:00
Emil Ernerfeldt 61a7b90d5b
Improve multi-viewports across monitors with different scales (#3663)
It required some ugly code in `egui-winit` in order to fix this without
breaking sem-ver (I want this to land in a 0.24.1 patch release). I'll
clean up in time for 0.25.

There is still a font rendering bug when using immediate viewports
across multiple viewports, but that's harder to fix.
2023-11-30 12:08:53 +01:00
Vaqxai 37244e3632
egui_extras: Add more years for datepicker (#3599)
Birthdates really needed this

Kinda closes
[<https://github.com/emilk/egui/issues/3597>](https://github.com/emilk/egui/issues/3597).
2023-11-28 14:50:19 +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 e6815ae1ea
Fix windowing problems when using the `x11` feature on Linux (#3643)
This was caused by a hack added by @konkitoman in
https://github.com/emilk/egui/pull/3172

The solution was reported by @ItsEthra in
https://github.com/emilk/egui/issues/3628#issuecomment-1827943346

* Closes https://github.com/emilk/egui/issues/3620
* Closes https://github.com/emilk/egui/issues/3628
2023-11-27 18:16:02 +01:00
zeozeozeo 4dc964ab4b
eframe: Fix window flashing white on launch (#3631)
This is a bug that can occur on Windows, previously it was fixed by only
showing the window after the first frame was rendered, but the bug
appeared again with egui 0.24.0. This commit fixes this bug by making
the window invisible on startup.

## Before


![window-flash](https://github.com/emilk/egui/assets/108888572/31a675af-8c30-46b1-a1af-653491cf67da)

## After


![no-window-flash](https://github.com/emilk/egui/assets/108888572/e7bfc429-033e-4842-8591-b9229143a60b)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

Closes https://github.com/emilk/egui/issues/3625.
2023-11-27 10:35:37 +01:00
Emil Ernerfeldt 43e7b16bb1
eframe: Fix clicks in web (#3640)
Closes https://github.com/emilk/egui/issues/3633

Bug introduced in #3623 (after 0.24.0 was cut)
2023-11-27 08:37:02 +01:00
Aaron Hill fbccd3a1a2
Don't treat 'WindowEvent::CloseRequested' as consumed in egui-winit (#3627)
This appears to have been 'consumed' by the viewport changes at one
point (by updating `viewport_info`), but this is no longer the case. We
should avoid marking this as 'consumed', so that applications know to
continue processing this event after passing it to egui.

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->
2023-11-26 23:37:03 +01:00
libertyteeth 6715ed5cea
Update viewport.rs, fix comment typo: "vieweport" -> "viewport" (#3638)
No code changes.  Just fixing a typo in a comment.

Closes #3637.
2023-11-26 23:33:54 +01:00
Emil Ernerfeldt 23732be0e5
eframe web: Don't throw away frames on click/copy/cut (#3623)
* Follow-up to https://github.com/emilk/egui/pull/3621 and
https://github.com/emilk/egui/pull/3513

To work around a Safari limitation, we run the app logic in the event
handler of copy, cut, and mouse up and down.

Previously the output of that frame was discarded, but in this PR it is
now saved to be used in the next requestAnimationFrame.

The result is noticeable more distinct clicks on buttons (one more frame
of highlight)

Bonus: also fix auto-save of a sleeping web app
2023-11-24 10:08:43 +01:00
Emil Ernerfeldt 0d24a3a73b
Fix click-to-copy on Safari (#3621)
* Closes https://github.com/lampsitter/egui_commonmark/issues/21

Follow-up to https://github.com/emilk/egui/pull/3513

Safari only allows access to the clipboard as response to user action,
so we need to take an extra logic step right in the event handler.
2023-11-24 09:06:15 +01:00
Emil Ernerfeldt 79a56b3aad Add highlights to 0.24 changelog 2023-11-23 17:39:55 +01:00
Emil Ernerfeldt bd087ffb8d Release 0.24.0 - Multi-viewport 2023-11-23 15:56:46 +01:00
Emil Ernerfeldt 56a74a5247 mute warning 2023-11-23 15:52:50 +01:00
Emil Ernerfeldt e7604c0230 Update changelogs 2023-11-23 15:46:04 +01:00
Emil Ernerfeldt 38ab2d9ca7 Sort deny.toml 2023-11-23 15:45:48 +01:00
Emil Ernerfeldt dd794f253a Don't persist zoom_with_keyboard 2023-11-23 15:45:41 +01:00
Emil Ernerfeldt 185e18ad4f Improve some docs 2023-11-23 15:45:32 +01:00
Emil Ernerfeldt 6a8b51adb5 Improve demo backend panel 2023-11-23 15:45:19 +01:00
Emil Ernerfeldt 96bc34a66d Use workspace definitions of edition,license,rust-version,version 2023-11-23 15:45:11 +01:00
Emil Ernerfeldt b62676d21a Improve changelog generator: capitalize output 2023-11-23 15:42:10 +01:00
Emil Ernerfeldt 24913ceeba
Fix up some examples (#3614) 2023-11-23 12:58:44 +01:00
Emil Ernerfeldt a2b15b23ad
macOS `ViewportBuilder` tweaks (#3613) 2023-11-23 10:43:30 +01:00
Emil Ernerfeldt 85489dc1dd
Fix deadlock on `custom_window_frame` (#3612)
* Reverts commit e037489 (https://github.com/emilk/egui/pull/3601)
* Reopens https://github.com/emilk/egui/issues/3494

It caused a deadlock on Mac when running `custom_window_frame`
2023-11-23 09:22:10 +01:00
Andreas Reich f9f5db9885
PaintCallbackInfo::viewport_in_pixels now guarantees to stay in bounds (#3604)
* Fixes https://github.com/rerun-io/rerun/issues/4297
* tested against a very hasty and incomplete port of egui/trunk, found
[here](https://github.com/rerun-io/rerun/tree/andreas/experimental-egui-trunk)


In rare cases in can happen that the viewport returned by
`PaintCallbackInfo` is outside the bounds of the screen.
for at least [wgpu/webgpu in
particular](https://www.w3.org/TR/webgpu/#dom-gpurenderpassencoder-setviewport)
this is invalid usage, other backends might be affected as well.
Since this happened due to a float rounding error (in one repro case I
had I got (width==1126.5625) + (offset=715.4376) = 1842.0001 for a
resolution of 1842) I decided to do away with fractional values on the
viewport alltogether. They _technically_ make sense since a viewport is
only specifying the NDC to pixel coordinate conversion, but practically
this may lead to surprising sub-sampling issues.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-11-22 21:01:38 +01:00
Emil Ernerfeldt 6490dfafb6
Fix: fall back to default egui icon if non is set (#3610)
It broke in one of the recent multi-viewport prs
2023-11-22 20:54:16 +01:00
YgorSouza 4ece25bd05
Keep unsafe code forbidden when puffin is disabled (#3603)
This helps document what unsafe is being used for, and prevent other
uses from going unnoticed.
2023-11-22 20:37: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 ea53246c60
Refactor viewport ids in eframe (#3607)
Simplifies some things
2023-11-22 13:50:43 +01:00
Emil Ernerfeldt e037489ac2
eframe: update the maximized/minimized viewport state each frame (#3601)
* Closes https://github.com/emilk/egui/issues/3494

This makes sure it is always up-to-date.

Previously (years back) this caused a deadlock on Mac, but this seems to
have been fixed
2023-11-21 19:05:19 +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 bfadb90d42
Update MSRV to Rust 1.72 (#3595)
Required to update to puffin 0.18
2023-11-21 17:26:35 +01:00
Emil Ernerfeldt 7abf8afd16
Change `Arc<glow::Context>` to `Rc<glow::Context>` (#3598)
This is required for Rust 1.72 (for unknown reasons; see
https://github.com/emilk/egui/pull/3595), but also for updating to glow
0.13, where the `glow::Context` is not longer `Sync+Send`
2023-11-21 17:13:46 +01:00
Emil Ernerfeldt e823491240
Update some crate dependencies (#3594)
Nothing major
2023-11-21 16:07:56 +01:00
Emil Ernerfeldt 8c68035b66 Add some explanations for the safari copy/cut fix 2023-11-21 14:58:19 +01:00
Ryan Hileman a6da34339a
Fix copy and cut on Safari (#3513)
* Closes <https://github.com/emilk/egui/issues/3480>

I've tested this on Safari and Chrome on macOS Sonoma 14.0.

Could be improved to only call `event.preventDefault()` if
`runner.logic()` actually performed a copy, but I don't see a way to get
that information out with the current API.
2023-11-21 14:54:31 +01:00