summaryrefslogtreecommitdiffstats
path: root/native/src/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-12-18 11:00:13 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-12-18 11:00:32 +0100
commit4eb5779542e3d53d2a41f30f259640bb2f8069fd (patch)
tree81073cb62728a6b082299e011b79d5922d255f7b /native/src/widget
parentcf97982929c2c5e4487e4ae0236b24749fca3013 (diff)
downloadiced-4eb5779542e3d53d2a41f30f259640bb2f8069fd.tar.gz
iced-4eb5779542e3d53d2a41f30f259640bb2f8069fd.tar.bz2
iced-4eb5779542e3d53d2a41f30f259640bb2f8069fd.zip
Remove redundant `f32` conversions in `image::Viewer`
Diffstat (limited to 'native/src/widget')
-rw-r--r--native/src/widget/image/viewer.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/native/src/widget/image/viewer.rs b/native/src/widget/image/viewer.rs
index 0f081a1a..605298f1 100644
--- a/native/src/widget/image/viewer.rs
+++ b/native/src/widget/image/viewer.rs
@@ -371,12 +371,11 @@ impl State {
/// [`Viewer`]: struct.Viewer.html
/// [`State`]: struct.State.html
fn pan(&mut self, x: f32, y: f32, bounds: Rectangle, image_size: Size) {
- let hidden_width = ((image_size.width - bounds.width) as f32 / 2.0)
- .max(0.0)
- .round();
- let hidden_height = ((image_size.height - bounds.height) as f32 / 2.0)
- .max(0.0)
- .round();
+ let hidden_width =
+ (image_size.width - bounds.width / 2.0).max(0.0).round();
+
+ let hidden_height =
+ (image_size.height - bounds.height / 2.0).max(0.0).round();
let delta_x = x - self.starting_cursor_pos.unwrap().x;
let delta_y = y - self.starting_cursor_pos.unwrap().y;
@@ -400,12 +399,11 @@ impl State {
/// [`Viewer`]: struct.Viewer.html
/// [`State`]: struct.State.html
fn offset(&self, bounds: Rectangle, image_size: Size) -> Vector {
- let hidden_width = ((image_size.width - bounds.width) as f32 / 2.0)
- .max(0.0)
- .round();
- let hidden_height = ((image_size.height - bounds.height) as f32 / 2.0)
- .max(0.0)
- .round();
+ let hidden_width =
+ (image_size.width - bounds.width / 2.0).max(0.0).round();
+
+ let hidden_height =
+ (image_size.height - bounds.height / 2.0).max(0.0).round();
Vector::new(
self.current_offset