Improve documentation of different ui layout functions
This commit is contained in:
parent
6331bfed90
commit
bb034e2e6c
2 changed files with 24 additions and 2 deletions
|
@ -106,6 +106,14 @@ impl Direction {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// The layout of a [`Ui`][`crate::Ui`], e.g. "vertical & centered".
|
/// 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)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
// #[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
// #[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct Layout {
|
pub struct Layout {
|
||||||
|
|
|
@ -1389,6 +1389,8 @@ impl Ui {
|
||||||
/// ui.label("row");
|
/// ui.label("row");
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// See also [`Self::with_layout`] for more options.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn horizontal<R>(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
pub fn horizontal<R>(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
||||||
self.horizontal_with_main_wrap(false, add_contents)
|
self.horizontal_with_main_wrap(false, add_contents)
|
||||||
|
@ -1423,6 +1425,8 @@ impl Ui {
|
||||||
/// The returned `Response` will only have checked for mouse hover
|
/// The returned `Response` will only have checked for mouse hover
|
||||||
/// but can be used for tooltips (`on_hover_text`).
|
/// but can be used for tooltips (`on_hover_text`).
|
||||||
/// It also contains the `Rect` used by the horizontal layout.
|
/// It also contains the `Rect` used by the horizontal layout.
|
||||||
|
///
|
||||||
|
/// See also [`Self::with_layout`] for more options.
|
||||||
pub fn horizontal_wrapped<R>(
|
pub fn horizontal_wrapped<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
add_contents: impl FnOnce(&mut Ui) -> R,
|
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||||
|
@ -1469,6 +1473,8 @@ impl Ui {
|
||||||
/// ui.label("under");
|
/// ui.label("under");
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// See also [`Self::with_layout`] for more options.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn vertical<R>(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
pub fn vertical<R>(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
||||||
self.with_layout(Layout::top_down(Align::Min), add_contents)
|
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.
|
/// 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<R>(
|
pub fn with_layout<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
layout: Layout,
|
layout: Layout,
|
||||||
|
|
Loading…
Reference in a new issue