Commit Graph

3910 Commits

Author SHA1 Message Date
Lucas Meurer 626cd9e227
Fix `Response::clicked_elsewhere` not returning true sometimes (#5798)
* Closes #5794
2025-03-18 11:40:33 +01:00
Lucas Meurer d3c1ac3798
Fix `context_menu` not closing when clicking widget (#5799)
The rerun timeline context menu wouldn't close when clicking outside,
this fixes it
2025-03-18 11:32:18 +01:00
Lucas Meurer cf756df14d
Clarify what happens when multiple modals are shown in the same frame (#5800)
* Closes #5788 
* [x] I have followed the instructions in the PR template
2025-03-18 11:30:32 +01:00
Lucas Meurer d698365dac
Fix the `StyleModifier` not being passed from popup to menu (#5805)
* [x] I have followed the instructions in the PR template
2025-03-18 11:29:20 +01:00
Sven Niederberger 024dc7b135
Add a toggle for the compact menu style (#5777)
<!--
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!
-->

Menus currently have their own style that removes outlines and
backgrounds. This is nice if the menu only contains buttons. However if
the menu contains other widgets, e.g. a drag value, the style change
makes it quite difficult to identify such widgets. This is a simple way
to make this configurable.


* [x] I have followed the instructions in the PR template
2025-03-18 11:13:59 +01:00
Adrian Blumer eb7ca72534
Fix`TextEdit` selection when placed in a `Scene`. (#5791)
* Closes https://github.com/emilk/egui/issues/5789
* [x] I have followed the instructions in the PR template

While this change fixes the TextEdit specific issue, I'm worried that
the underlying problem is more fundamental and could show up in other
widgets, and I'm wondering if there's a more general solution?
2025-03-17 10:00:47 +01:00
lucasmerlin d811940dcc
Allow unmaintained paste crate (#5787)
Should fix cargo deny CI
2025-03-13 11:45:29 +01:00
lucasmerlin 5941a27ed4
Update ring (#5786)
Upate ring to latest patch, should fix ci failures
2025-03-13 11:29:37 +01:00
lucasmerlin 962c7c7516
Deprecate `Ui::allocate_new_ui` in favor of `Ui::scope_builder` (#5764)
They had the same signature and slightly different implementations, now
it's streamlined
2025-03-05 12:08:43 +01:00
Gilberto Santos 1dea8fac9b
Fix scroll handle extending outside of `ScrollArea` (#5286)
* [x] I have followed the instructions in the PR template
* Closes https://github.com/emilk/egui/issues/3734

## Info

This PR addresses an issue where resizing a scroll handle can lead to
unwanted overlap.

It is also happening on the egui-demo.

![Screenshot 2024-10-18 at 17 35
25](https://github.com/user-attachments/assets/3a9527d9-fc46-4b25-b95a-9ba2fa54978e)

## Cause

*Note: The following explanation assumes a vertical scroll; however, the
logic applies equally to horizontal scrolling.*

When the scroll handle is positioned at the top or bottom of the scroll
area and the handle is resized to fit the minimum handle size, there is
a risk of overlap. This occurs if the handle’s new size extends beyond
the bounds of the scroll area.

## Proposed Solution

1. Check whether increasing the handle size will cause it to overlap
with the scroll area.
2. If an overlap is detected, adjust the handle’s center position by the
overlap amount, moving it towards the center of the scroll area.
2025-03-05 10:49:04 +01:00
Lucas Meurer 159ccb2fef Release 0.31.1 - text_edit and kittest fixes 2025-03-05 08:37:34 +01:00
lucasmerlin e1f5d68995
Improved git lfs instructions (#5707)
* Closes <https://github.com/emilk/egui/issues/5526>
* [x] I have followed the instructions in the PR template
2025-03-04 11:38:46 +01:00
lucasmerlin 26288d7dd7
Fix preview build failing (#5756)
The preview build randomly started failing:

https://github.com/emilk/egui/actions/runs/13633368357/job/38106240555?pr=5755
2025-03-03 17:08:54 +01:00
lucasmerlin 40bf21728d
Move gifs to git lfs (#5706)
Since we moved pngs to lfs I think we should also move the gifs there.

* [x] I have followed the instructions in the PR template
2025-03-03 15:51:43 +01:00
lucasmerlin cd22517280
⚠️ Improved menu based on `egui::Popup` (#5716)
Continuation of #5713

**Silently breaking changes:**
- Menus now close on click by default, this is configurable via
`PopupCloseBehavior`

**Additional additions:**
- `Button::right_text`
- `StyleModifier`

This is a rewrite of the egui menus, with the following goals:
- submenu buttons should work everywhere, in a popup, context menu,
area, in some random Ui
- remove the menu state from Ui
- should work just like the previous menu
- ~proper support for keyboard navigation~
  - It's better now but requires further work to be perfect
- support `PopupCloseBehavior`

* Closes #4607 
* [x] I have followed the instructions in the PR template
2025-03-03 14:56:30 +01:00
lucasmerlin 6e3575b4c7
Add `typ` to known words (#5754)
This recently started to fail:
https://github.com/emilk/egui/actions/runs/13628559355/job/38091065444?pr=5706
2025-03-03 11:40:28 +01:00
IaVashik e995c4c5b4
Fix sizing bug in `TextEdit::singleline` (#5640)
This PR reverts a change introduced in PR
https://github.com/emilk/egui/pull/3660 that caused a regression with
`TextEdit::singleline`. The original PR attempted to fix an issue with
the cursor in `TextEdit` inside `ScrollArea`, but it did so by adding
unnecessary size allocation to `TextEdit`, which breaks the layout when
`TextEdit::singleline` is used outside of `ScrollArea`.


![Image](https://github.com/user-attachments/assets/78fdf20a-0763-4b5f-b83b-64522f15b35b)

The regression introduced by #3660 is more severe, as it completely
breaks the layout of applications using `TextEdit::singleline`, as shown
in the following issues:

*   Closes https://github.com/emilk/egui/issues/5500
*   Closes https://github.com/emilk/egui/issues/5597

Furthermore, I was unable to reproduce the original bug from PR #3660 in
the current version of egui using the following code:

```rust
impl eframe::App for MyEguiApp {
    fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
        ctx.set_debug_on_hover(true);
        egui::CentralPanel::default().show(ctx, |ui| {
            ScrollArea::vertical().max_height(100.0).show(ui, |ui| {
                ui.add(TextEdit::multiline(&mut self.text).hint_text("Enter text here..."))
            });
        });
    }
}
```

This code attempts to recreate the layout shown in the video from PR
#3660, using a `ScrollArea` with limited height and a `TextEdit` inside.
However, the cursor hiding issue was not reproducible.

![Video_2025-01-26_17-54-24](https://github.com/user-attachments/assets/ca4750ea-8af8-4ab5-8c10-bdf73a090362)

Therefore, I believe the code added in PR #3660 is no longer necessary
and only creates more problems.

*   Closes https://github.com/emilk/egui/issues/5500
*   Closes https://github.com/emilk/egui/issues/5597
*   [x] I have followed the instructions in the PR template
2025-03-03 09:22:01 +01:00
Onè 4589cbb0fe
Fix typo in example (#5750)
* [x] I have followed the instructions in the PR template
2025-03-02 12:07:08 +01:00
tyssyt 2428aeccbe
Use enum-map serde feature only when serde is enabled (#5748)
* [x] I have followed the instructions in the PR template
2025-02-27 15:50:45 +01:00
Jack Maguire 05141f8690
Fix typo in comment in `containers/scene.rs` (#5747)
There was a typo in one of the comments in the file, so I fixed it :).
2025-02-27 15:50:16 +01:00
Nicolas 0521caed2e
Fix Cargo-Machete Workflow (#5745)
As cargo machete now uses rust edition2024 we cannot use the older rust
version - we need to install the newest on the runner

* [ ] I have followed the instructions in the PR template

---------

Co-authored-by: lucasmerlin <lucasmeurer96@gmail.com>
2025-02-27 15:24:10 +01:00
Emil Ernerfeldt 42a88b677c Fix some clippy lints from the future 2025-02-25 14:10:42 +01:00
Emil Ernerfeldt 6a96612cb3
Mark all keys as up if the app loses focus (#5743)
In Rerun, pressing `Cmd+S` brings up a save dialog using `rfd`, but we
get not key-up event for the `S` key (in winit).
This leads to `S` being mistakenly marked as down when we switch back to
the app.

This PR takes the safe route and marks all keys as up when an egui app
loses focus.

* Tested with https://github.com/rerun-io/rerun/pull/9103
2025-02-25 14:05:35 +01:00
Brandon Li 27e7303ebe
Clarify platform-specific details for `Viewport` positioning (#5715)
On Wayland (and android apparently) it is not possible for applications
to position their windows or request the window position (for some
reason). This is not specified in the documentation.

proof: [`winit::set_outer_position`], [`winit::outer_position`],
[`winit::inner_position`] all specify that Android / Wayland are not
supported.

[`winit::set_outer_position`]:
https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_outer_position
[`winit::outer_position`]:
https://docs.rs/winit/latest/winit/window/struct.Window.html#method.outer_position
[`winit::inner_position`]:
https://docs.rs/winit/latest/winit/window/struct.Window.html#method.inner_position

* Maybe closes #4469
* the lack of support makes me sad. I believe this makes some items in
#3556 impossible on Wayland. Oh well!

---------

Co-authored-by: lucasmerlin <lucasmeurer96@gmail.com>
2025-02-20 19:32:34 +01:00
lucasmerlin f5b058b908
Add `Ui::close` and `Response::should_close` (#5729)
This adds a generic way of telling containers to close from their child
`Ui`s.

* Part of #5727 
* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-02-20 17:59:29 +01:00
Onè 264749b8af
Fix typo in docstring for `Column::auto_size_this_frame` (#5681)
* [x] I have followed the instructions in the PR template
2025-02-18 18:11:48 +01:00
Piotr Podusowski 9dad7f827d
Align `available_rect` docs with the new reality after #4590 (#5701)
...as after #4590, `Window`/`Area` is not constrained within it.
2025-02-18 18:03:42 +01:00
Michael Grupp b48c7a164b
Implement `Default` for `ThemePreference` (#5702)
Convenient if you store it in an options struct in your app, want to
reset it, etc.

* ~Closes <https://github.com/emilk/egui/issues/THE_RELEVANT_ISSUE>~
* [x] I have followed the instructions in the PR template
2025-02-18 18:03:02 +01:00
Aiden 43261a5396
Add pointer events and focus handling for apps run in a Shadow DOM (#5627)
* [x] I have followed the instructions in the PR template

This PR handles pointer events and focus which did following changes:
- `element_from_point` and focus is now acquired from root node object
by using `get_root_node` from document or a shadow root.
- `TextAgent` is appended individually in each shadow root.

These changes handles pointer events and focus well in a web app that
are running in a shadow dom, or else the hover pointer actions and
keyboard input events are not triggered in a shadow dom.
Helpful for building embeddable/multi-view web-apps.
2025-02-18 18:01:07 +01:00
Bryce Berger 071e090e2b
add Label::show_tooltip_when_elided (#5710)
fixes #5708

Allows the user to disable the automatic tooltip when a Label is elided

* Closes <https://github.com/emilk/egui/issues/5708>
* [x] I have followed the instructions in the PR template
2025-02-18 17:33:27 +01:00
Braden Steffaniak 770c976ed7
Fix image_loader for animated image types (#5688)
Hi, after upgrading to 0.31.0 all of my beautiful static webp images
started failing to load. I use the image_loader to load those via the
`image` crate.

I noticed that with 0.31.0 there are additions to how animated image
types are handled with frames and such. And with those changes the frame
index is attached to the uri at the end. This was problematic for the
image_loader, because it wasn't updated to handle that frame tag at the
end of the uri, so when looking up the bytes, it would fail to match the
uri in the bytes cache (the bytes were being saved without the frame
index, but attempting to be fetched _with_ the frame index).

This fixes the image_loader for me with webp & gif. They don't load the
animations, but I think that is because I don't have the custom
image_loader set up so I'm not worried about that for myself. I'm not
sure if that part is problematic in general, or if its just the way I
have my features set up.

You can recreate the issue on master by swapping out the dependency
features in the `images` example like this:
```
# egui_extras = { workspace = true, features = ["default", "all_loaders"] }
# env_logger = { version = "0.10", default-features = false, features = [
#   "auto-color",
#   "humantime",
# ] }
# image = { workspace = true, features = ["jpeg", "png"] }
egui_extras = { workspace = true, features = ["image", "svg"] }
env_logger = { version = "0.10", default-features = false, features = [
  "auto-color",
  "humantime",
] }
image = { workspace = true, features = ["jpeg", "png", "webp", "gif"] }
```

* [x] I have followed the instructions in the PR template

---------

Co-authored-by: lucasmerlin <lucasmeurer96@gmail.com>
2025-02-18 17:30:50 +01:00
lucasmerlin a8e98d3f9b
Add `Popup` and `Tooltip`, unifying the previous behaviours (#5713)
This introduces new `Tooltip` and `Popup` structs that unify and extend
the old popups and tooltips.

`Popup` handles the positioning and optionally stores state on whether
the popup is open (for click based popups like `ComboBox`, menus,
context menus).
`Tooltip` is based on `Popup` and handles state of whether the tooltip
should be shown (which turns out to be quite complex to handles all the
edge cases).

Both `Popup` and `Tooltip` can easily be constructed from a `Response`
and then customized via builder methods.

This also introduces `PositionAlign`, for aligning something outside of
a `Rect` (in contrast to `Align2` for aligning inside a `Rect`). But I
don't like the name, any suggestions? Inspired by [mui's tooltip
positioning](https://mui.com/material-ui/react-tooltip/#positioned-tooltips).

* Part of #4607 
* [x] I have followed the instructions in the PR template

TODOs:
- [x] Automatic tooltip positioning based on available space
- [x] Review / fix / remove all code TODOs 
- [x] ~Update the helper fns on `Response` to be consistent in naming
and parameters (Some use tooltip, some hover_ui, some take &self, some
take self)~ actually, I think the naming and parameter make sense on
second thought
- [x] Make sure all old code is marked deprecated

For discussion during review:
- the following check in `show_tooltip_for` still necessary?:
```rust
     let is_touch_screen = ctx.input(|i| i.any_touches());
     let allow_placing_below = !is_touch_screen; // There is a finger below. TODO: Needed?
```
2025-02-18 15:53:07 +01:00
Nicolas 66c73b9cbf
Set hint_text in WidgetInfo (#5724)
The placeholder in kittest is currently not set for TextEdit Fields.
This resolves it 

* [x] I have followed the instructions in the PR template
2025-02-18 12:01:06 +01:00
Andreas Reich 40f002fe3f
Add guidelines for image comparison tests (#5714)
Guidelines & why images may differ

Based on (but slightly altered):
* https://github.com/rerun-io/rerun/pull/8989
2025-02-18 09:52:24 +01:00
lucasmerlin 08c5a641a1
Run a frame per queued event in egui_kittest (#5704)
This should fix the remaining problems with the modifiers
* [x] I have followed the instructions in the PR template
2025-02-12 14:20:50 +01:00
YgorSouza 982b2580f4
Enable all features for egui_kittest docs (#5711)
- Enable all-features when generating docs
- Add x11 feature so it builds on Linux
- Add double hashes to the feature comments so document-features
includes them in the docs

* Closes <https://github.com/emilk/egui/issues/5709>
* [x] I have followed the instructions in the PR template
2025-02-12 14:20:15 +01:00
lucasmerlin 510b3cdf48
Rename `Marginf` to `MarginF32` for consistency with `CornerRadiusF32` (#5677)
* [x] I have followed the instructions in the PR template
2025-02-11 11:23:59 +01:00
lucasmerlin 1c6e7b1bd0
Fix modifiers not working in kittest (#5693)
* Closes <https://github.com/emilk/egui/issues/5690>
* [x] I have followed the instructions in the PR template

It still isn't ideal, since you have to remember to call key_up on a
separate frame.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-02-10 09:33:36 +01:00
Emil Ernerfeldt 81806c4b86 Add badges to kittest README.md 2025-02-07 09:22:10 +01:00
Pēteris Pakalns 54d00d7d69
Fix panic when rendering thin textured rectangles (#5692)
* Closes https://github.com/emilk/egui/issues/5664
* [x] I have followed the instructions in the PR template
2025-02-06 21:37:32 +01:00
Emil Ernerfeldt 0db56dc9f1 Fix the magnification range of the tessellation test 2025-02-04 17:35:55 +01:00
Emil Ernerfeldt 985e569542 Fix warning 2025-02-04 17:04:29 +01:00
Emil Ernerfeldt d7453e42d3 Fix gif in CHANGELOG.md 2025-02-04 17:03:38 +01:00
Lucas Meurer 5c372a7b36 Release 0.31.0 - Scene container, improved rendering quality 2025-02-04 16:47:56 +01:00
Emil Ernerfeldt d97cd82338 Update RELEASES.md 2025-02-04 16:31:10 +01:00
Emil Ernerfeldt f162c3bcbf Explain how to set up generate_changelog.py 2025-02-04 16:30:32 +01:00
Emil Ernerfeldt 95ab92ca4a Protect against mistyping "tessellator" 2025-02-04 16:28:27 +01:00
Emil Ernerfeldt 7ec1fbf467
Fix minor glitch in rendering of selected windows (#5678) 2025-02-04 16:05:36 +01:00
Emil Ernerfeldt c6bda9a38c
Make the ends of vline/hline sharper (#5676)
TL;DR: line caps are annoying in two ways:

A) we only add them for lines wider than a pixel
B) they always make the line longer (if added)
2025-02-04 15:31:51 +01:00
Emil Ernerfeldt c90b97f4ef
Fix sharp corners for rectangles with StrokeKind != Inside (#5675)
Oops!
2025-02-04 14:36:29 +01:00