From 6a51282933ca90283c2fb9ae2088129157394d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 18 Dec 2020 11:23:22 +0100 Subject: [PATCH] Simplify `cursor_to_center` in `image::Viewer` --- native/src/widget/image/viewer.rs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/native/src/widget/image/viewer.rs b/native/src/widget/image/viewer.rs index ab9f3802..d376e475 100644 --- a/native/src/widget/image/viewer.rs +++ b/native/src/widget/image/viewer.rs @@ -149,23 +149,6 @@ impl<'a> Viewer<'a> { } } -/// Cursor position relative to the [`Viewer`] bounds. -/// -/// [`Viewer`]: struct.Viewer.html -fn relative_cursor_position( - absolute_position: Point, - bounds: Rectangle, -) -> Point { - absolute_position - Vector::new(bounds.x, bounds.y) -} - -/// Center point relative to the [`Viewer`] bounds. -/// -/// [`Viewer`]: struct.Viewer.html -fn relative_center(bounds: Rectangle) -> Point { - bounds.center() - Vector::new(bounds.x, bounds.y) -} - impl<'a, Message, Renderer> Widget for Viewer<'a> where Renderer: self::Renderer + image::Renderer, @@ -241,10 +224,8 @@ where let factor = self.state.scale / previous_scale - 1.0; - let cursor_to_center = relative_cursor_position( - cursor_position, - bounds, - ) - relative_center(bounds); + let cursor_to_center = + cursor_position - bounds.center(); let adjustment = cursor_to_center * factor + self.state.current_offset * factor;