Add Ui::place, to place widgets without changing the cursor#7359
Merged
lucasmerlin merged 5 commits intomainfrom Sep 4, 2025
Merged
Add Ui::place, to place widgets without changing the cursor#7359lucasmerlin merged 5 commits intomainfrom
Ui::place, to place widgets without changing the cursor#7359lucasmerlin merged 5 commits intomainfrom
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/7359-lucasui-put-cursor |
Ui::put to not affect the current Uis cursorUi::put to not affect the current Uis cursor
Collaborator
Author
|
Change it to Ui::place and deprecate put |
Ui::put to not affect the current Uis cursorUi::place, to place widgets without changing the cursor
Collaborator
Author
|
Ive now added a new |
emilk
approved these changes
Sep 4, 2025
lucasmerlin
added a commit
that referenced
this pull request
Sep 4, 2025
* Closes <#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`?).
lucasmerlin
added a commit
that referenced
this pull request
Sep 4, 2025
* Closes <#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`?).
Masterchef365
pushed a commit
to Masterchef365/egui
that referenced
this pull request
Apr 3, 2026
…7359) * Closes <emilk#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`?).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently
ui.putmoves the cursor after the placed widget. In my opinion that is a bit unexpected and counterproductive in most cases whereui.putmakes sense.The following example breakes with the current behavior and looks right with my change:
I had a look at reruns source code and there are no uses of
ui.putthat 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?).