diff --git a/egui/src/layout.rs b/egui/src/layout.rs index 5a773cc3..fafc8b2e 100644 --- a/egui/src/layout.rs +++ b/egui/src/layout.rs @@ -106,6 +106,14 @@ impl Direction { // ---------------------------------------------------------------------------- /// The layout of a [`Ui`][`crate::Ui`], e.g. "vertical & centered". +/// +/// ``` +/// # let ui = &mut egui::Ui::__test(); +/// ui.with_layout(egui::Layout::right_to_left(), |ui| { +/// ui.label("world!"); +/// ui.label("Hello"); +/// }); +/// ``` #[derive(Clone, Copy, Debug, PartialEq)] // #[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))] pub struct Layout { diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 5701e001..d8fefb88 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -1389,6 +1389,8 @@ impl Ui { /// ui.label("row"); /// }); /// ``` + /// + /// See also [`Self::with_layout`] for more options. #[inline(always)] pub fn horizontal(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse { self.horizontal_with_main_wrap(false, add_contents) @@ -1423,6 +1425,8 @@ impl Ui { /// The returned `Response` will only have checked for mouse hover /// but can be used for tooltips (`on_hover_text`). /// It also contains the `Rect` used by the horizontal layout. + /// + /// See also [`Self::with_layout`] for more options. pub fn horizontal_wrapped( &mut self, add_contents: impl FnOnce(&mut Ui) -> R, @@ -1469,6 +1473,8 @@ impl Ui { /// ui.label("under"); /// }); /// ``` + /// + /// See also [`Self::with_layout`] for more options. #[inline(always)] pub fn vertical(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse { self.with_layout(Layout::top_down(Align::Min), add_contents) @@ -1513,8 +1519,16 @@ impl Ui { /// The new layout will take up all available space. /// - /// Consider using [`Self::allocate_ui_with_layout`] instead, - /// or the helpers [`Self::horizontal]`, [`Self::vertical`], etc. + /// ``` + /// # let ui = &mut egui::Ui::__test(); + /// ui.with_layout(egui::Layout::right_to_left(), |ui| { + /// ui.label("world!"); + /// ui.label("Hello"); + /// }); + /// ``` + /// + /// See also [`Self::allocate_ui_with_layout`], + /// and the helpers [`Self::horizontal]`, [`Self::vertical`], etc. pub fn with_layout( &mut self, layout: Layout,