From 9f85e0c721927f1e3bd195a998ec7a80ec0e7455 Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Sat, 24 Dec 2022 21:27:44 -0800 Subject: Reworked Scrollable to account for lack of widget order guarantees. Fixed thumb "snapping" bug on scrollable when cursor is out of bounds. --- core/src/point.rs | 8 ++++++++ core/src/rectangle.rs | 6 ++++++ 2 files changed, 14 insertions(+) (limited to 'core') 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 for Point { Vector::new(self.x - point.x, self.y - point.y) } } + +impl std::ops::Add 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 { } } +impl std::cmp::PartialOrd for Rectangle { + fn partial_cmp(&self, other: &Self) -> Option { + (self.width * self.height).partial_cmp(&(other.width * other.height)) + } +} + impl std::ops::Mul for Rectangle { type Output = Self; -- cgit