egui/crates/emath/src
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
..
align.rs Add `Popup` and `Tooltip`, unifying the previous behaviours (#5713) 2025-02-18 15:53:07 +01:00
easing.rs Easing functions (#4630) 2024-06-06 13:09:52 +02:00
gui_rounding.rs Make all lines and rectangles crisp (#5518) 2024-12-26 21:02:27 +01:00
history.rs Remove `extra_asserts` and `extra_debug_asserts` feature flags (#4478) 2024-05-10 19:39:08 +02:00
lib.rs Add `Popup` and `Tooltip`, unifying the previous behaviours (#5713) 2025-02-18 15:53:07 +01:00
numeric.rs Update MSRV to Rust 1.79 (#5421) 2024-12-01 18:58:35 +01:00
ordered_float.rs Remove wildcard imports (#5018) 2024-08-28 12:18:42 +02:00
pos2.rs Remove wildcard imports (#5018) 2024-08-28 12:18:42 +02:00
range.rs Cross-widget text select (#3870) 2024-01-24 15:45:22 +01:00
rect.rs Provide better `debug_assert`s for ray intersections (#5504) 2024-12-19 13:39:14 +01:00
rect_align.rs Add `Popup` and `Tooltip`, unifying the previous behaviours (#5713) 2025-02-18 15:53:07 +01:00
rect_transform.rs Use `Self` everywhere (#3787) 2024-01-08 17:41:21 +01:00
rot2.rs Fix docstring 2024-06-26 09:00:11 +02:00
smart_aim.rs Update MSRV to Rust 1.79 (#5421) 2024-12-01 18:58:35 +01:00
ts_transform.rs Add `egui::Scene` for panning/zooming a `Ui` (#5505) 2025-01-28 20:06:10 +01:00
vec2.rs Add new `Rect::intersects_ray_from_center` method (#5415) 2024-12-02 09:20:59 +01:00
vec2b.rs Update ScrollArea drag velocity when drag stopped (#5175) 2024-10-02 18:12:36 +02:00