Skip to content

Commit

Permalink
Bounds Contains update. (#2017)
Browse files Browse the repository at this point in the history
* 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 <hector0193@gmail.com>
  • Loading branch information
Andrew Wheeler(Genusis) and hecrj authored Aug 15, 2023
1 parent 318ee4d commit f5b9562
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...

Expand All @@ -98,6 +99,7 @@ Many thanks to...
- @clarkmoody
- @Davidster
- @Drakulix
- @genusistimelord
- @GyulyVGC
- @ids1024
- @jhff
Expand Down
4 changes: 2 additions & 2 deletions core/src/rectangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impl Rectangle<f32> {
/// 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
Expand Down

0 comments on commit f5b9562

Please sign in to comment.