From ae123d8f14c14a2c393bcf00dc364844a32cc0c8 Mon Sep 17 00:00:00 2001 From: Rowun Giles <1868220+rowungiles@users.noreply.github.com> Date: Mon, 16 Mar 2020 10:08:37 +0000 Subject: [PATCH 1/4] Instantiate Column and Row with children --- native/src/widget/column.rs | 16 ++++++++++++++++ native/src/widget/row.rs | 16 ++++++++++++++++ web/src/widget/column.rs | 16 ++++++++++++++++ web/src/widget/row.rs | 16 ++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index 104790d429..e6c795e5db 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -42,6 +42,22 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { } } + /// Creates a [`Column`] with children. + /// + /// [`Column`]: struct.Column.html + pub fn new_with_children(children: Vec>) -> Self { + Column { + spacing: 0, + padding: 0, + width: Length::Shrink, + height: Length::Shrink, + max_width: u32::MAX, + max_height: u32::MAX, + align_items: Align::Start, + children, + } + } + /// Sets the vertical spacing _between_ elements. /// /// Custom margins per element do not exist in Iced. You should use this diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index 775b953eec..3d803fa28e 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -42,6 +42,22 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { } } + /// Creates a [`Row`] with children. + /// + /// [`Row`]: struct.Row.html + pub fn new_with_children(children: Vec>) -> Self { + Row { + spacing: 0, + padding: 0, + width: Length::Shrink, + height: Length::Shrink, + max_width: u32::MAX, + max_height: u32::MAX, + align_items: Align::Start, + children, + } + } + /// Sets the horizontal spacing _between_ elements. /// /// Custom margins per element do not exist in Iced. You should use this diff --git a/web/src/widget/column.rs b/web/src/widget/column.rs index 6454ffba71..f1d9f9a2ae 100644 --- a/web/src/widget/column.rs +++ b/web/src/widget/column.rs @@ -37,6 +37,22 @@ impl<'a, Message> Column<'a, Message> { } } + /// Creates a [`Column`] with children. + /// + /// [`Column`]: struct.Column.html + pub fn new_with_children(children: Vec>) -> Self { + Column { + spacing: 0, + padding: 0, + width: Length::Fill, + height: Length::Shrink, + max_width: u32::MAX, + max_height: u32::MAX, + align_items: Align::Start, + children, + } + } + /// Sets the vertical spacing _between_ elements. /// /// Custom margins per element do not exist in Iced. You should use this diff --git a/web/src/widget/row.rs b/web/src/widget/row.rs index 02035113f9..55077d5206 100644 --- a/web/src/widget/row.rs +++ b/web/src/widget/row.rs @@ -37,6 +37,22 @@ impl<'a, Message> Row<'a, Message> { } } + /// Creates a [`Row`] with children. + /// + /// [`Row`]: struct.Row.html + pub fn new_with_children(children: Vec>) -> Self { + Row { + spacing: 0, + padding: 0, + width: Length::Fill, + height: Length::Shrink, + max_width: u32::MAX, + max_height: u32::MAX, + align_items: Align::Start, + children, + } + } + /// Sets the horizontal spacing _between_ elements. /// /// Custom margins per element do not exist in Iced. You should use this From a146e53eb0f9bf2714f7f2a4227fe445f4905ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 17 Mar 2020 00:50:23 +0100 Subject: [PATCH 2/4] Rename `new_with_children` to `with_children` --- native/src/widget/column.rs | 6 ++++-- native/src/widget/row.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index e6c795e5db..b38b1ef14b 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -42,10 +42,12 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { } } - /// Creates a [`Column`] with children. + /// Creates a [`Column`] with the given elements. /// /// [`Column`]: struct.Column.html - pub fn new_with_children(children: Vec>) -> Self { + pub fn with_children( + children: Vec>, + ) -> Self { Column { spacing: 0, padding: 0, diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index 3d803fa28e..b71d6480ad 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -42,10 +42,12 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { } } - /// Creates a [`Row`] with children. + /// Creates a [`Row`] with the given elements. /// /// [`Row`]: struct.Row.html - pub fn new_with_children(children: Vec>) -> Self { + pub fn with_children( + children: Vec>, + ) -> Self { Row { spacing: 0, padding: 0, From 95c8031f3d2800ade28b593c17c138c6d389b1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 17 Mar 2020 00:51:01 +0100 Subject: [PATCH 3/4] Reuse `with_children` to remove some duplication --- native/src/widget/column.rs | 11 +---------- native/src/widget/row.rs | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index b38b1ef14b..a7a6f242d5 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -30,16 +30,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { /// /// [`Column`]: struct.Column.html pub fn new() -> Self { - Column { - spacing: 0, - padding: 0, - width: Length::Shrink, - height: Length::Shrink, - max_width: u32::MAX, - max_height: u32::MAX, - align_items: Align::Start, - children: Vec::new(), - } + Self::with_children(Vec::new()) } /// Creates a [`Column`] with the given elements. diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index b71d6480ad..c8812ea262 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -30,16 +30,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { /// /// [`Row`]: struct.Row.html pub fn new() -> Self { - Row { - spacing: 0, - padding: 0, - width: Length::Shrink, - height: Length::Shrink, - max_width: u32::MAX, - max_height: u32::MAX, - align_items: Align::Start, - children: Vec::new(), - } + Self::with_children(Vec::new()) } /// Creates a [`Row`] with the given elements. From 99b5212550f225a21e1d1144c6fb9ebb8f4e6ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 17 Mar 2020 00:53:51 +0100 Subject: [PATCH 4/4] Implement `Column` and `Row` changes in `iced_web` --- web/src/widget/column.rs | 15 +++------------ web/src/widget/row.rs | 15 +++------------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/web/src/widget/column.rs b/web/src/widget/column.rs index f1d9f9a2ae..25b88b0e5b 100644 --- a/web/src/widget/column.rs +++ b/web/src/widget/column.rs @@ -25,22 +25,13 @@ impl<'a, Message> Column<'a, Message> { /// /// [`Column`]: struct.Column.html pub fn new() -> Self { - Column { - spacing: 0, - padding: 0, - width: Length::Fill, - height: Length::Shrink, - max_width: u32::MAX, - max_height: u32::MAX, - align_items: Align::Start, - children: Vec::new(), - } + Self::with_children(Vec::new()) } - /// Creates a [`Column`] with children. + /// Creates a [`Column`] with the given elements. /// /// [`Column`]: struct.Column.html - pub fn new_with_children(children: Vec>) -> Self { + pub fn with_children(children: Vec>) -> Self { Column { spacing: 0, padding: 0, diff --git a/web/src/widget/row.rs b/web/src/widget/row.rs index 55077d5206..cfa10fdf82 100644 --- a/web/src/widget/row.rs +++ b/web/src/widget/row.rs @@ -25,22 +25,13 @@ impl<'a, Message> Row<'a, Message> { /// /// [`Row`]: struct.Row.html pub fn new() -> Self { - Row { - spacing: 0, - padding: 0, - width: Length::Fill, - height: Length::Shrink, - max_width: u32::MAX, - max_height: u32::MAX, - align_items: Align::Start, - children: Vec::new(), - } + Self::with_children(Vec::new()) } - /// Creates a [`Row`] with children. + /// Creates a [`Row`] with the given elements. /// /// [`Row`]: struct.Row.html - pub fn new_with_children(children: Vec>) -> Self { + pub fn with_children(children: Vec>) -> Self { Row { spacing: 0, padding: 0,