diff options
| author | 2024-04-25 01:39:34 +0200 | |
|---|---|---|
| committer | 2024-04-25 01:39:34 +0200 | |
| commit | 0c74d2645649a88799a894ed684a728d135043fa (patch) | |
| tree | 259174b70c65f9c17e8b2157a370169df244722f /widget/src/helpers.rs | |
| parent | 5ef593ce53e0ba53d51809f198a02743f87a6ccd (diff) | |
| download | iced-0c74d2645649a88799a894ed684a728d135043fa.tar.gz iced-0c74d2645649a88799a894ed684a728d135043fa.tar.bz2 iced-0c74d2645649a88799a894ed684a728d135043fa.zip  | |
Implement `Stack` widget
It can be used to stack elements on top of each other!
Diffstat (limited to 'widget/src/helpers.rs')
| -rw-r--r-- | widget/src/helpers.rs | 27 | 
1 files changed, 26 insertions, 1 deletions
diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index 61789c19..2afed3e6 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -21,7 +21,7 @@ use crate::text_input::{self, TextInput};  use crate::toggler::{self, Toggler};  use crate::tooltip::{self, Tooltip};  use crate::vertical_slider::{self, VerticalSlider}; -use crate::{Column, MouseArea, Row, Space, Themer}; +use crate::{Column, MouseArea, Row, Space, Stack, Themer};  use std::borrow::Borrow;  use std::ops::RangeInclusive; @@ -52,6 +52,19 @@ macro_rules! row {      );  } +/// Creates a [`Stack`] with the given children. +/// +/// [`Stack`]: crate::Stack +#[macro_export] +macro_rules! stack { +    () => ( +        $crate::Stack::new() +    ); +    ($($x:expr),+ $(,)?) => ( +        $crate::Stack::with_children([$($crate::core::Element::from($x)),+]) +    ); +} +  /// Creates a new [`Container`] with the provided content.  ///  /// [`Container`]: crate::Container @@ -98,6 +111,18 @@ where      Row::with_children(children)  } +/// Creates a new [`Stack`] with the given children. +/// +/// [`Stack`]: crate::Stack +pub fn stack<'a, Message, Theme, Renderer>( +    children: impl IntoIterator<Item = Element<'a, Message, Theme, Renderer>>, +) -> Stack<'a, Message, Theme, Renderer> +where +    Renderer: core::Renderer, +{ +    Stack::with_children(children) +} +  /// Creates a new [`Scrollable`] with the provided content.  ///  /// [`Scrollable`]: crate::Scrollable  | 
