1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

3127 Commits

Author SHA1 Message Date
Emil Ernerfeldt
014327e365 Release 0.27.2 - Fix blurry web rendering 0.27.2 2024-04-02 18:13:37 +02:00
lucasmerlin
3897be3774 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:54:26 +02:00
Emil Ernerfeldt
5c8df022b7 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:38:13 +02:00
YgorSouza
cadaa7a65d Prevent plot from resetting one axis while zooming/dragging the other (#4252)
* Closes <https://github.com/emilk/egui/issues/4251>
2024-04-02 15:12:28 +02:00
Emil Ernerfeldt
11c5cb09e9 Fix typos and false positives found by new version of 'typos' 2024-04-02 11:07:03 +02:00
Emil Ernerfeldt
11ea38e1a7 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-02 11:07:03 +02:00
Emil Ernerfeldt
dce49e4987 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-04-02 11:07:03 +02:00
Emil Ernerfeldt
5549ef8d21 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-04-02 11:07:03 +02:00
Emil Ernerfeldt
1b553c99af Remove a bunch of unwrap() (#4285)
The fewer unwraps, the fewer panics
2024-04-02 11:07:03 +02:00
刘皓
063098e83b 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-04-02 11:07:03 +02:00
Emil Ernerfeldt
7b31d3af76 eframe: Correctly identify if browser tab has focus (#4280)
`input.focus` was often wrong on web
2024-04-02 11:07:03 +02:00
Emil Ernerfeldt
166b51e445 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-04-02 11:01:34 +02:00
Emil Ernerfeldt
b532e2e2be Fix bug in determining wether to remove focus from a widget (#4272)
* Closes https://github.com/emilk/egui/issues/4206
2024-04-02 11:01:34 +02:00
Emil Ernerfeldt
232b8bc298 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-04-02 11:01:34 +02:00
Emil Ernerfeldt
6b4a8e260b Improve docs of ui.collapsing
See https://github.com/emilk/egui/issues/4265
2024-04-02 11:01:34 +02:00
Emil Ernerfeldt
929e33781c Release 0.27.1 - Bug fixes for shadows and touch input 0.27.1 2024-03-29 12:49:31 +01:00
Emil Ernerfeldt
9ac6f33c1d Avoid duplicate entires when generating changelog 2024-03-29 12:45:11 +01:00
Emil Ernerfeldt
555f64dfea Hide shortcut text on zoom buttons if zoom_with_keyboard is false (#4262) 2024-03-29 12:29:28 +01:00
Justus Dieckmann
f7ea6dc410 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 12:29:28 +01:00
Emil Ernerfeldt
2b75e38abb 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 12:29:28 +01:00
Emil Ernerfeldt
fdcc9eac13 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-29 12:29:28 +01:00
Emil Ernerfeldt
fbccd9cc99 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-29 12:29:28 +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 0.27.0 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
Emil Ernerfeldt
a03604fce0 Add breaking change to changelog 2024-03-26 11:13:56 +01:00
Emil Ernerfeldt
884cf6de3d Add some tests for Rect 2024-03-26 11:13:04 +01:00
Emil Ernerfeldt
8a880d6d0f Add Area::sense and improve hit-testing of buttons in menus (#4234)
Previously, putting the cursor in the gap between two menu buttons would
not hover any of the buttons, but the click-sensitive menu itself. Now
the menu is no longer click-sensitive.
2024-03-26 11:12:49 +01:00
Emil Ernerfeldt
9cfaf8b961 Better align menus with the button that opened them (#4233)
<img width="530" alt="Screenshot 2024-03-26 at 10 42 46"
src="https://github.com/emilk/egui/assets/1148717/4891047d-42a1-45b6-9363-c6ac93cefc8d">
<img width="268" alt="Screenshot 2024-03-26 at 10 42 57"
src="https://github.com/emilk/egui/assets/1148717/98865f38-10cc-4cbe-a80b-a767415e1469">
2024-03-26 10:54:15 +01:00
Emil Ernerfeldt
c530504a04 CSS-like shadows with offset, spread, and blur (#4232)
This makes `epaint::Shadow` more like CSS's box-shadow, adding `offset`
and replacing `extrusion` with `blur` and `spread`.

* Closes https://github.com/emilk/egui/pull/3047

The offsets make for nice drop-shadow effects.

Old shadows:
<img width="1447" alt="old-shadows"
src="https://github.com/emilk/egui/assets/1148717/8a30f7b9-fb9d-49ea-9a2f-9367a60c448a">

New shadows:
<img width="1447" alt="new-shadows-full"
src="https://github.com/emilk/egui/assets/1148717/28cc9c1e-b0de-4c5b-a705-22e52c556584">
2024-03-26 10:37:12 +01:00
Emil Ernerfeldt
1634554032 Add Margin to epaint (#4231)
Moved from `egui`
2024-03-26 09:05:29 +01:00
Emil Ernerfeldt
cf8c37c71e Add some distance between parent menu and submenu (#4230)
Before:
<img width="502" alt="Screenshot 2024-03-26 at 08 37 16"
src="https://github.com/emilk/egui/assets/1148717/ca072cae-807a-4830-a59a-11ff822d0a7b">


After:
<img width="532" alt="Screenshot 2024-03-26 at 08 36 12"
src="https://github.com/emilk/egui/assets/1148717/f42d79f4-ff05-457f-9fab-67574839f025">
2024-03-26 08:43:38 +01:00
/lemon.sh
ab6c3f9161 Add an API for customizing the return key in TextEdit (#4085)
This PR allows customizing the return key in the TextEdit widget. Right
now, it's hard-coded to the Enter key, which is problematic in cases
when you want to use the Enter key for something else, and insert the
newline in a different way instead.
2024-03-25 13:18:08 +01:00
Colin Kinloch
287a550b90 egui demo: Add drop down to resize the window (#4197)
An alternative to the "Phone Size" button useful for testing
`ViewportCommand::InnerSize`.

I created this to make it easy to debug
https://github.com/emilk/egui/issues/4196 there are more details there.
2024-03-25 13:11:39 +01:00
rustbasic
d410bc5b9a Fix example/test_viewports title change (#4221)
fix : `example/test_viewports` title Change accurately

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-25 12:40:49 +01:00
Emil Ernerfeldt
7f8aae4103 Don't show URLs when hovering hyperlinks (#4218)
Can be changed with `Style::url_in_tooltip`
2024-03-25 09:00:12 +01:00
Emil Ernerfeldt
20b0637d42 Some clippy fixes 2024-03-22 12:33:35 +01:00
Emil Ernerfeldt
b7ec3fa1e3 Fix crash in wants_keyboard_input 2024-03-22 12:33:17 +01:00
rustbasic
21d045e8ef Fix: IME bug when typing Chinese characters (#4210)
* Closes #4209 

Fix: IME bug when typing Chinese characters
2024-03-22 12:27:08 +01:00
rustbasic
769199648d Prevent egui::Window from becoming larger than Viewport (#4199)
* Closes #3987  

* Closes #3988

There is a need to prevent egui::Window from becoming larger than the
Viewport.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-21 13:47:25 +01:00
dwuertz
0299663cdd Expose PlotGeometry in public API (#4193)
Expose `egui_plot::items::values::PlotGeometry` in public API so that
`PlotItem`, which is already public, can actually be implemented by
applications. Fixes #3464.

---------

Co-authored-by: Dominique Würtz <dom@blaukraut.info>
2024-03-21 12:27:18 +01:00
Zeenobit
e4f209ec50 Expose state override for HeaderResponse (#4200)
I'm trying to create some custom collapsing headers that add additional
buttons inside the header itself. Because of this, I load the
`CollapsingState` in my special widget manually. But because
`HeaderResponse` owns the `Ui` and the `CollapsingState`, there is no
way for me to open/close the collapsing header based on response of the
inner widget.

Initially, I considered just exposing `state` member of
`HeaderResponse`, but that exposes too much of the API at the wrong
time, in my opinion.

So instead I found it'd be safer to just expose the open/close API to
the response itself, and that's what this PR does.
2024-03-21 12:13:32 +01:00
rustbasic
7d3d7ce0ca typos : intersects_ray() (#4201)
typos : intersects_ray()
2024-03-21 12:10:02 +01:00
Seth Rider
2c9c5f0dea Add x11 window type settings to viewport builder (#4175)
Not sure about the api, currently I've mapped the whole XWindowType
enum, but maybe there's something more sensible to do?

* Closes <https://github.com/emilk/egui/issues/4150>

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-21 12:07:20 +01:00
hiyosilver
365d035b20 Added ability to disable highlighting of weekend days in DatePickerPopup. (#4151)
I added a handfull of lines to allow for the red highlight on weekends
in `DatePickerPopup` to be disabled.

I tried to follow the rules, but I've never done any kind of PR before,
and I'm also not sure if this is at all the kind of thing that is wanted
at the moment. If it is not, I'm happy to just have this removed. Just a
tiny little addition I would find useful.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-21 11:09:19 +01:00
rustbasic
861a1b6225 Adjustable Slider rail height (#4092)
Adjustable Slider rail height 


![explain20240312-2](https://github.com/emilk/egui/assets/127506429/d5edfe10-8191-44ed-8567-d9d2127ce4b8)

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-21 10:48:40 +01:00