diff options
author | 2022-12-24 21:27:44 -0800 | |
---|---|---|
committer | 2022-12-29 18:29:15 -0800 | |
commit | 9f85e0c721927f1e3bd195a998ec7a80ec0e7455 (patch) | |
tree | ed4bc6f1f700f9570cc9c72428188d506951d80f /core | |
parent | d91f4f6aa74d0693179a02167d626efa3ac4c20b (diff) | |
download | iced-9f85e0c721927f1e3bd195a998ec7a80ec0e7455.tar.gz iced-9f85e0c721927f1e3bd195a998ec7a80ec0e7455.tar.bz2 iced-9f85e0c721927f1e3bd195a998ec7a80ec0e7455.zip |
Reworked Scrollable to account for lack of widget order guarantees.
Fixed thumb "snapping" bug on scrollable when cursor is out of bounds.
Diffstat (limited to '')
-rw-r--r-- | core/src/point.rs | 8 | ||||
-rw-r--r-- | core/src/rectangle.rs | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/core/src/point.rs b/core/src/point.rs index 9bf7726b..d351befd 100644 --- a/core/src/point.rs +++ b/core/src/point.rs @@ -75,3 +75,11 @@ impl std::ops::Sub<Point> for Point { Vector::new(self.x - point.x, self.y - point.y) } } + +impl std::ops::Add<Point> for Point { + type Output = Point; + + fn add(self, point: Point) -> Point { + Point::new(self.x + point.x, self.y + point.y) + } +} diff --git a/core/src/rectangle.rs b/core/src/rectangle.rs index 4fe91519..c6e6fce4 100644 --- a/core/src/rectangle.rs +++ b/core/src/rectangle.rs @@ -111,6 +111,12 @@ impl Rectangle<f32> { } } +impl std::cmp::PartialOrd for Rectangle<f32> { + fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { + (self.width * self.height).partial_cmp(&(other.width * other.height)) + } +} + impl std::ops::Mul<f32> for Rectangle<f32> { type Output = Self; |