zoom: Seperate animating/current focal_point
This commit is contained in:
parent
726a53b6b9
commit
909ca8cf9d
3 changed files with 26 additions and 6 deletions
|
|
@ -421,7 +421,7 @@ where
|
|||
let (focal_point, zoom_scale) = zoom_state
|
||||
.map(|state| {
|
||||
(
|
||||
state.focal_point(Some(&output)).to_local(&output),
|
||||
state.animating_focal_point(Some(&output)).to_local(&output),
|
||||
state.animating_level(),
|
||||
)
|
||||
})
|
||||
|
|
@ -729,7 +729,7 @@ where
|
|||
let (focal_point, zoom_scale) = zoom_level
|
||||
.map(|state| {
|
||||
(
|
||||
state.focal_point(Some(&output)).to_local(&output),
|
||||
state.animating_focal_point(Some(&output)).to_local(&output),
|
||||
state.animating_level(),
|
||||
)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ impl OutputZoomState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn focal_point(&mut self) -> Point<f64, Local> {
|
||||
pub fn animating_focal_point(&mut self) -> Point<f64, Local> {
|
||||
if let Some((old_point, start)) = self.previous_point.as_ref() {
|
||||
let duration_since = Instant::now().duration_since(*start);
|
||||
if duration_since > ANIMATION_DURATION {
|
||||
|
|
@ -146,6 +146,10 @@ impl OutputZoomState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn current_focal_point(&mut self) -> Point<f64, Local> {
|
||||
self.focal_point
|
||||
}
|
||||
|
||||
pub fn is_animating(&self) -> bool {
|
||||
self.previous_point.is_some()
|
||||
}
|
||||
|
|
@ -204,11 +208,27 @@ impl ZoomState {
|
|||
self.seat.clone()
|
||||
}
|
||||
|
||||
pub fn focal_point(&self, output: Option<&Output>) -> Point<f64, Global> {
|
||||
pub fn animating_focal_point(&self, output: Option<&Output>) -> Point<f64, Global> {
|
||||
let active_output = self.seat.active_output();
|
||||
let output = output.unwrap_or(&active_output);
|
||||
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
|
||||
let res = output_state.lock().unwrap().focal_point().to_global(output);
|
||||
let res = output_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.animating_focal_point()
|
||||
.to_global(output);
|
||||
res
|
||||
}
|
||||
|
||||
pub fn current_focal_point(&self, output: Option<&Output>) -> Point<f64, Global> {
|
||||
let active_output = self.seat.active_output();
|
||||
let output = output.unwrap_or(&active_output);
|
||||
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
|
||||
let res = output_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.current_focal_point()
|
||||
.to_global(output);
|
||||
res
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ impl OutputExt for Output {
|
|||
let output_state = self.user_data().get::<Mutex<OutputZoomState>>()?;
|
||||
let mut output_state_ref = output_state.lock().unwrap();
|
||||
|
||||
let focal_point = output_state_ref.focal_point().to_global(self);
|
||||
let focal_point = output_state_ref.current_focal_point().to_global(self);
|
||||
let mut zoomed_output_geo = output_geometry.to_f64();
|
||||
zoomed_output_geo.loc -= focal_point;
|
||||
zoomed_output_geo = zoomed_output_geo.downscale(level);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue