image/zoom: No different callbacks for animation
We actually don't need different callbacks for zooms with different targets anymore since the target is an object property anyways.
This commit is contained in:
parent
7e227097ef
commit
f16bd898d6
2 changed files with 6 additions and 13 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
Rotating a freshly opened image would not follow the best-fit scaling.
|
||||||
|
|
@ -263,25 +263,17 @@ impl imp::LpImage {
|
||||||
let animation = self.zoom_animation();
|
let animation = self.zoom_animation();
|
||||||
|
|
||||||
if force_cursor_center {
|
if force_cursor_center {
|
||||||
animation.set_target(&adw::CallbackAnimationTarget::new(glib::clone!(
|
self.zoom_cursor_target.set(None);
|
||||||
#[weak]
|
|
||||||
obj,
|
|
||||||
move |zoom| {
|
|
||||||
obj.imp().set_zoom_aiming(zoom, None);
|
|
||||||
}
|
|
||||||
)));
|
|
||||||
} else {
|
} else {
|
||||||
// Set new point in image that should remain under the cursor while zooming if
|
// Set new point in image that should remain under the cursor while zooming if
|
||||||
// there isn't one already
|
// there isn't one already
|
||||||
if self.zoom_cursor_target.get().is_none() {
|
if self.zoom_cursor_target.get().is_none() {
|
||||||
let img_pos = self
|
let img_pos: Option<(f64, f64)> = self
|
||||||
.pointer_position
|
.pointer_position
|
||||||
.get()
|
.get()
|
||||||
.map(|x| self.widget_to_img_coord(x));
|
.map(|x| self.widget_to_img_coord(x));
|
||||||
self.zoom_cursor_target.set(img_pos);
|
self.zoom_cursor_target.set(img_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
animation.set_target(&adw::PropertyAnimationTarget::new(&obj, "zoom"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
animation.set_value_from(obj.zoom());
|
animation.set_value_from(obj.zoom());
|
||||||
|
|
@ -296,13 +288,13 @@ impl imp::LpImage {
|
||||||
/// Animation that makes larger zoom steps (from buttons etc) look smooth
|
/// Animation that makes larger zoom steps (from buttons etc) look smooth
|
||||||
pub(super) fn zoom_animation(&self) -> &adw::TimedAnimation {
|
pub(super) fn zoom_animation(&self) -> &adw::TimedAnimation {
|
||||||
self.zoom_animation.get_or_init(|| {
|
self.zoom_animation.get_or_init(|| {
|
||||||
let obj = self.obj();
|
let obj = self.obj().to_owned();
|
||||||
|
|
||||||
let animation = adw::TimedAnimation::builder()
|
let animation = adw::TimedAnimation::builder()
|
||||||
.duration(ZOOM_ANIMATION_DURATION)
|
.duration(ZOOM_ANIMATION_DURATION)
|
||||||
.widget(&*obj)
|
.widget(&obj)
|
||||||
// The actual target will be set individually later
|
// The actual target will be set individually later
|
||||||
.target(&adw::CallbackAnimationTarget::new(|_| {}))
|
.target(&adw::PropertyAnimationTarget::new(&obj, "zoom"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
animation.connect_done(glib::clone!(
|
animation.connect_done(glib::clone!(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue