Restore auto-panning that #2443 had broken (#2562)

* Fix auto panning

* Clean up comments

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Mateo 2025-04-13 19:19:08 -03:00 committed by GitHub
parent b3d6be9618
commit c2a36ce981
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View file

@ -3,6 +3,7 @@ use crate::messages::prelude::*;
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, Hash)]
#[impl_message(Message, BroadcastMessage, TriggerEvent)]
pub enum BroadcastEvent {
/// Triggered by requestAnimationFrame in JS
AnimationFrame,
CanvasTransformed,
ToolAbort,

View file

@ -4,6 +4,7 @@ use crate::messages::input_mapper::utility_types::misc::FrameTimeInfo;
use crate::messages::portfolio::utility_types::KeyboardPlatformLayout;
use crate::messages::prelude::*;
use glam::DVec2;
use std::time::Duration;
pub struct InputPreprocessorMessageData {
pub keyboard_platform: KeyboardPlatformLayout,
@ -97,6 +98,7 @@ impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageData> for
InputPreprocessorMessage::CurrentTime { timestamp } => {
responses.add(AnimationMessage::SetTime(timestamp as f64));
self.time = timestamp;
self.frame_time.advance_timestamp(Duration::from_millis(timestamp));
}
InputPreprocessorMessage::WheelScroll { editor_mouse_state, modifier_keys } => {
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);

View file

@ -152,6 +152,12 @@ impl EditorHandle {
for message in editor.handle_message(AnimationMessage::IncrementFrameCounter) {
handle.send_frontend_message_to_js(message);
}
// Used by auto-panning, but this could possibly be refactored in the future, see:
// <https://github.com/GraphiteEditor/Graphite/pull/2562#discussion_r2041102786>
for message in editor.handle_message(BroadcastMessage::TriggerEvent(BroadcastEvent::AnimationFrame)) {
handle.send_frontend_message_to_js(message);
}
});
}