Commit Graph

3148 Commits

Author SHA1 Message Date
Emil Ernerfeldt 15b0ef3259 Release 0.27.2 - Fix blurry web rendering 2024-04-02 18:18:43 +02:00
lucasmerlin de9e0adf17
Allow disabling animations on a ScrollArea (#4309)
<!--
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.
* The PR title is what ends up in the changelog, so make it descriptive!
* 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!
-->

Adds a flag to ScrollArea that disables animations for the scroll_to_*
functions
2024-04-02 17:53:54 +02:00
Emil Ernerfeldt 36ebce163a
egui_plots: Fix the same plot tick label being painted multiple times (#4307)
Usually this isn't visible (the same label being painted on top of
itself), but it will be visible if the user has a custom formatter (e.g.
`y_axis_formatter`) that choses a different format based on
`GridMark:step_size` (e.g. using fewer decimals for thicker ticks).
2024-04-02 15:37:44 +02:00
Alexander Parlett 4bc7e66245
Support order on windows (#4301)
Adds support for the ordering of windows passing through to the
underlying area.

Needed for a specific usecase of adding debug tools using windows with
the bevy integration.
2024-04-02 10:33:14 +02:00
Emil Ernerfeldt 058f4753b0 Fix typos and false positives found by new version of 'typos' 2024-04-02 09:55:13 +02:00
Emil Ernerfeldt 0a40b16bd4
Fix blurry rendering in some browsers (#4299)
* 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
2024-04-01 15:22:47 +02:00
Emil Ernerfeldt 48ecf01e11
Rename "Color test" to "Rendering test", and restructure it slightly (#4298)
Put the pixel-alignment test first, and hide the color test under a
collapsing header.

<img width="743" alt="Screenshot 2024-04-01 at 13 01 43"
src="https://github.com/emilk/egui/assets/1148717/8e7108ab-63c8-470f-9c21-83181287969b">
2024-04-01 13:08:52 +02:00
Emil Ernerfeldt e99bd00dec
Only avoid glow context switching on Windows (#4296)
…since it is reportedly broken on Windows

* Early-out added in https://github.com/emilk/egui/pull/4284
* Re-opens https://github.com/emilk/egui/issues/4173 😭 
* Closes https://github.com/emilk/egui/issues/4289
* Closes https://github.com/emilk/egui/pull/4290
2024-04-01 12:14:44 +02:00
Emil Ernerfeldt 3ee4890b94 Remove warning in release build 2024-03-31 20:41:44 +02:00
Emil Ernerfeldt a97134d66c Improve `Debug` format of `Sense`, `WidgetInfo` and `Id` 2024-03-31 20:33:02 +02:00
Emil Ernerfeldt 95b62ce144 Show `WidgetInfo` for each widget if `debug.show_interactive_widgets`
This was useful during debugging
2024-03-31 20:32:05 +02:00
Emil Ernerfeldt aa2f87e0ff
Allow zoom/pan a plot as long as it contains the mouse cursor (#4292)
This is a fix meant mostly for Rerun, where we sometiems paint a
vertical time-line over the plot (which is interactive). Before this PR
you couldn't zoom or pan the plot while hovering that line, which was
really annoying.
2024-03-31 20:20:46 +02:00
Emil Ernerfeldt bb06befef1
Consider all non-interactie widgets under the mouse pointer hovered (#4291)
At least all those above any interactive widget.

* Closes https://github.com/emilk/egui/issues/4286

I feel there is still more thinking to be done about what is considered
`hovered` and how it relates to `contains_pointer`, but this PR at least
fixes tooltips for uninteractive widgets
2024-03-31 20:06:25 +02:00
rustbasic 21835c3176
Fix `ViewportCommand::InnerSize` not resizing viewport on Wayland (#4211) 2024-03-30 20:09:28 +01:00
Emil Ernerfeldt 5a0a1e96e0
Remove a bunch of `unwrap()` (#4285)
The fewer unwraps, the fewer panics
2024-03-30 19:33:19 +01:00
Emil Ernerfeldt 2ee9d30d6e Make it easier to tweak text colors in settings 2024-03-30 19:12:54 +01:00
Emil Ernerfeldt ab720ce900
Change `Frame::multiply_with_opacity` to multiply in gamma space (#4283)
This produces a more perceptually even change when used in animations,
like when fading out a closed window
2024-03-30 18:39:05 +01:00
Emil Ernerfeldt e03ea2e17d
eframe: Early-out from context switching the `glow` backend (#4284)
* Closes https://github.com/emilk/egui/issues/4173
2024-03-30 18:38:59 +01:00
Emil Ernerfeldt 549b243228
Rename `fn scroll2` to `fn scroll` (#4282) 2024-03-30 18:00:43 +01:00
Emil Ernerfeldt 1354c3e19a
Make the code example demo narrow enough to fit on mobile (#4281)
I think it is a good example, and so I want to open it by default, but
for that it needs to work on mobile.

Hopefully this doesn't make it too cryptic

<img width="415" alt="image"
src="https://github.com/emilk/egui/assets/1148717/83d881fa-675e-4659-bd21-14abcb79fe46">
2024-03-30 17:51:44 +01:00
刘皓 33221bd4dd
Fix continuous repaint on Wayland when TextEdit is focused or IME output is not None (#4269)
* Closes #4254

Changes egui-winit so that it calls `window.set_ime_cursor_area` when
the IME rect changes or the user interacts with the application instead
of calling it every time the app is rendered. This works around a winit
bug that causes the app to continuously repaint under certain
circumstances on Wayland.

Tested on Wayland and on X11 using the text edit in the egui_demo_app -
no changes in IME functionality as far as I can tell. Untested on
non-Linux platforms.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-30 17:14:58 +01:00
Emil Ernerfeldt 3b147c066b
Implement blinking text cursor in `TextEdit` (#4279)
On by default. Can be set with `style.text_cursor.blink`.

* Closes https://github.com/emilk/egui/pull/4121
2024-03-30 16:22:28 +01:00
Emil Ernerfeldt d3c6895443
eframe: Correctly identify if browser tab has focus (#4280)
`input.focus` was often wrong on web
2024-03-30 16:22:16 +01:00
Emil Ernerfeldt 7277322983
Break out Checkbox, RadioButton and ImageButton to their own files (#4278)
Just a refactor
2024-03-30 14:28:12 +01:00
Emil Ernerfeldt a9a756e8f3
Overload operators for `Rect + Margin`, `Rect - Margin` etc (#4277)
It's more ergonomic
2024-03-30 14:03:41 +01:00
Emil Ernerfeldt 32888e0f83
Make `TextEdit` and atomic widget (#4276)
This means only one space allocation, which should allow putting it in
more types of layouts (right-to-left, centered, adjusted, …).

It also just makes the code simpler
2024-03-30 13:33:51 +01:00
Emil Ernerfeldt fbb4a040ac
Change the resize cursor when you reach the resize limit (#4275)
For panels and `DragValue`: if you cannot resize more in one direction,
reflect that in the choice of mouse cursor


![resize-cursor-2](https://github.com/emilk/egui/assets/1148717/f95176d3-eab9-48cf-b7bd-3182312551d9)
2024-03-30 10:54:32 +01:00
Emil Ernerfeldt 8da0e8cc77
Fix: `Response::clicked_elsewhere` takes clip rect into account (#4274)
`clicked_elsewhere` now checks against the clipped `interact_rect` of
the widget instead of the full `rect`.

In practice this shouldn't change much since the function is mostly used
for windows and areas, which aren't clipped.
2024-03-30 10:35:55 +01:00
Emil Ernerfeldt a7c5eb47a8
Fix bug in determining wether to remove focus from a widget (#4272)
* Closes https://github.com/emilk/egui/issues/4206
2024-03-30 10:22:58 +01:00
Emil Ernerfeldt 810135c5eb
Fix incorrect `Response::interact_rect` for `Area/Window` (#4273)
It was wrong for any `Area` or `Window` that was being moved or whose
position was constrained
2024-03-30 10:15:54 +01:00
Emil Ernerfeldt a541e021aa
Add `RectShape::blur_width` to implement shadows (#4267)
This is mostly a refactor, but has some performance benefits:
* We (re)use the same tessellator as for everything else, leading to
less allocations
* We cull shapes before rendering them

Adding `RectShape::blur_width` means it can also be used for other
effects, such as glow.
2024-03-29 20:29:42 +01:00
Emil Ernerfeldt 73dbfd689b Don't wrap the text in the `Frame` demo 2024-03-29 15:58:37 +01:00
Emil Ernerfeldt 0a428f0887 Improve docs of `ui.collapsing`
See https://github.com/emilk/egui/issues/4265
2024-03-29 15:58:22 +01:00
Emil Ernerfeldt dfbe118ea4
Release 0.27.1 (#4264)
## egui changelog
### 🐛 Fixed
* Fix visual glitch on the right side of highly rounded rectangles
[#4244](https://github.com/emilk/egui/pull/4244)
* Prevent visual glitch when shadow blur width is very high
[#4245](https://github.com/emilk/egui/pull/4245)
* Fix `InputState::any_touches` and add `InputState::has_touch_screen`
[#4247](https://github.com/emilk/egui/pull/4247)
* Fix `Context::repaint_causes` returning no causes
[#4248](https://github.com/emilk/egui/pull/4248)
* Fix touch-and-hold to open context menu
[#4249](https://github.com/emilk/egui/pull/4249)
* Hide shortcut text on zoom buttons if `zoom_with_keyboard` is false
[#4262](https://github.com/emilk/egui/pull/4262)

### 🔧 Changed
* Don't apply a clip rect to the contents of an `Area` or `Window`
[#4258](https://github.com/emilk/egui/pull/4258)


## eframe changelog
* Web: repaint if the `#hash` in the URL changes
[#4261](https://github.com/emilk/egui/pull/4261)
* Add web support for `zoom_factor`
[#4260](https://github.com/emilk/egui/pull/4260) (thanks
[@justusdieckmann](https://github.com/justusdieckmann)!)

---------

Co-authored-by: Justus Dieckmann <45795270+justusdieckmann@users.noreply.github.com>
2024-03-29 13:12:26 +01:00
Emil Ernerfeldt 946bc888db
Hide shortcut text on zoom buttons if `zoom_with_keyboard` is false (#4262) 2024-03-29 12:15:03 +01:00
Justus Dieckmann 7cc98bd38e
Add web support for `zoom_factor` (#4260)
Before, when setting the `zoom_factor`, the website was already
enlarged, but the zoom was ignored when calculating the logical window
size and mouse position, causing an offset between the actual cursor and
selected elements. That is addressed here

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-29 11:55:49 +01:00
Emil Ernerfeldt 60da4b4f65
Web: repaint if the `#hash` in the URL changes (#4261)
Fixes a problem in egui.rs where the back-button would not work to
switch between the top-level tabs
2024-03-29 10:59:24 +01:00
YgorSouza c4f16af721
Prevent plot from resetting one axis while zooming/dragging the other (#4252)
* Closes <https://github.com/emilk/egui/issues/4251>
2024-03-28 10:43:28 +01:00
Emil Ernerfeldt 3dba73e63e
Improve the UI for changing the egui theme (#4257)
I added a new demo - a `Frame` editor:

![frame-editor](https://github.com/emilk/egui/assets/1148717/d0bec169-c211-45a3-9f53-5059fb8fc224)

This whole menu is now just a a bit nicer to use:
<img width="406" alt="Screenshot 2024-03-28 at 09 49 16"
src="https://github.com/emilk/egui/assets/1148717/32d12067-7cf0-4312-aa12-42909a5ed5ac">
2024-03-28 10:09:28 +01:00
Emil Ernerfeldt e183655aac
Don't apply a clip rect to the contents of an `Area` or `Window` (#4258)
The edges were rather arbitrarily chosen anyway, and I'm not sure who it
was supposed to help.
2024-03-28 10:09:21 +01:00
Emil Ernerfeldt 58a27882b0
Fix touch-and-hold to open context menu (#4249)
This was broken in cases where the ui wasn't waking up, i.e. when
nothing else was happening.
2024-03-27 16:39:06 +01:00
Nicolas PASCAL 9fa8aa7e30
`Plot::Items:allow_hover` give possibility to masked the interaction on hovered item (#2558)
This is particularly interesting if you want to authorize a single hover
tooltip on an item in the event of an interaction.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-27 16:35:36 +01:00
lomekragow 570e7cf71b
Add `register_native_texture` in `eframe::Frame` (#4246)
<!--
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.
* The PR title is what ends up in the changelog, so make it descriptive!
* 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/4243

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-27 16:35:25 +01:00
Emil Ernerfeldt 3c029a45ac
Fix `Context::repaint_causes` returning no causes (#4248)
It would return the causes for repainting again collected this frame,
instead of the cause for repainting the current frame.

* Part of https://github.com/emilk/egui/issues/3931
2024-03-27 16:14:22 +01:00
Emil Ernerfeldt bc5ce77819
Fix `InputState::any_touches` and add `InputState::has_touch_screen` (#4247)
Add `InputState::has_touch_screen` to query if there ever has been any
touches (which is what `any_touches` used to return).
2024-03-27 16:14:17 +01:00
Emil Ernerfeldt a15e6c2122
Prevent visual glitch when shadow blur width is very high (#4245)
* Closes https://github.com/emilk/egui/issues/4238

The comment in the code explains it well, but the short of it is this:
we can't handle a shadow blur width larger than the shadow rectangle, so
we need to clamp the blur. This means smaller things will cast shadows
with a smaller blur width, but that's better than having visual
glitches.
2024-03-27 11:22:38 +01:00
Emil Ernerfeldt 947b5813d7
Fix visual glitch on the right side of highly rounded rectangles (#4244)
* Part of https://github.com/emilk/egui/issues/4238

When one side of a rectangle is all rounding we need to take care not to
produce duplicated vertices in the rectangle path generator.

The old code only handled three sides, but forgot the last side (the
right side).
The new code handles the right side, and also handles the other sides
more robustly (with a floating point eps) and efficiently (in a single
pass).

The glitch was most notable in shadows with a high blur width.

Examples of the glitch:

<img width="203" alt="Screenshot 2024-03-26 at 20 15 38"
src="https://github.com/emilk/egui/assets/1148717/dc1c0a06-35f0-4fda-a011-0e37d18454a0">

<img width="220" alt="Screenshot 2024-03-27 at 09 48 48"
src="https://github.com/emilk/egui/assets/1148717/c278b28e-c3f9-4c82-ba20-0480621efd2f">

<img width="33" alt="Screenshot 2024-03-27 at 09 49 21"
src="https://github.com/emilk/egui/assets/1148717/379ddf77-6590-4444-9c2e-67ab1e071f0f">
2024-03-27 10:13:49 +01:00
Emil Ernerfeldt 4d4cb3d20d Release 0.27.0 - Nicer menus and new hit test logic 2024-03-26 17:13:57 +01:00
Emil Ernerfeldt f8d7d0ebaa
Enforce writing username in TODO comments (#4235) 2024-03-26 11:48:24 +01:00
Emil Ernerfeldt 8a10f81ca0 Forbid use of `std::time::Instant` on wasm 2024-03-26 11:15:08 +01:00