-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Ui::place
, to place widgets without changing the cursor
#7359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
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
Ive now added a new |
* 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`?).
* 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`?).
Currently
ui.put
moves the cursor after the placed widget. In my opinion that is a bit unexpected and counterproductive in most cases whereui.put
makes 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.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
?).