egui/crates
Jan Procházka 759c8fd2c9
Use ResizeObserver instead of `resize` event (#4536)
Currently, if the size of the canvas element changes independently of
the size of the browser window (e.g. due to its parent element
shrinking), then no repaints are scheduled.

This PR replaces the `resize` event with a `ResizeObserver`, which
ensures that _any_ resize of the canvas element (including those caused
by browser window resizes) trigger a repaint. The repaint is done
synchronously as part of the resize event, to reduce any potential
flickering.

The result seems to pass the rendering tests on most platform+browser
combinations. We tested:
- Chrome, Firefox, Safari on macOS
- Chrome, Firefox on Linux (ubuntu and arch, both running wayland)
- Chrome, Firefox on Windows

Firefox still has some antialiasing issues on Linux platforms, but this
antialiasing also happens on `master`, so this PR is not a regression
there.

The code setting `canvas.style.width` and `canvas.style.height` at the
start of `AppRunner::logic` was also removed - the canvas _display_ size
is now fully controlled by CSS, e.g. by setting `canvas { width: 100%;
height: 100%; }`.

The approach used here is described in
https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html

Note: The only remaining place where egui updates the style of the
canvas it is rendering to is some of the IME/mobile input handling code.
Fixing that is out of scope for this PR, and will be done in a followup
PR.
2024-05-27 21:41:28 +02:00
..
ecolor Move dependencies to workspace (#4495) 2024-05-14 11:02:49 +02:00
eframe Use ResizeObserver instead of `resize` event (#4536) 2024-05-27 21:41:28 +02:00
egui TextEdit hint text styling (#4517) 2024-05-27 17:28:03 +02:00
egui-wgpu Do no use the ahash reimport (#4504) 2024-05-27 16:24:50 +02:00
egui-winit Do no use the ahash reimport (#4504) 2024-05-27 16:24:50 +02:00
egui_demo_app Move dependencies to workspace (#4495) 2024-05-14 11:02:49 +02:00
egui_demo_lib Add improved pixel alignment test with alternating white/black lines (#4537) 2024-05-24 15:55:36 +02:00
egui_extras Do no use the ahash reimport (#4504) 2024-05-27 16:24:50 +02:00
egui_glow Do no use the ahash reimport (#4504) 2024-05-27 16:24:50 +02:00
egui_plot Plot now respects the `interact_radius` set in the UI's style (#4520) 2024-05-27 19:23:15 +02:00
egui_web Fix typos (#2866) 2023-04-18 15:52:45 +02:00
emath Move dependencies to workspace (#4495) 2024-05-14 11:02:49 +02:00
epaint Don't panic when replacement glyph is not found (#4542) 2024-05-27 11:53:06 +02:00