summaryrefslogtreecommitdiff
path: root/web_demo
AgeCommit message (Collapse)Author
2024-07-15Use canvas directly (#4780)Jan Procházka
2024-06-28eframe web: ignore keyboard events unless canvas has focus (#4718)Emil Ernerfeldt
* Fixes https://github.com/rerun-io/rerun/issues/6638 * Related? https://github.com/emilk/egui/issues/4563 This improves how an eframe canvas works inside of a larger web page, and how it works when there are multiple eframe apps in the same page. `eframe` will set `tabindex="0"` on the canvas automatically, making it focusable. It will also set `outline: none` on the CSS, so the focused canvas won't have an ugly outline. ## Breaking changes You may wanna add this to your `index.html` to give the canvas focus on startup: ```js document.getElementById("the_canvas_id").focus(); ``` ## Test setup ```sh ./scripts/build_demo_web.sh ./scripts/start_server.sh open http://localhost:8888/multiple_apps.html ``` Then open the "Input Event History" and "Text Edit" windows ## Tested * Chromium * [x] drag-and-drop of files * Test both when a `TextEdit` is focused and when it is not: * [x] `Event::Key` * [x] `Event::Text` * [x] copy-cut-paste * [x] Wheel scroll * [x] `Event::PointerGone` * [x] Mouse drag * [x] Mouse click * [x] Mouse right-click * [x] Defocus all eframe canvas, and then start typing text * [x] Firefox (all of the above) * [x] Desktop Safari (all of the above) * [x] Mobile Safari ## Future work (pre-existing issues) * https://github.com/emilk/egui/issues/4723 * https://github.com/emilk/egui/issues/4724 * https://github.com/emilk/egui/issues/4725 * https://github.com/emilk/egui/issues/4726
2024-06-28Improve `multiple_apps.html` example/demo/testEmil Ernerfeldt
2024-06-28Change web demo local port to 8765 to avoid colliding with JupyterEmil Ernerfeldt
2024-06-27Improve CSS commentEmil Ernerfeldt
2024-05-27Use ResizeObserver instead of `resize` event (#4536)Jan Procházka
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-04-01Fix blurry rendering in some browsers (#4299)Emil Ernerfeldt
* Closes https://github.com/emilk/egui/issues/4241 I would love some more testers of this. I'm not sure if we really need the round-to-even code, but I'm hesitant to out-right revert https://github.com/emilk/egui/pull/151 when I cannot reproduce its problem. Keeping it seems quite safe though. --- # Testing Checkout the branch and run: * `./scripts/start_server.sh` * `./scripts/build_demo_web.sh` and then open `http://localhost:8888/index.html#Rendering` * `./scripts/build_demo_web.sh --wgpu` and then open `http://localhost:8888/index.html#Rendering` Check the "Rendering test" that the squares in the pixel alignment test are perfectly sharp, like this: <img width="576" alt="Screenshot 2024-04-01 at 13 27 20" src="https://github.com/emilk/egui/assets/1148717/fb6c4824-9e25-4304-bc0c-3c50fbd44a52"> If it looks something like this, something is WRONG: <img width="488" alt="Screenshot 2024-04-01 at 13 29 07" src="https://github.com/emilk/egui/assets/1148717/04bd93ff-2108-40c5-95f6-76e3bcb9cd7f"> Please try it on different zoom levels in different browsers, and if possible on different monitors with different native dpi scaling. Report back the results! ### Mac I have tested on a high-DPI Mac: * Chromium (Brave): ✅ Can reproduce problem on `master`, and it's now fixed * Firefox: ✅ Can reproduce problem on `master`, and it's now fixed * Safari: ❌ Can't get it to work; giving up for now
2023-11-16Rename `docs/` to `web_demo/`Emil Ernerfeldt