run cargo fmt
This commit is contained in:
parent
15f1566578
commit
c9453cd55d
1 changed files with 30 additions and 8 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
//! Zoom and pan on an image.
|
//! Zoom and pan on an image.
|
||||||
use iced_renderer::core::ContentFit;
|
|
||||||
use crate::core::event::{self, Event};
|
use crate::core::event::{self, Event};
|
||||||
use crate::core::image;
|
use crate::core::image;
|
||||||
use crate::core::layout;
|
use crate::core::layout;
|
||||||
|
|
@ -10,6 +9,7 @@ use crate::core::{
|
||||||
Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size,
|
Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size,
|
||||||
Vector, Widget,
|
Vector, Widget,
|
||||||
};
|
};
|
||||||
|
use iced_renderer::core::ContentFit;
|
||||||
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
|
|
@ -182,7 +182,13 @@ where
|
||||||
})
|
})
|
||||||
.clamp(self.min_scale, self.max_scale);
|
.clamp(self.min_scale, self.max_scale);
|
||||||
|
|
||||||
let image_size = image_size(renderer, &self.handle, state, bounds.size(), self.content_fit);
|
let image_size = image_size(
|
||||||
|
renderer,
|
||||||
|
&self.handle,
|
||||||
|
state,
|
||||||
|
bounds.size(),
|
||||||
|
self.content_fit,
|
||||||
|
);
|
||||||
|
|
||||||
let factor = state.scale / previous_scale - 1.0;
|
let factor = state.scale / previous_scale - 1.0;
|
||||||
|
|
||||||
|
|
@ -224,7 +230,7 @@ where
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => {
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => {
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
|
|
||||||
if state.cursor_grabbed_at.is_some() {
|
if state.cursor_grabbed_at.is_some() {
|
||||||
state.cursor_grabbed_at = None;
|
state.cursor_grabbed_at = None;
|
||||||
|
|
||||||
|
|
@ -235,9 +241,15 @@ where
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::CursorMoved { position }) => {
|
Event::Mouse(mouse::Event::CursorMoved { position }) => {
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
|
|
||||||
if let Some(origin) = state.cursor_grabbed_at {
|
if let Some(origin) = state.cursor_grabbed_at {
|
||||||
let image_size = image_size(renderer, &self.handle, state, bounds.size(), self.content_fit);
|
let image_size = image_size(
|
||||||
|
renderer,
|
||||||
|
&self.handle,
|
||||||
|
state,
|
||||||
|
bounds.size(),
|
||||||
|
self.content_fit,
|
||||||
|
);
|
||||||
let hidden_width = (image_size.width - bounds.width / 2.0)
|
let hidden_width = (image_size.width - bounds.width / 2.0)
|
||||||
.max(0.0)
|
.max(0.0)
|
||||||
.round();
|
.round();
|
||||||
|
|
@ -308,9 +320,15 @@ where
|
||||||
let state = tree.state.downcast_ref::<State>();
|
let state = tree.state.downcast_ref::<State>();
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
|
|
||||||
let image_size = image_size(renderer, &self.handle, state, bounds.size(), self.content_fit);
|
let image_size = image_size(
|
||||||
|
renderer,
|
||||||
|
&self.handle,
|
||||||
|
state,
|
||||||
|
bounds.size(),
|
||||||
|
self.content_fit,
|
||||||
|
);
|
||||||
|
|
||||||
let translation = {
|
let translation = {
|
||||||
let image_top_left = Vector::new(
|
let image_top_left = Vector::new(
|
||||||
(bounds.width - image_size.width).max(0.0) / 2.0,
|
(bounds.width - image_size.width).max(0.0) / 2.0,
|
||||||
(bounds.height - image_size.height).max(0.0) / 2.0,
|
(bounds.height - image_size.height).max(0.0) / 2.0,
|
||||||
|
|
@ -327,7 +345,11 @@ where
|
||||||
..bounds
|
..bounds
|
||||||
};
|
};
|
||||||
|
|
||||||
renderer.draw(self.handle.clone(), self.filter_method, drawing_bounds);
|
renderer.draw(
|
||||||
|
self.handle.clone(),
|
||||||
|
self.filter_method,
|
||||||
|
drawing_bounds,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue