From f5b95629009ecde8c6f6388c8f33ec43d30d17d1 Mon Sep 17 00:00:00 2001 From: "Andrew Wheeler(Genusis)" Date: Tue, 15 Aug 2023 01:47:53 -0400 Subject: Bounds Contains update. (#2017) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * changed the way contains works to exclude <= for point.y and point.x on width and height check to avoid multiple selects * update changelog * Update `CHANGELOG` --------- Co-authored-by: Héctor Ramón Jiménez --- CHANGELOG.md | 2 ++ core/src/rectangle.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a87c1a..5d9c7349 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `image::Viewer` reacting to any scroll event. [#1998](https://github.com/iced-rs/iced/pull/1998) - `TextInput` pasting text when `Alt` key is pressed. [#2006](https://github.com/iced-rs/iced/pull/2006) - Broken link to old `iced_native` crate in `README`. [#2024](https://github.com/iced-rs/iced/pull/2024) +- `Rectangle::contains` being non-exclusive. [#2017](https://github.com/iced-rs/iced/pull/2017) Many thanks to... @@ -98,6 +99,7 @@ Many thanks to... - @clarkmoody - @Davidster - @Drakulix +- @genusistimelord - @GyulyVGC - @ids1024 - @jhff diff --git a/core/src/rectangle.rs b/core/src/rectangle.rs index db56aa18..c1c2eeac 100644 --- a/core/src/rectangle.rs +++ b/core/src/rectangle.rs @@ -74,9 +74,9 @@ impl Rectangle { /// Returns true if the given [`Point`] is contained in the [`Rectangle`]. pub fn contains(&self, point: Point) -> bool { self.x <= point.x - && point.x <= self.x + self.width + && point.x < self.x + self.width && self.y <= point.y - && point.y <= self.y + self.height + && point.y < self.y + self.height } /// Returns true if the current [`Rectangle`] is completely within the given -- cgit