Code cleanup and refactoring to enhance consistency (#1695)

- Move message handler payload data into structs
- Organize the file structure used by `editor/src/messages/portfolio/document` `/node_graph` and `/graph_operation`
- Make derive attributes use `serde::Serialize, serde::Deserialize` consistently instead of `use serde::{Deserialize, Serialize};` imports
- Various other code cleanup and refactoring
This commit is contained in:
Keavon Chambers
2024-03-20 21:28:51 -07:00
committed by GitHub
parent ed3f7acdd7
commit 0a9bd41be1
134 changed files with 1860 additions and 1865 deletions
@@ -9,6 +9,14 @@ use crate::node_graph_executor::NodeGraphExecutor;
use graphene_core::raster::color::Color;
pub struct ToolMessageData<'a> {
pub document_id: DocumentId,
pub document: &'a DocumentMessageHandler,
pub input: &'a InputPreprocessorMessageHandler,
pub persistent_data: &'a PersistentData,
pub node_graph: &'a NodeGraphExecutor,
}
#[derive(Debug, Default)]
pub struct ToolMessageHandler {
pub tool_state: ToolFsmState,
@@ -16,13 +24,15 @@ pub struct ToolMessageHandler {
pub shape_editor: ShapeState,
}
impl MessageHandler<ToolMessage, (&DocumentMessageHandler, DocumentId, &InputPreprocessorMessageHandler, &PersistentData, &NodeGraphExecutor)> for ToolMessageHandler {
fn process_message(
&mut self,
message: ToolMessage,
responses: &mut VecDeque<Message>,
(document, document_id, input, persistent_data, node_graph): (&DocumentMessageHandler, DocumentId, &InputPreprocessorMessageHandler, &PersistentData, &NodeGraphExecutor),
) {
impl MessageHandler<ToolMessage, ToolMessageData<'_>> for ToolMessageHandler {
fn process_message(&mut self, message: ToolMessage, responses: &mut VecDeque<Message>, data: ToolMessageData) {
let ToolMessageData {
document_id,
document,
input,
persistent_data,
node_graph,
} = data;
let font_cache = &persistent_data.font_cache;
match message {