diff --git a/crates/egui/src/atomics/atom_kind.rs b/crates/egui/src/atomics/atom_kind.rs index f58b39f8..3c54c496 100644 --- a/crates/egui/src/atomics/atom_kind.rs +++ b/crates/egui/src/atomics/atom_kind.rs @@ -41,7 +41,7 @@ pub enum AtomKind<'a> { /// For custom rendering. /// /// You can get the [`crate::Rect`] with the [`Id`] from [`crate::AtomLayoutResponse`] and use a - /// [`crate::Painter`] or [`Ui::put`] to add/draw some custom content. + /// [`crate::Painter`] or [`Ui::place`] to add/draw some custom content. /// /// Example: /// ``` @@ -53,7 +53,7 @@ pub enum AtomKind<'a> { /// /// let rect = response.rect(id); /// if let Some(rect) = rect { - /// ui.put(rect, Button::new("⏵")); + /// ui.place(rect, Button::new("⏵")); /// } /// # }); /// ``` diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 67d210b2..f595469b 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -1710,7 +1710,7 @@ impl Ui { /// The returned [`Response`] can be used to check for interactions, /// as well as adding tooltips using [`Response::on_hover_text`]. /// - /// See also [`Self::add_sized`] and [`Self::put`]. + /// See also [`Self::add_sized`], [`Self::place`] and [`Self::put`]. /// /// ``` /// # egui::__run_test_ui(|ui| { @@ -1729,7 +1729,7 @@ impl Ui { /// /// To fill all remaining area, use `ui.add_sized(ui.available_size(), widget);` /// - /// See also [`Self::add`] and [`Self::put`]. + /// See also [`Self::add`], [`Self::place`] and [`Self::put`]. /// /// ``` /// # egui::__run_test_ui(|ui| { @@ -1748,9 +1748,23 @@ impl Ui { .inner } - /// Add a [`Widget`] to this [`Ui`] at a specific location (manual layout). + /// Add a [`Widget`] to this [`Ui`] at a specific location (manual layout) without + /// affecting this [`Ui`]s cursor. /// - /// See also [`Self::add`] and [`Self::add_sized`]. + /// See also [`Self::add`] and [`Self::add_sized`] and [`Self::put`]. + pub fn place(&mut self, max_rect: Rect, widget: impl Widget) -> Response { + self.new_child( + UiBuilder::new() + .max_rect(max_rect) + .layout(Layout::centered_and_justified(Direction::TopDown)), + ) + .add(widget) + } + + /// Add a [`Widget`] to this [`Ui`] at a specific location (manual layout) and advance the + /// cursor after the widget. + /// + /// See also [`Self::add`], [`Self::add_sized`], and [`Self::place`]. pub fn put(&mut self, max_rect: Rect, widget: impl Widget) -> Response { self.scope_builder( UiBuilder::new()