mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 21:58:12 +08:00
Make auto-panning speed uniform (#1690)
* Make auto-panning speed uniform * Abstract time-delta calculation to `TimeInfo` * Update docs and add additional check * Apply code review changes
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::messages::input_mapper::utility_types::input_keyboard::{KeyStates, NU
|
||||
use crate::messages::input_mapper::utility_types::input_mouse::NUMBER_OF_MOUSE_BUTTONS;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use core::time::Duration;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -146,3 +147,22 @@ impl ActionKeys {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct FrameTimeInfo {
|
||||
timestamp: Duration,
|
||||
prev_timestamp: Option<Duration>,
|
||||
}
|
||||
|
||||
impl FrameTimeInfo {
|
||||
pub fn frame_duration(&self) -> Option<Duration> {
|
||||
self.prev_timestamp.map(|prev| self.timestamp - prev)
|
||||
}
|
||||
|
||||
pub fn advance_timestamp(&mut self, next_timestamp: Duration) {
|
||||
debug_assert!(next_timestamp >= self.timestamp);
|
||||
|
||||
self.prev_timestamp = Some(self.timestamp);
|
||||
self.timestamp = next_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user