Commit Graph

3348 Commits

Author SHA1 Message Date
Emil Ernerfeldt 8bf498d2bf Fix sizing of `images` example 2024-07-03 15:49:05 +02:00
Emil Ernerfeldt 234274d46f Release 0.28.0 - Sizing pass, and better eframe web 2024-07-03 14:54:08 +02:00
Emil Ernerfeldt bca9a04acd
Use correct cursor icons when resizing panels too wide or narrow (#4769) 2024-07-03 14:33:11 +02:00
Emil Ernerfeldt 47accb0eeb Tooltip fix: Only treat enabled widgets as interactive 2024-07-03 13:11:48 +02:00
Emil Ernerfeldt 249b69d534
Make sure all tooltips close if you open a menu in the same layer (#4766) 2024-07-03 12:33:23 +02:00
Emil Ernerfeldt d1be5a1efb
Only show one tooltip per layer at a time (#4763)
Before, you could accidentally get multiple tooltips if a tooltips was
interactive (e.g. had a link in it) and on the way to interact with it
you would hover another widget with a tooltip.

This PR ensures that each `LayerId` only has one tooltip open at a time.
You can still have a tooltip for an item inside of a tooltip.
2024-07-03 11:28:26 +02:00
Emil Ernerfeldt c0296fb47b
When debugging widget rects on hover, show width and height (#4762)
As requested by @gavrelina


![image](https://github.com/emilk/egui/assets/1148717/15d9600a-ae2e-43dd-981b-c690f9b1bdf1)
2024-07-03 10:48:52 +02:00
Emil Ernerfeldt dca552ea48
Save `FrameState` of previous frame (#4761)
By saving the `FrameState` of the previous frame, we make it much more
versatile, and allows us to remove some other double-buffering.
2024-07-03 10:31:02 +02:00
Emil Ernerfeldt 1b06c69d01
Fix text selection when there's multiple viewports (#4760)
* Closes https://github.com/emilk/egui/issues/4758

Thanks to @lukexor for finding and diagnosing the problem!
2024-07-03 10:19:03 +02:00
Emil Ernerfeldt fcb7764e48
Fix menus and interactive popups not closing when framerate was low (#4757) 2024-07-02 21:33:22 +02:00
Emil Ernerfeldt 8ef0e85b85
egui_extras: Improve the auto-sizing of `Table` (#4756)
This makes the sizing pass of an `egui_table` ensure the table uses as
little width as possible.
Subsequently, it will redistribute all non-resizable columns on the
available space, so that a table better follow the parent container as
it is resized.

I also added `table.reset()` for forgetting the current column widths.
2024-07-02 21:13:55 +02:00
Emil Ernerfeldt 753412193c
Improve `egui_extras::Table` layout (#4755)
Mostly a refactor, but some minor fixes to how it works.

Mostly preparing for a few bigger changes.
2024-07-02 20:57:46 +02:00
Emil Ernerfeldt f0e2bd8b00
Make it easier to grab the handle of a floating scroll bar (#4754)
Should solve https://github.com/rerun-io/rerun/issues/6700
2024-07-02 10:39:01 +02:00
William Zhang 770c82a3f3
Prevent `TextEdit` widgets from sending fake primary clicks (#4751)
<!--
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 test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* 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!
-->

This prevents TextEdit widgets from sending fake primary clicks when a
user types Space / Enter. Small change but having Space / Enter send
`OutputEvent::ValueChanged` instead of `OutputEvent::Clicked` makes more
sense I believe.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-07-02 09:18:47 +02:00
Wybe Westra fa8d535fe7
Disabled widgets are now also disabled in the accesskit output (#4750)
Marking widgets as disabled was not reflected in the accesskit output,
now the disabled status should match.

---------

Co-authored-by: Wybe Westra <w.westra@kwantcontrols.nl>
2024-07-02 09:18:30 +02:00
Emil Ernerfeldt fcec84ca74 Clarify version numbers in egui trunk 2024-07-02 09:09:30 +02:00
Emil Ernerfeldt af404fec63
Persist `Area` positions again (#4749)
* Reverts https://github.com/emilk/egui/pull/4577

We again persist area positions, but not sizes.
2024-07-01 17:33:03 +02:00
Emil Ernerfeldt 0fc79aea14 egui_demo_app: include `log::trace` in debug builds 2024-07-01 16:26:20 +02:00
Emil Ernerfeldt 7b61e426d7 eframe web: map `log::debug` to `console.debug`; not `console.trace` 2024-07-01 16:25:48 +02:00
Emil Ernerfeldt f3a0ac1d1b eframe web fix: `save()` on "blur" event 2024-07-01 16:16:56 +02:00
Emil Ernerfeldt 051b90bfc7 eframe web: Position the IME input position in the middle of the cursor 2024-07-01 16:08:20 +02:00
Emil Ernerfeldt d271718065
Fix focus problems on web (#4745)
* Closes https://github.com/emilk/egui/issues/4743
* Related to https://github.com/emilk/egui/issues/4569
2024-07-01 10:38:54 +02:00
Emil Ernerfeldt 31716d787e
Fix plot bounds of empty plots (#4741)
We would sometimes hit a `debug_assert` when plots were empty

* Closes https://github.com/rerun-io/rerun/issues/6681
2024-06-30 17:49:54 +02:00
Emil Ernerfeldt dc1f032846
Add `Style::number_formatter` as the default used by `DragValue` (#4740)
This allows users to customize how numbers are converted into strings in
a `DragValue`, as a global default.

This can be used (for instance) to show thousands separators, or use `,`
as a decimal separator.
2024-06-30 17:17:15 +02:00
Emil Ernerfeldt e297a1d107 Handle unicode minus character when parsing floats 2024-06-30 14:48:05 +02:00
Emil Ernerfeldt 3add56f81b Fix wrong comment 2024-06-30 14:35:46 +02:00
Emil Ernerfeldt 6222e031b5
The default parser for `DragValue` and `Slider` now ignores whitespace (#4739)
It's easy to include whitespace when copy-pasting values. Also, some
formatters use half-spaces as thousands separators.
2024-06-30 14:34:36 +02:00
Emil Ernerfeldt b6fd1cfc99
egui_plot: Improve default formatter of tick-marks (#4738)
The default `Plot` formatter now picks precision intelligently based on
zoom level. The width of the Y axis are is now much smaller by default,
and expands as needed.

Also deprecates `Plot::y_axis_with`; replaced with `y_axis_min_width`.
2024-06-30 14:20:41 +02:00
Emil Ernerfeldt 17fd305967 Fix `cargo test -p egui` 2024-06-30 14:12:40 +02:00
Emil Ernerfeldt d4e8966aac
Ensure `Window` scroll bars are at the window edges (#4733)
Set `auto_shrink(false)` on `Window`s `ScrollArea`.
This ensures that the scroll bars are always the outermost.

* Closes https://github.com/emilk/egui/pull/4602
2024-06-28 18:14:48 +02:00
Emil Ernerfeldt d10b3c1f4e
eframe web: Fix stuck keys after pressing ctrl+C, cmd+A, etc (#4731)
* Closes https://github.com/emilk/egui/issues/4724
2024-06-28 18:12:50 +02:00
Emil Ernerfeldt 2180f16cba
eframe web: Fix drag-and-drop file preview/hover (#4732)
* Closes https://github.com/emilk/egui/issues/4726
2024-06-28 18:07:53 +02:00
Emil Ernerfeldt 0c059ac113
Only repaint on cursor movements of area, or if dragging outside (#4730)
* Closes https://github.com/emilk/egui/issues/4723

Also fix some small bugs in the touch input on web
2024-06-28 17:40:48 +02:00
Andreas Reich 10f092d9d4
Add `clamp_to_range` option to DragValue, rename `clamp_range` to `range` (deprecating the former) (#4728)
Adds the ability to have `DragValue` not clamp values its presented with
and instead apply clamping only once there's any user input.

In action:


https://github.com/emilk/egui/assets/1220815/af42fd67-86d0-4364-8ae6-48a2ec15646a




Alternative name could be `only_clamp_on_change`, not entirely certain
which one is better 🤔
2024-06-28 16:06:59 +02:00
Emil Ernerfeldt 3b9f964aed
eframe web: ignore keyboard events unless canvas has focus (#4718)
* 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-28 15:01:06 +02:00
Wybe Westra 779312ac0c
Add basic test for egui accesskit output. (#4716)
For a project I am currently attempting to use the acceskit output of
egui to preform end-to-end integration tests of my application. However,
the output is currently quite basic (buttons for example don't report
that they are disabled).

Before adding new features to the acceskit integration, I thought it
would be a good idea to add some testing to egui's accesskit output.
I have started with a simple test for button texts, to get feedback on
whether this is the correct direction to go in.

---------

Co-authored-by: Wybe Westra <w.westra@kwantcontrols.nl>
2024-06-28 13:03:31 +02:00
Emil Ernerfeldt 254dfc1ebc
Fix broken mouse coordinates when there's padding on the canvas element (#4729)
* Closes https://github.com/emilk/egui/issues/4725

Also fixes touch input being wrong if the web page is scrolled.
2024-06-28 13:02:36 +02:00
Emil Ernerfeldt a6937f79f3 Improve `multiple_apps.html` example/demo/test 2024-06-28 08:44:17 +02:00
Emil Ernerfeldt e62bd7037a Improve warning when failing to copy on web 2024-06-28 08:40:58 +02:00
Emil Ernerfeldt 814eddd094 Add warning if `window.navigator.clipboard` is null 2024-06-28 08:39:49 +02:00
Emil Ernerfeldt f50e64632e Change web demo local port to 8765 to avoid colliding with Jupyter 2024-06-28 08:37:21 +02:00
Emil Ernerfeldt a0f4fafb88
Refactor web event handling: break up into smaller functions (#4717)
No change in functionality, just making the code easier to read and
change.

* Part of fixing https://github.com/rerun-io/rerun/issues/6638
2024-06-27 15:26:52 +02:00
Emil Ernerfeldt ce0e200503 Sort feature flags in egui_extras 2024-06-27 14:29:59 +02:00
Emil Ernerfeldt 97b6d8cb1c Fix vertical spacing in changelog generation 2024-06-27 14:29:49 +02:00
Emil Ernerfeldt a489374ca6 Improve CSS comment 2024-06-27 11:17:49 +02:00
Emil Ernerfeldt 7121a49e4e
`generate_changelog.py`: divide into "fixed/added/changed" sections (#4712)
Make each release a little bit easier to do
2024-06-27 09:54:01 +02:00
Umatriz 5051e945e4
Add `PopupCloseBehavior` (#4636)
This PR adds `PopupCloseBehavior` to improve state of the
<https://github.com/emilk/egui/issues/4607>

`PopupCloseBehavior` determines when popup will be closed.
- `CloseOnClick` popup will be closed if the click happens anywhere even
in the popup's body
- `CloseOnClickAway` popup will be closed if the click happens somewhere
else but in the popup's body.

It also adds a test in the demo app which contains several popups
examples.

---

My ideas about <https://github.com/emilk/egui/issues/4607> is to make
every tooltip and popup a menu. So it will provide more control over
popups and tooltips (you will be able to close a popup by calling
something similar to the `ui.close_menu` if you need to). You won't need
to manually handle it's opening. And also will allow to have multiple
popups opened. That means you can have a popup inside a popup. And it
will also lead to the easier creation of the popups. (should we create a
tracking issue to track changes because to me it seems like a huge
amount of changes to be done?)

---

- Improvements on <https://github.com/emilk/egui/issues/4607>
2024-06-27 09:42:57 +02:00
YgorSouza ab861574f4
Cancel DragValue edit if Escape is pressed (#4713)
Since Escape takes focus away from the text field, it makes more sense
for it to cancel the change rather than confirm it.

This only matters if `update_while_editing` is set to false, of course.
2024-06-27 09:18:25 +02:00
Emil Ernerfeldt a1a0d4a12a Tweak two demos 2024-06-26 21:18:28 +02:00
Emil Ernerfeldt fd85557463
Close context menus with Escape (#4711)
Pressing escape should close any menu or popup
2024-06-26 21:04:29 +02:00