Commit graph

2482 commits

Author SHA1 Message Date
Emil Ernerfeldt
2771c8c3e5 Fix doclinks 2022-05-28 18:09:08 +02:00
Benedikt Terhechte
72e38370fe
Add flag to disable hardware acceleration (#1681)
This is a fix for the behaviour on macOS platforms where any egui app would use the dedicated GPU and consume more power than needed. Not all apps might have dedicated GPU requirements.
2022-05-28 17:53:05 +02:00
Zicklag
1d9524cc59
Re-implement PaintCallbacks With Support for WGPU (#1684)
* Re-implement PaintCallbacks With Support for WGPU

This makes breaking changes to the PaintCallback system, but makes it
flexible enough to support both the WGPU and glow backends with custom
rendering.

Also adds a WGPU equivalent to the glow demo for custom painting.
2022-05-28 17:52:36 +02:00
Emil Ernerfeldt
8173093c67 run cargo check --locked on CI
This ensures the Cargo.lock is up-to-date in PR:s
2022-05-28 17:32:59 +02:00
sy1ntexx
f5cca2a288
Added support for 20 fn keys (#1665) 2022-05-23 17:49:48 +02:00
Emil Ernerfeldt
f2dcdfc22c Fix some broken doc links 2022-05-23 17:25:31 +02:00
Robert Bragg
a5076d4cc4
egui_winit/wgpu: enable Android support (#1634)
* egui-winit: don't assume window available at init

On Android in particular we can only initialize render state once we
have a native window, after a 'Resumed' lifecycle event. It's still
practical to be able to initialize an egui_winit::State early on
so this adds setters for the max_texture_side and pixels_per_point
that can be called once we have a valid Window and have initialized
a graphics context.

On Wayland, where we need to access the Display for clipboard handling
we now get the Display from the event loop instead of a window.

* egui-wgpu: lazily initialize render + surface state

Enable the renderer and surface state initialization to be deferred
until we know that any winit window we created has a valid native window
and enable the surface state to be updated in case the native window
changes.

In particular these changes help with running on Android where winit
windows will only have a valid native window associated with them
between Resumed and Paused lifecycle events, and so surface creation
(and render state initialization) needs to wait until the first
Resumed event, and the surface needs to be dropped/recreated based on
Paused/Resumed events.
2022-05-22 20:24:41 +02:00
Emil Ernerfeldt
fff2008255 Move three-d patch into example Cargo.tom 2022-05-22 18:14:00 +02:00
Sebastian Urban
b2510676b9
Take Glow context using Arc. (#1640)
This allows usage with a Glow context that is passed between threads.
2022-05-22 17:43:30 +02:00
Emil Ernerfeldt
a29154233b Add support for texture filters in WGPU backend 2022-05-22 17:40:56 +02:00
Florian Diebold
5d15e3d367
egui-wgpu: Add ability to register user textures (#1660) 2022-05-22 17:32:54 +02:00
Emil Ernerfeldt
cc148ca895 Add texture filters to changelogs and improve docs 2022-05-22 17:32:38 +02:00
Zicklag
1a9a0d7ec8
Add the Ability to Specify Egui Texture Filters (#1636)
Only works for egui_glow
2022-05-22 16:56:51 +02:00
Emil Ernerfeldt
f3e305a646 Replace TODO: with TODO(emilk): and update code guidelines 2022-05-21 16:53:25 +02:00
Emil Ernerfeldt
3d5e203d86
egui_glow: clear the post-processing render target (#1658) 2022-05-21 16:53:05 +02:00
Emil Ernerfeldt
32ad9c29be Use better names in glow::Painter 2022-05-21 16:03:26 +02:00
Emil Ernerfeldt
aef8a7901f Fix broken link
Closes https://github.com/emilk/egui/issues/1643
2022-05-21 15:42:43 +02:00
Emil Ernerfeldt
d6fd5dec3b
Add single-threaded deadlock detection to RwMutex (#1619) 2022-05-21 14:08:19 +02:00
Emil Ernerfeldt
810b609a80 clippy fixes 2022-05-21 13:04:58 +02:00
Emil Ernerfeldt
934fcd7e99 Add hex_color clipboard fixes to changelogs 2022-05-21 13:04:58 +02:00
Sebastian Urban
5687aa6b50
Request GLSL version 3.30. (#1639) 2022-05-21 12:52:20 +02:00
griffi-gh
27cca111c8
Fix wrong name in egui-wgpu CHANGELOG.md (#1645) 2022-05-21 12:49:37 +02:00
Emil Ernerfeldt
f807a290a4 Release egui-wgpu 0.18.0 2022-05-16 16:39:26 +02:00
Erlend Walstad
f27f67b76b
Make color-hex optional (#1632) 2022-05-16 16:38:14 +02:00
Antti Keränen
b8a5924295
Fix clipboard on Wayland (#1613)
arboard advertises that it works with Wayland, but in reality it only
works with Wayland terminal applications. To make the clipboard work
with applications that draw Wayland surfaces, arboard isn't going to
work.

Copypasta does support Wayland's graphical clipboard, but the usage
isn't documented. However, for the reasons mentioned in #1474 the move
from Copypasta to arboard makes sense.

To resolve the issue, this commit brings in an optional dependency
smithay-clipboard, that is a crate that correctly handles the Wayland
clipboard in graphical applications. It is used by default if a Wayland
window handle is found. If for some reason the handle to the Wayland
window handle cannot be fetched, arboard is used as a backup.
2022-05-16 16:37:41 +02:00
Stanislav
b008b147e5
Fix Plot auto_bounds when LinkedAxisGroup one axis (#1599)
Co-authored-by: Stanislav <enomado@users.noreply.github.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-05-15 19:27:30 +02:00
Emil Ernerfeldt
0389ce68e2
CI: Run cargo check --all-features on Windows and Mac too (#1631) 2022-05-15 19:25:24 +02:00
Luke Newcomb
d2decfa338
Add ability to convert from a hex string to Color32 using macros (#1596) 2022-05-15 17:07:30 +02:00
TicClick
3c685d7bf6
eframe: read native window position and size (#1617)
Position and dimensions are available via `eframe::Frame::info().window_info`
2022-05-13 10:15:43 +02:00
Emil Ernerfeldt
aef5942d0f Make egui_demo_app the default binary, so cargo run just works 2022-05-12 13:30:35 +02:00
Emil Ernerfeldt
2e4138d050
Add InputState::stable_dt (#1625)
This provides a better estimate of a typical frametime in reactive mode.

From the docstring of `stable_dt`:

Time since last frame (in seconds), but gracefully handles the first frame after sleeping in reactive mode.

In reactive mode (available in e.g. `eframe`), `egui` only updates when there is new input or something animating.
This can lead to large gaps of time (sleep), leading to large [`Self::unstable_dt`].

If `egui` requested a repaint the previous frame, then `egui` will use
`stable_dt = unstable_dt;`, but if `egui` did not not request a repaint last frame,
then `egui` will assume `unstable_dt` is too large, and will use
`stable_dt = predicted_dt;`.

This means that for the first frame after a sleep,
`stable_dt` will be a prediction of the delta-time until the next frame,
and in all other situations this will be an accurate measurement of time passed
since the previous frame.

Note that a frame can still stall for various reasons, so `stable_dt` can
still be unusually large in some situations.

When animating something, it is recommended that you use something like
`stable_dt.min(0.1)` - this will give you smooth animations when the framerate is good
(even in reactive mode), but will avoid large jumps when framerate is bad,
and will effectively slow down the animation when FPS drops below 10.
2022-05-12 11:23:53 +02:00
Emil Ernerfeldt
931e716b97
Add egui_wgpu crate (#1564)
Based on https://github.com/hasenbanck/egui_wgpu_backend

`egui-wgpu` is now an official backend for `eframe` (opt-in).

Use the `wgpu` feature flag on `eframe` and the `NativeOptions::renderer` settings to pick it.

Co-authored-by: Nils Hasenbanck <nils@hasenbanck.de>
Co-authored-by: Sven Niederberger <niederberger@embotech.com>
Co-authored-by: Sven Niederberger <73159570+s-nie@users.noreply.github.com>
2022-05-12 09:02:28 +02:00
4JX
3d52cc8867
Fix docstring in area.rs (#1620) 2022-05-11 22:44:29 +02:00
sy1ntexx
d850b47f9e
Added Extra1 & Extra2 pointer buttons (#1603)
Extra1 is usually extra back button on most mice & Extra2 is usually extra forward button.
2022-05-11 22:44:00 +02:00
Emil Ernerfeldt
9624de6c41
Fix dead-lock when alt-tabbing while also showing a tooltip (#1618)
Closes https://github.com/emilk/egui/issues/1609
2022-05-11 20:56:57 +02:00
4JX
c47e20c733
Allow manually painting the CollapsingState icon (#1592)
* Allow manually painting the CollapsingState icon

* Update egui/src/containers/collapsing_header.rs

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

* Oops

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-05-11 19:02:37 +02:00
Luke Newcomb
e44c9b8e54
Fix image button padding on hover (#1595) 2022-05-11 11:58:15 +02:00
Emil Ernerfeldt
7b18fab7a4
Optimize tessellation of filled circles (#1616)
When painting a scatter plot we sometimes want to paint hundreds of thousands of points (filled circles) on screen every frame.

In this PR the font texture atlas is pre-populated with some filled circled of various radii. These are then used when painting (small) filled circled, which means A LOT less triangles and vertices are generated for them.

In a new benchmark we can see a 10x speedup in circle tessellation, but the the real benefit comes in the painting of these circles: since we generate a lot less vertices, the backend painter has less to do.

In a real-life scenario with a lot of things being painted (including around 100k points) I saw tessellation go from 35ms -> 7ms and painting go from 45ms -> 1ms. This means the total frame time went from 80ms to 8ms, or a 10x speedup.
2022-05-10 19:31:19 +02:00
Emil Ernerfeldt
28efc0e1c8 emath: Implement NumExt on all integer types 2022-05-09 12:44:28 +02:00
Emil Ernerfeldt
d69ce546fa Release egui_glow 0.18.1 - remove unnecessary calls to gl.get_error 2022-05-09 12:43:37 +02:00
Nigecat
87ca29173d
Fix typo in ui.rs (waker -> weaker) (#1586) 2022-05-06 10:36:49 +02:00
Alejandro Perea
fe6e1ce28f
Add *_released & *_clicked PointerState methods (#1582) 2022-05-05 23:26:15 +02:00
Emil Ernerfeldt
e82b87ca73
Remove calls to gl.getError in release builds (#1583)
This slows down the web version a lot, especially on some browsers

Publish new web demo
2022-05-05 23:17:33 +02:00
carrotflakes
cb2298e98b
Fix CircleShape::visual_bounding_rect() (#1575) 2022-05-05 09:16:00 +02:00
Reilly Moore
1dd014cbed
mark the response of a toggle_value as changed on click (#1573) 2022-05-04 21:45:14 +02:00
René Rössler
d3af3a6de1
egui_extras date picker: fix Feb 29 crash (#1571) 2022-05-04 19:30:41 +02:00
Emil Ernerfeldt
32b4781da2
Improve web demo for mobile (#1556)
`egui_demo_app/lib`: add "About egui" window, and improve mobile layout

This makes the app responsive, removing the side bars on mobile and turning them into drop-down menus instead.
2022-05-02 13:13:35 +02:00
Emil Ernerfeldt
078be52ff8 README.md: Fix broken links to toggle_switch.rs example code 2022-05-01 15:27:12 +02:00
Emil Ernerfeldt
b30224471c
Release 0.18.1 of egui & epaint - Change Shape::Callback to &mut dyn Any (#1552) 2022-05-01 11:35:29 +02:00
Emil Ernerfeldt
dc26890a80 Release 0.18.0 - Shape::Callback, Table, and better text contrast 2022-04-30 20:27:27 +02:00