egui/crates
Lucas Meurer d3cd6d44cf
Add `Ui::place`, to place widgets without changing the cursor (#7359)
* Closes <https://github.com/emilk/egui/issues/7353>

Currently `ui.put` moves the cursor after the placed widget. In my
opinion that is a bit unexpected and counterproductive in most cases
where `ui.put` makes sense.

The following example breakes with the current behavior and looks right
with my change:
```rs
            ui.horizontal(|ui| {
                let custom_button_id = Id::new("custom_button");
                let response = Button::new((
                    Atom::custom(custom_button_id, Vec2::splat(18.0)),
                    "Look at my mini button!",
                ))
                .atom_ui(ui);
                if let Some(rect) = response.rect(custom_button_id) {
                    ui.put(rect, Button::new("🔎").frame_when_inactive(false));
                }

                let custom_button_id = Id::new("custom_button");
                let response = Button::new((
                    Atom::custom(custom_button_id, Vec2::splat(18.0)),
                    "Look at my mini button!",
                ))
                .atom_ui(ui);
                if let Some(rect) = response.rect(custom_button_id) {
                    ui.put(rect, Button::new("🔎").frame_when_inactive(false));
                }
            });

            ui.add_space(10.0);

            let response = ui.button("Notifications");

            ui.put(
                Rect::from_center_size(response.rect.right_top(), Vec2::splat(12.0)),
                |ui: &mut Ui| {
                    Frame::new()
                        .fill(Color32::RED)
                        .corner_radius(10.0)
                        .show(ui, |ui| {
                            ui.label(RichText::new("11").size(8.0).color(Color32::WHITE));
                        }).response
                },
            );

            ui.button("Some other button");
```

<img width="253" height="86" alt="Screenshot 2025-07-14 at 10 58 30"
src="https://github.com/user-attachments/assets/fca56e60-e3c0-4b59-8e2d-0a39aefea9f9"
/>


<img width="361" height="107" alt="Screenshot 2025-07-14 at 10 58 51"
src="https://github.com/user-attachments/assets/85e2fbf9-9174-41e0-adaa-60c721b16bf6"
/>

I had a look at reruns source code and there are no uses of `ui.put`
that would break with this change (very little usages in general).

## Alternatives
Instead of a breaking change we could of course instead introduce a new
metheod (e.g. `Ui::place`?).
2025-09-04 10:07:35 +02:00
..
ecolor Add 0.32.1 to changelogs 2025-08-15 13:42:49 +02:00
eframe Make more dependencies workspace dependencies (#7495) 2025-09-04 09:54:59 +02:00
egui Add `Ui::place`, to place widgets without changing the cursor (#7359) 2025-09-04 10:07:35 +02:00
egui-wgpu Add 0.32.1 to changelogs 2025-08-15 13:42:49 +02:00
egui-winit Improve egui-winit profile scope 2025-08-24 15:03:57 +02:00
egui_demo_app Fix egui_demo_app missing wgpu backends (#7492) 2025-09-03 12:55:02 +02:00
egui_demo_lib fix: `SubMenu` should not display when ui is disabled (#7428) 2025-08-24 14:43:31 +02:00
egui_extras Add theme selection for code editor (#7375) 2025-08-24 16:41:10 +02:00
egui_glow Add 0.32.1 to changelogs 2025-08-15 13:42:49 +02:00
egui_kittest Allow masking widgets in kittest snapshots (#7467) 2025-08-21 17:46:36 +02:00
egui_plot Move `egui_plot` to its own repo (#4828) 2024-07-15 18:45:19 +02:00
egui_web Rename `master` branch to `main` (#7034) 2025-05-08 09:15:42 +02:00
emath Add `emath::fast_midpoint` (#7435) 2025-08-08 12:04:51 +02:00
epaint Selectively update dependencies to reduce total number (#7488) 2025-09-04 09:42:46 +02:00
epaint_default_fonts Add 0.32.1 to changelogs 2025-08-15 13:42:49 +02:00