From 0abb82033eecf41483f89273cf07c0def40989c6 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Wed, 4 May 2022 11:52:19 -0700 Subject: Fix vertical rule helper --- pure/src/helpers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pure/src/helpers.rs b/pure/src/helpers.rs index 2c4a37be..746b807d 100644 --- a/pure/src/helpers.rs +++ b/pure/src/helpers.rs @@ -202,7 +202,7 @@ pub fn horizontal_rule<'a>(height: u16) -> widget::Rule<'a> { /// /// [`Rule`]: widget::Rule pub fn vertical_rule<'a>(width: u16) -> widget::Rule<'a> { - widget::Rule::horizontal(width) + widget::Rule::vertical(width) } /// Creates a new [`ProgressBar`]. -- cgit From 7087a3d75c9b9decca04bf90ac87038b5f527dd6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 5 May 2022 00:59:21 +0200 Subject: Bump version of `iced_pure` :tada: --- pure/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pure/Cargo.toml b/pure/Cargo.toml index 8369a717..2301031d 100644 --- a/pure/Cargo.toml +++ b/pure/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_pure" -version = "0.2.0" +version = "0.2.1" edition = "2021" description = "Pure widgets for Iced" license = "MIT" -- cgit From 927e1a99d28ef4dc89f9df0f9e56ee40607d739b Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Thu, 5 May 2022 08:56:24 -0700 Subject: Expose pure flex module as public --- pure/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pure/src/lib.rs b/pure/src/lib.rs index 6af74771..fa5fd46f 100644 --- a/pure/src/lib.rs +++ b/pure/src/lib.rs @@ -87,12 +87,11 @@ #![forbid(unsafe_code)] #![forbid(rust_2018_idioms)] +pub mod flex; pub mod helpers; pub mod overlay; pub mod widget; -pub(crate) mod flex; - mod element; pub use element::Element; -- cgit From f1c1d519c5be7f9f0bbd32b22635659a803425e2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 6 May 2022 19:42:14 +0200 Subject: Take `AsRef` instead of `Element` in `Tree` API --- pure/src/element.rs | 8 ++++++++ pure/src/widget/tree.rs | 32 +++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/pure/src/element.rs b/pure/src/element.rs index 704b3d0b..5b5038c8 100644 --- a/pure/src/element.rs +++ b/pure/src/element.rs @@ -321,3 +321,11 @@ where .map(move |overlay| overlay.map(mapper)) } } + +impl<'a, Message, Renderer> AsRef + 'a> + for Element<'a, Message, Renderer> +{ + fn as_ref(&self) -> &(dyn Widget + 'a) { + self.widget.as_ref() + } +} diff --git a/pure/src/widget/tree.rs b/pure/src/widget/tree.rs index d81dd02c..28249fe6 100644 --- a/pure/src/widget/tree.rs +++ b/pure/src/widget/tree.rs @@ -1,5 +1,5 @@ //! Store internal widget state in a state tree to ensure continuity. -use crate::Element; +use crate::Widget; use std::any::{self, Any}; @@ -28,13 +28,15 @@ impl Tree { } /// Creates a new [`Tree`] for the provided [`Element`]. - pub fn new( - element: &Element<'_, Message, Renderer>, + pub fn new<'a, Message, Renderer>( + widget: impl AsRef + 'a>, ) -> Self { + let widget = widget.as_ref(); + Self { - tag: element.as_widget().tag(), - state: element.as_widget().state(), - children: element.as_widget().children(), + tag: widget.tag(), + state: widget.state(), + children: widget.children(), } } @@ -46,23 +48,27 @@ impl Tree { /// Otherwise, the whole [`Tree`] is recreated. /// /// [`Widget::diff`]: crate::Widget::diff - pub fn diff( + pub fn diff<'a, Message, Renderer>( &mut self, - new: &Element<'_, Message, Renderer>, + new: impl AsRef + 'a>, ) { - if self.tag == new.as_widget().tag() { - new.as_widget().diff(self) + if self.tag == new.as_ref().tag() { + new.as_ref().diff(self) } else { *self = Self::new(new); } } /// Reconciliates the children of the tree with the provided list of [`Element`]. - pub fn diff_children( + pub fn diff_children<'a, Message, Renderer>( &mut self, - new_children: &[Element<'_, Message, Renderer>], + new_children: &[impl AsRef + 'a>], ) { - self.diff_children_custom(new_children, Self::diff, Self::new) + self.diff_children_custom( + new_children, + |tree, widget| Self::diff(tree, widget), + |widget| Self::new(widget), + ) } /// Reconciliates the children of the tree with the provided list of [`Element`] using custom -- cgit From 59aeb20600661e55e59223a309146eea68b4c32f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 6 May 2022 23:35:13 +0200 Subject: Use `Borrow` instead of `AsRef` to allow easier casting --- pure/src/element.rs | 16 +++++++++++++--- pure/src/widget/tree.rs | 17 +++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pure/src/element.rs b/pure/src/element.rs index 5b5038c8..5450db20 100644 --- a/pure/src/element.rs +++ b/pure/src/element.rs @@ -8,6 +8,8 @@ use iced_native::mouse; use iced_native::renderer; use iced_native::{Clipboard, Length, Point, Rectangle, Shell}; +use std::borrow::Borrow; + /// A generic [`Widget`]. /// /// It is useful to build composable user interfaces that do not leak @@ -322,10 +324,18 @@ where } } -impl<'a, Message, Renderer> AsRef + 'a> +impl<'a, Message, Renderer> Borrow + 'a> for Element<'a, Message, Renderer> { - fn as_ref(&self) -> &(dyn Widget + 'a) { - self.widget.as_ref() + fn borrow(&self) -> &(dyn Widget + 'a) { + self.widget.borrow() + } +} + +impl<'a, Message, Renderer> Borrow + 'a> + for &Element<'a, Message, Renderer> +{ + fn borrow(&self) -> &(dyn Widget + 'a) { + self.widget.borrow() } } diff --git a/pure/src/widget/tree.rs b/pure/src/widget/tree.rs index 28249fe6..0bb3107a 100644 --- a/pure/src/widget/tree.rs +++ b/pure/src/widget/tree.rs @@ -2,6 +2,7 @@ use crate::Widget; use std::any::{self, Any}; +use std::borrow::Borrow; /// A persistent state widget tree. /// @@ -29,9 +30,9 @@ impl Tree { /// Creates a new [`Tree`] for the provided [`Element`]. pub fn new<'a, Message, Renderer>( - widget: impl AsRef + 'a>, + widget: impl Borrow + 'a>, ) -> Self { - let widget = widget.as_ref(); + let widget = widget.borrow(); Self { tag: widget.tag(), @@ -50,10 +51,10 @@ impl Tree { /// [`Widget::diff`]: crate::Widget::diff pub fn diff<'a, Message, Renderer>( &mut self, - new: impl AsRef + 'a>, + new: impl Borrow + 'a>, ) { - if self.tag == new.as_ref().tag() { - new.as_ref().diff(self) + if self.tag == new.borrow().tag() { + new.borrow().diff(self) } else { *self = Self::new(new); } @@ -62,12 +63,12 @@ impl Tree { /// Reconciliates the children of the tree with the provided list of [`Element`]. pub fn diff_children<'a, Message, Renderer>( &mut self, - new_children: &[impl AsRef + 'a>], + new_children: &[impl Borrow + 'a>], ) { self.diff_children_custom( new_children, - |tree, widget| Self::diff(tree, widget), - |widget| Self::new(widget), + |tree, widget| tree.diff(widget.borrow()), + |widget| Self::new(widget.borrow()), ) } -- cgit From 46e61ae4ebf211739597ac156f5c84ba2eb3797e Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Mon, 9 May 2022 17:19:45 +0800 Subject: Add note about resolver requirement --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3d1e6e1e..d4b7b39f 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ Add `iced` as a dependency in your `Cargo.toml`: iced = "0.4" ``` +If your project is using a Rust edition older than 2021, then you will need to +set `resolver = "2"` in the `[package]` section as well. + __Iced moves fast and the `master` branch can contain breaking changes!__ If you want to learn about a specific release, check out [the release list]. -- cgit From 48d25009af415d99f8a7155f117a3979e5aceba5 Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Mon, 9 May 2022 17:28:51 +0800 Subject: Add missing versions to issue template --- .github/ISSUE_TEMPLATE/BUG-REPORT.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml index 9d0eb2ed..0e275a63 100644 --- a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml @@ -60,6 +60,9 @@ body: description: What version of iced are you using? options: - master + - 0.4.2 + - 0.4.1 + - 0.4.0 - 0.3.0 validations: required: true -- cgit From af1ff677545c9354aa8ae09d40b99317a6dd9613 Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Tue, 10 May 2022 06:27:45 +0800 Subject: Drop older versions from list --- .github/ISSUE_TEMPLATE/BUG-REPORT.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml index 0e275a63..8500f2aa 100644 --- a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml @@ -60,10 +60,7 @@ body: description: What version of iced are you using? options: - master - - 0.4.2 - - 0.4.1 - - 0.4.0 - - 0.3.0 + - "0.4" validations: required: true - type: dropdown -- cgit From 82e11e04f2cf067a293c80127aaf9b60177a1126 Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Tue, 10 May 2022 06:31:07 +0800 Subject: Add note about using the latest patch --- .github/ISSUE_TEMPLATE/BUG-REPORT.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml index 8500f2aa..ad60918c 100644 --- a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml @@ -57,7 +57,7 @@ body: id: version attributes: label: Version - description: What version of iced are you using? + description: What version of iced are you using? Please ensure it's the latest patch. options: - master - "0.4" -- cgit From 42c61a5c449f7b761189e5c35c9dc8920f89e4a5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 10 May 2022 01:18:06 +0200 Subject: Elaborate on supported versions in `BUG-REPORT.yml` --- .github/ISSUE_TEMPLATE/BUG-REPORT.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml index ad60918c..0c06c405 100644 --- a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml @@ -57,10 +57,16 @@ body: id: version attributes: label: Version - description: What version of iced are you using? Please ensure it's the latest patch. + description: | + We only offer support for the `0.4` release on crates.io and the `master` + branch on this repository. Which version are you using? Please make sure + you are using the latest patch available (e.g. run `cargo update`). + + If you are using an older release, please upgrade to `0.4` before filing + an issue. options: - master - - "0.4" + - 0.4 validations: required: true - type: dropdown -- cgit From d4ed8afa1ed15486144dc7afee52c09e044a92e0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 10 May 2022 01:20:06 +0200 Subject: Fix unnecessary newlines in `BUG-REPORT.yml` --- .github/ISSUE_TEMPLATE/BUG-REPORT.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml index 0c06c405..96dcc3b6 100644 --- a/.github/ISSUE_TEMPLATE/BUG-REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG-REPORT.yml @@ -58,12 +58,9 @@ body: attributes: label: Version description: | - We only offer support for the `0.4` release on crates.io and the `master` - branch on this repository. Which version are you using? Please make sure - you are using the latest patch available (e.g. run `cargo update`). + We only offer support for the `0.4` release on crates.io and the `master` branch on this repository. Which version are you using? Please make sure you are using the latest patch available (e.g. run `cargo update`). - If you are using an older release, please upgrade to `0.4` before filing - an issue. + If you are using an older release, please upgrade to `0.4` before filing an issue. options: - master - 0.4 -- cgit