use crate::messages::frontend::utility_types::{ExportBounds, FileType}; use crate::messages::portfolio::document::utility_types::layer_panel::LayerMetadata; use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, FlipAxis}; use crate::messages::prelude::*; use document_legacy::boolean_ops::BooleanOperation as BooleanOperationType; use document_legacy::layers::blend_mode::BlendMode; use document_legacy::layers::style::ViewMode; use document_legacy::LayerId; use document_legacy::Operation as DocumentOperation; use graph_craft::document::NodeId; use serde::{Deserialize, Serialize}; #[remain::sorted] #[impl_message(Message, PortfolioMessage, Document)] #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] pub enum DocumentMessage { // Sub-messages #[remain::unsorted] DispatchOperation(Box), #[remain::unsorted] #[child] Artboard(ArtboardMessage), #[remain::unsorted] #[child] Navigation(NavigationMessage), #[remain::unsorted] #[child] Overlays(OverlaysMessage), #[remain::unsorted] #[child] TransformLayer(TransformLayerMessage), #[remain::unsorted] #[child] PropertiesPanel(PropertiesPanelMessage), #[remain::unsorted] #[child] NodeGraph(NodeGraphMessage), // Messages AbortTransaction, AddSelectedLayers { additional_layers: Vec>, }, AlignSelectedLayers { axis: AlignAxis, aggregate: AlignAggregate, }, BooleanOperation(BooleanOperationType), ClearLayerTree, CommitTransaction, CreateEmptyFolder { container_path: Vec, }, DebugPrintDocument, DeleteLayer { layer_path: Vec, }, DeleteSelectedLayers, DeleteSelectedManipulatorPoints, DeselectAllLayers, DeselectAllManipulatorPoints, DirtyRenderDocument, DirtyRenderDocumentInOutlineView, DocumentHistoryBackward, DocumentHistoryForward, DocumentStructureChanged, DuplicateSelectedLayers, ExportDocument { file_name: String, file_type: FileType, scale_factor: f64, bounds: ExportBounds, }, FlipSelectedLayers { flip_axis: FlipAxis, }, FolderChanged { affected_folder_path: Vec, }, FrameClear, GroupSelectedLayers, LayerChanged { affected_layer_path: Vec, }, MoveSelectedLayersTo { folder_path: Vec, insert_index: isize, reverse_index: bool, }, MoveSelectedManipulatorPoints { layer_path: Vec, delta: (f64, f64), }, NodeGraphFrameGenerate, NodeGraphFrameImaginate { imaginate_node: Vec, }, NodeGraphFrameImaginateRandom { imaginate_node: Vec, }, NodeGraphFrameImaginateTerminate { layer_path: Vec, node_path: Vec, }, NudgeSelectedLayers { delta_x: f64, delta_y: f64, }, PasteImage { mime: String, image_data: Vec, mouse: Option<(f64, f64)>, }, Redo, RenameLayer { layer_path: Vec, new_name: String, }, RenderDocument, RollbackTransaction, SaveDocument, SelectAllLayers, SelectedLayersLower, SelectedLayersLowerToBack, SelectedLayersRaise, SelectedLayersRaiseToFront, SelectedLayersReorder { relative_index_offset: isize, }, SelectLayer { layer_path: Vec, ctrl: bool, shift: bool, }, SetBlendModeForSelectedLayers { blend_mode: BlendMode, }, SetImageBlobUrl { layer_path: Vec, blob_url: String, resolution: (f64, f64), document_id: u64, }, SetLayerExpansion { layer_path: Vec, set_expanded: bool, }, SetLayerName { layer_path: Vec, name: String, }, SetOpacityForSelectedLayers { opacity: f64, }, SetOverlaysVisibility { visible: bool, }, SetSelectedLayers { replacement_selected_layers: Vec>, }, SetSnapping { snap: bool, }, SetTextboxEditability { path: Vec, editable: bool, }, SetViewMode { view_mode: ViewMode, }, StartTransaction, ToggleLayerExpansion { layer_path: Vec, }, ToggleLayerVisibility { layer_path: Vec, }, ToggleSelectedHandleMirroring { layer_path: Vec, toggle_distance: bool, toggle_angle: bool, }, Undo, UngroupLayers { folder_path: Vec, }, UngroupSelectedLayers, UpdateLayerMetadata { layer_path: Vec, layer_metadata: LayerMetadata, }, ZoomCanvasTo100Percent, ZoomCanvasTo200Percent, ZoomCanvasToFitAll, } impl From for DocumentMessage { fn from(operation: DocumentOperation) -> DocumentMessage { DocumentMessage::DispatchOperation(Box::new(operation)) } } impl From for Message { fn from(operation: DocumentOperation) -> Message { DocumentMessage::DispatchOperation(Box::new(operation)).into() } }