Commit graph

49 commits

Author SHA1 Message Date
Emil Ernerfeldt
eca5e6a4d2
Update to Rust 1.65 (#2314)
* Update to Rust 1.65

Because then you can use dynamic linking on Linux

* Fix a bunch of clippy lints

* Update changelogs

* More clippy fixes
2022-11-16 19:08:03 +01:00
Clement Rey
f7019926dc
wgpu backend: do not try to render zero-sized surfaces (#2313)
* wgpu backend: do not try to render zero-sized surfaces

* reverse if

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-11-16 18:03:57 +01:00
Emil Ernerfeldt
9268f43896
eframe: make RequestRepaintEvent into an enum UserEvent (#2311)
Preparation for https://github.com/emilk/egui/pull/2294
to make that a smaller diff.
2022-11-16 12:17:41 +01:00
LoganDark
f0f41d60e1
eframe: Don't show window until after initialization (#2279)
* Don't show window until after initialization

Shortens #1802, but does not completely solve it

* format code

* Present first frame immediately before showing window

This resolves the white flash almost completely, but is a hack. Window
visibility should be derived from the AppOutput, and the first frame
should not be painted before the event loop has processed initial
events.

Working on a better implementation.

* Integrate window showing with AppOutput

This allows an app to keep the window hidden (never shown) by calling
Frame.set_visible(false) on the first update. This includes a slightly
less nasty hack than the last commit did.

Also fixes an accidental cross-contamination of pull requests.

* fmt

* add comments

* add comments

* add comments

* add comments

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-11-13 20:30:52 +01:00
LoganDark
5bac853d9c
eframe: Repaint immediately on RepaintAsap, fixes #903 (#2280)
* eframe: Repaint immediately on RepaintAsap, fixes #903

This completely eliminates the white flickering seen on Windows when
rapidly resizing a window on the glow backend. The reason that happens
is because DWM only waits for the resize event to be delivered before
displaying the window at its new size. You must repaint synchronously
inside that iteration of the event loop or else you get flickering.

* Differentiate between RepaintAsap and RepaintNext

RepaintNext looks like it is indeed needed in at least one case instead
of RepaintAsap.

* Use RepaintNext in more situations

Starting to understand why this was the behavior. It looks like only a
few special cases should be given RepaintAsap, such as the window being
resized. All other cases should be RepaintNext, as it can wait.

Using RepaintAsap in all situations will cause things like lag when
changing a slider by keyboard with a high key repeat rate.

* Add explanatory comments

I am a total hypocrite for forgetting to add these.

* Rename RepaintAsap to RepaintNow

There is no notion of "possibility" here like there is when waiting for
RedrawEventsCleared. RepaintNow causes an immediate repaint no matter
what.

* Fix RepaintNow comment

"Delays" is ambiguous.
2022-11-13 20:30:39 +01:00
Red Artist
8ff139687a
bump msrv 1.64 and tts + bindgen dep (#2274)
* bump msrv 1.64 and tts + bindgen dep

* Update crates/egui-winit/Cargo.toml

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

* Update crates/eframe/Cargo.toml

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

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-11-11 10:27:25 +01:00
Emil Ernerfeldt
e225c6b8d0 Opt-in logging of egui-wgpu using puffin 2022-11-10 16:28:08 +01:00
Emil Ernerfeldt
b3ab47a594 eframe: warn if web_sys_unstable_apis was not set 2022-11-07 14:00:00 +01:00
Emil Ernerfeldt
8c76b8caff
Update op puffin 0.14.0 (#2257) 2022-11-07 12:37:37 +01:00
Emil Ernerfeldt
eec18290a4
eframe: make sure to update native_pixels_per_point when dpi changes (#2256)
* eframe: make sure to update native_pixels_per_point when dpi changes

* Update changelog
2022-11-07 12:36:17 +01:00
Emil Ernerfeldt
e48602059d
Update ahash to 0.8.1 (#2255) 2022-11-07 09:23:45 +01:00
Emil Ernerfeldt
a0b3f1126b
Add helpers for zooming an app using Ctrl+Plus and Ctrl+Minus (#2239)
* Using tracing-subscriber in hello_world example

* Add Key::Plus/Minus/Equals

* Warn if failing to guess OS from User-Agent

* Remove jitter when using Context::set_pixels_per_point

* Demo app: zoom in/out using ⌘+ and ⌘-

* Demo app: make backend panel GUI scale slider better

* Optimize debug builds a bit

* typo

* Update changelog

* Add helper module `egui::gui_zoom` for zooming an app

* Better names, and update changelog

* Combine Plus and Equals keys

* Last fix

* Fix docs
2022-11-05 11:18:13 +01:00
Mikhail Sheldyakov
25718f2774
fix comment for WebOptions follow_system_theme (#2233) 2022-11-05 09:20:53 +01:00
Clement Rey
fcb00723bc
wgpu: add support for user-level command buffers + viewport clarification (#2230)
* wgpu: add support for user-level command buffers
* updated wgpu demo app
2022-11-04 09:54:29 +01:00
ItsEthra
4d1e858a52
Use total_cmp for clamping drag value in order to avoid floating point ambiguities (#2213)
* Use total_cmp for clamping DragValue

* Added test for clamping

* Increase MSRV in all crates

* Increased rust version for github actions and lib.rs

* Inversed ranges are now working properply with clamp_to_range

* Added more tests
2022-11-02 19:38:39 +01:00
Andreas Reich
4c82519fb8
configurable wgpu backend (#2207)
* introduce new wgpu configuration option to allow configuring wgpu renderer

* use new options with wgpu web painter

* use on_surface_error callback

* changelog update

* cleanup

* changelog and comment fixes
2022-10-31 17:57:32 +01:00
Emil Ernerfeldt
02b9d2d082
Keyboard shortcut helpers (#2202)
* eframe web: Add WebInfo::user_agent

* Deprecate `Modifier::ALT_SHIFT`

* Add code for formatting Modifiers and Key

* Add type KeyboardShortcut

* Code cleanup

* Add Context::os/set_os to query/set what OS egui believes it is on

* Add Fonts::has_glyph(s)

* Add helper function for formatting keyboard shortcuts

* Faster code

* Add way to set a shortcut text on menu buttons

* Cleanup

* format_keyboard_shortcut -> format_shortcut

* Add TODO about supporting more keyboard sumbols

* Modifiers::plus

* Use the new keyboard shortcuts in emark editor demo

* Explain why ALT+SHIFT is a bad modifier combo

* Fix doctest
2022-10-31 12:58:26 +01:00
Emil Ernerfeldt
2b1341095d
CI: Run cargo clippy for wasm32-unknown-unknown (#2200)
* CI: Run cargo clippy for wasm32-unknown-unknown

* wasm32 clippy fixes

* Document when AppRunner::new can fail
2022-10-30 20:55:07 +01:00
Emil Ernerfeldt
7b8c17042c eframe: Make fullsize_content mac-only 2022-10-21 08:55:56 +02:00
Andreas Reich
c414af7aa2
wgpu renderer now always requires a RenderPass being passed in, pass command encoder to prepare callback (#2136)
* wgpu renderer now always requires a RenderPass being passed in
This also implies that it no longer owns the depth buffer! (why would it anyways!)

* wgpu-renderer now passes a command encoder to prepare

* add changelog entries

* fixup changelogs, fix variable name
2022-10-12 14:27:24 +02:00
Emil Ernerfeldt
eba3927ace
Remove .with_srgb(false) when constructing window (#2110) 2022-10-08 11:43:48 +02:00
Andreas Reich
cd74c74f6f
Update to wgpu 0.14 (#2114) 2022-10-06 15:50:46 +02:00
Andreas Reich
c2a37f4bd8
eframe support for wgpu on the web (#2107)
* basic working wgpu @ webgl on websys

* fix glow compile error

* introduced WebPainter trait, provide wgpu renderstate

* WebPainterWgpu destroy implemented

* make custom3d demo work on wgpu backend

* changelog entry for wgpu support eframe wasm

* remove temporary logging hack

* stop using pollster for web
we're actually not allowed to block - this only worked because wgpu on webgl doesn't actually cause anything blocking. However, when trying webgpu this became an issue

* revert cargo update

* compile error if neither glow nor wgpu features are enabled

* code cleanup

* Error handling

* Update changelog with link

* Make sure --all-features work

* Select best framebuffer format from the available ones

* update to wasm-bindgen 0.2.83

* Fix typo

* Clean up Cargo.toml

* Log about using the wgpu painter

* fixup wgpu labels

* fix custom3d_wgpu_shader ub padding

* remove duplicated uniforms struct in wgsl shader for custom3d

* Update docs: add async/await to the web 'start' function

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-10-05 20:14:18 +02:00
Emil Ernerfeldt
77df8ca0b0
Update some crates (#2100)
* Update crate webbrowser 0.7 -> 0.8

* Update criterion 0.3 -> 0.4

* Update tts 0.20 -> 0.24

* revert tts update
2022-10-02 20:33:45 +02:00
Michael Galos
9901ad4bb0
eframe: Mouse passthrough option (#2080) 2022-10-02 08:45:37 +02:00
Emil Ernerfeldt
4ac1e28eae
Improve text redering and do all color operation in gamma space (#2071) 2022-09-24 17:53:11 +02:00
Emil Ernerfeldt
2b0bf82b51
Make eframe::App::as_any_mut optional to implement (#2061) 2022-09-20 13:58:55 +02:00
Adia Robbie
bc6a823103
eframe: Add center to NativeOptions and monitor_size to WindowInfo (#2035)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-09-17 11:20:40 +02:00
Paul Rouget
c4117066cf
MacOS: Support fullsize content (no titlebar, but window controls) (#2049)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-09-16 14:31:21 +02:00
Sheldon Nico
0605bcfca7
Add IME support for native (#2046) 2022-09-15 17:21:43 +02:00
Emil Ernerfeldt
c5495d69fb
egui-wgpu: Fix crash on zero-sized scissor rects (#2039) 2022-09-13 09:32:05 +02:00
Stanislav
ebc4fc866d
eframe web: access app from WebHandle (#1886)
Co-authored-by: Stanislav <enomado@users.noreply.github.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-09-09 08:22:46 +02:00
Emil Ernerfeldt
e0c7533ede eframe native: Make sure we only shut down once
I don't trust winit to actually exit on ControlFlow::Exit

Perhaps this will solve https://github.com/emilk/egui/issues/2027
2022-09-08 10:50:35 +02:00
Emil Ernerfeldt
1fe08bf7e4 eframe: reduce repaint log level from debug to trace 2022-09-07 16:27:53 +02:00
Emil Ernerfeldt
5500895845
eframe: make sure we save app state on Cmd-Q (#2013)
Cmd-Q emits a `winit::event::Event::LoopDestroyed` and then the app closes, without `run_return` returning (despite its name).
2022-09-06 16:07:58 +02:00
Romet Tagobert
64aac30f36
Add depth buffer support for egui-wgpu's render pass (#2002)
* add a depth texture for wgpu callbacks

* egui-wgpu: use depth from native_options

* add wgpu caveat to depth_buffer docstring
2022-09-06 14:37:07 +02:00
Adia Robbie
b43a8626cf
Add custom shader_version on glow renderer (#1993)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-09-06 10:08:16 +02:00
Emil Ernerfeldt
ac4d75e9b4
egui-winit: don't repaint when just moving window (#1980)
* Bug fix: reset repaint countdown when we pass it

* eframe: debug-print what winit event caused a repaint

* egui-winit: don't repaint when only moving window

* fix docstring
2022-08-29 11:20:19 +02:00
Emil Ernerfeldt
3142c52b94
Minor wgpu-web releated stuff (#1977)
* egui_demo_app: remove wgpu and pollster as direct dependencies

* eframe: use same web-sys version as wgpu crate

* Make note that web_sys_unstable_apis is required by the wgpu crate

* Rename the glow web painter in eframe

* Remove trait DummyWebGLConstructor from web_glow_painter.rs

* cargo fmt

* Fix check.sh
2022-08-28 10:58:58 +02:00
Emil Ernerfeldt
d5933daee5 egui_glow: allow empty (zero-sized) textures
See https://github.com/emilk/egui/issues/1960
2022-08-24 14:34:34 +02:00
Robert Bragg
fb92434aac
Android support for EFrame (#1952)
* eframe: allow hooking into EventLoop building

This enables native applications to add an `event_loop_builder` callback
to the `NativeOptions` struct that lets them modify the Winit
`EventLoopBuilder` before the final `EventLoop` is built and run.

This makes it practical for applications to change platform
specific config options that Egui doesn't need to be directly aware of.

For example the `android-activity` glue crate that supports writing
Android applications in Rust requires that the Winit event loop be
passed a reference to the `AndroidApp` that is given to the
`android_main` entrypoint for the application.

Since the `AndroidApp` itself is abstracted by Winit then there's no
real need for Egui/EFrame to have a dependency on the `android-activity`
crate just for the sake of associating this state with the event loop.

Addresses: #1951

* eframe: defer graphics state initialization until app Resumed

Conceptually the Winit `Resumed` event signifies that the application is
ready to run and render and since
https://github.com/rust-windowing/winit/pull/2331 all platforms now
consistently emit a Resumed event that can be used to initialize
graphics state for an application.

On Android in particular it's important to wait until the application
has Resumed before initializing graphics state since it won't have an
associated SurfaceView while paused.

Without this change then Android applications are likely to just show
a black screen.

This updates the Wgpu+Winit and Glow+Winit integration for eframe but
it's worth noting that the Glow integration is still not able to fully
support suspend and resume on Android due to limitations with Glutin's
API that mean we can't destroy and create a Window without also
destroying the GL context, and therefore (practically) the entire
application.

There is a plan (and progress on) to improve the Glutin API here:
https://github.com/rust-windowing/glutin/pull/1435 and with that change
it should be an incremental change to enable Android suspend/resume
support with Glow later.

In the mean time the Glow changes keep the implementation consistent
with the wgpu integration and it should now at least be possible to
start an Android application - even though it won't be able to suspend
correctly.

Fixes #1951
2022-08-23 14:43:22 +02:00
Zoxc
b9bb7baaa7
Only require something GLES 3 compatible from wgpu (#1956) 2022-08-23 14:39:01 +02:00
Emil Ernerfeldt
bd5250f85d
Disable custom 3D painting example in the egui demo app for Es100 (#1945)
Closes https://github.com/emilk/egui/issues/1944
2022-08-20 19:54:18 +02:00
Emil Ernerfeldt
97ce103209 Release 0.19.0 - wgpu backend, repaint_after, continue-after-close 2022-08-20 16:49:58 +02:00
Emil Ernerfeldt
127931ba45
eframe: rename quit/exit to "close" (#1943)
Since https://github.com/emilk/egui/pull/1919 we can continue
the application after closing the native window. It therefore makes
more sense to call `frame.close()` to close the native window,
instead of `frame.quit()`.
2022-08-20 16:08:59 +02:00
Emil Ernerfeldt
2453756782 Fix broken GitHub source links due to #1940 2022-08-20 15:18:02 +02:00
Emil Ernerfeldt
8737933101 Improve documentation and logging 2022-08-20 15:06:43 +02:00
Emil Ernerfeldt
f4cc1c5465
eframe: Don't follow system theme by default (#1941)
I have gone back and forth on this a bit, but I think the arguments
AGAINST following the system theme are many:

* `dark-light` is a big dependency with problems on Linux.
* Many people prefer the dark mode and ask how to set it as the default
  (even though they are using light mode in their OS).
* A developer may be surprised when the app changes theme when
  they run it on another computer.

So, the path of least surprise is to make this an opt-in feature
with dark mode as the default mode.

On native, you add the `dark-light` feature to enable it.
On web, you set `WebOptions::follow_system_theme`.
2022-08-20 11:11:07 +02:00
Emil Ernerfeldt
041f2e64ba
Move all crates into a crates directory (#1940) 2022-08-20 10:41:49 +02:00