mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 01:28:12 +08:00
Rename the message system's 'data' argument to 'context' (#2872)
This commit is contained in:
@@ -7,7 +7,7 @@ use glam::DVec2;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(ExtractField)]
|
||||
pub struct InputPreprocessorMessageData {
|
||||
pub struct InputPreprocessorMessageContext {
|
||||
pub keyboard_platform: KeyboardPlatformLayout,
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ pub struct InputPreprocessorMessageHandler {
|
||||
}
|
||||
|
||||
#[message_handler_data]
|
||||
impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageData> for InputPreprocessorMessageHandler {
|
||||
fn process_message(&mut self, message: InputPreprocessorMessage, responses: &mut VecDeque<Message>, data: InputPreprocessorMessageData) {
|
||||
let InputPreprocessorMessageData { keyboard_platform } = data;
|
||||
impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContext> for InputPreprocessorMessageHandler {
|
||||
fn process_message(&mut self, message: InputPreprocessorMessage, responses: &mut VecDeque<Message>, context: InputPreprocessorMessageContext) {
|
||||
let InputPreprocessorMessageContext { keyboard_platform } = context;
|
||||
|
||||
match message {
|
||||
InputPreprocessorMessage::BoundsOfViewports { bounds_of_viewports } => {
|
||||
@@ -98,7 +98,7 @@ impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageData> for
|
||||
self.translate_mouse_event(mouse_state, false, responses);
|
||||
}
|
||||
InputPreprocessorMessage::CurrentTime { timestamp } => {
|
||||
responses.add(AnimationMessage::SetTime(timestamp as f64));
|
||||
responses.add(AnimationMessage::SetTime { time: timestamp as f64 });
|
||||
self.time = timestamp;
|
||||
self.frame_time.advance_timestamp(Duration::from_millis(timestamp));
|
||||
}
|
||||
@@ -214,10 +214,10 @@ mod test {
|
||||
|
||||
let mut responses = VecDeque::new();
|
||||
|
||||
let data = InputPreprocessorMessageData {
|
||||
let context = InputPreprocessorMessageContext {
|
||||
keyboard_platform: KeyboardPlatformLayout::Standard,
|
||||
};
|
||||
input_preprocessor.process_message(message, &mut responses, data);
|
||||
input_preprocessor.process_message(message, &mut responses, context);
|
||||
|
||||
assert!(input_preprocessor.keyboard.get(Key::Alt as usize));
|
||||
assert_eq!(responses.pop_front(), Some(InputMapperMessage::KeyDown(Key::Alt).into()));
|
||||
@@ -233,10 +233,10 @@ mod test {
|
||||
|
||||
let mut responses = VecDeque::new();
|
||||
|
||||
let data = InputPreprocessorMessageData {
|
||||
let context = InputPreprocessorMessageContext {
|
||||
keyboard_platform: KeyboardPlatformLayout::Standard,
|
||||
};
|
||||
input_preprocessor.process_message(message, &mut responses, data);
|
||||
input_preprocessor.process_message(message, &mut responses, context);
|
||||
|
||||
assert!(input_preprocessor.keyboard.get(Key::Control as usize));
|
||||
assert_eq!(responses.pop_front(), Some(InputMapperMessage::KeyDown(Key::Control).into()));
|
||||
@@ -252,10 +252,10 @@ mod test {
|
||||
|
||||
let mut responses = VecDeque::new();
|
||||
|
||||
let data = InputPreprocessorMessageData {
|
||||
let context = InputPreprocessorMessageContext {
|
||||
keyboard_platform: KeyboardPlatformLayout::Standard,
|
||||
};
|
||||
input_preprocessor.process_message(message, &mut responses, data);
|
||||
input_preprocessor.process_message(message, &mut responses, context);
|
||||
|
||||
assert!(input_preprocessor.keyboard.get(Key::Shift as usize));
|
||||
assert_eq!(responses.pop_front(), Some(InputMapperMessage::KeyDown(Key::Shift).into()));
|
||||
@@ -273,10 +273,10 @@ mod test {
|
||||
|
||||
let mut responses = VecDeque::new();
|
||||
|
||||
let data = InputPreprocessorMessageData {
|
||||
let context = InputPreprocessorMessageContext {
|
||||
keyboard_platform: KeyboardPlatformLayout::Standard,
|
||||
};
|
||||
input_preprocessor.process_message(message, &mut responses, data);
|
||||
input_preprocessor.process_message(message, &mut responses, context);
|
||||
|
||||
assert!(!input_preprocessor.keyboard.get(Key::Control as usize));
|
||||
assert_eq!(responses.pop_front(), Some(InputMapperMessage::KeyUp(Key::Control).into()));
|
||||
@@ -293,10 +293,10 @@ mod test {
|
||||
|
||||
let mut responses = VecDeque::new();
|
||||
|
||||
let data = InputPreprocessorMessageData {
|
||||
let context = InputPreprocessorMessageContext {
|
||||
keyboard_platform: KeyboardPlatformLayout::Standard,
|
||||
};
|
||||
input_preprocessor.process_message(message, &mut responses, data);
|
||||
input_preprocessor.process_message(message, &mut responses, context);
|
||||
|
||||
assert!(input_preprocessor.keyboard.get(Key::Control as usize));
|
||||
assert!(input_preprocessor.keyboard.get(Key::Shift as usize));
|
||||
|
||||
@@ -4,4 +4,4 @@ mod input_preprocessor_message_handler;
|
||||
#[doc(inline)]
|
||||
pub use input_preprocessor_message::{InputPreprocessorMessage, InputPreprocessorMessageDiscriminant};
|
||||
#[doc(inline)]
|
||||
pub use input_preprocessor_message_handler::{InputPreprocessorMessageData, InputPreprocessorMessageHandler};
|
||||
pub use input_preprocessor_message_handler::{InputPreprocessorMessageContext, InputPreprocessorMessageHandler};
|
||||
|
||||
Reference in New Issue
Block a user