use super::layer_panel::LayerMetadata; use super::utility_types::{AlignAggregate, AlignAxis, FlipAxis}; use crate::frontend::utility_types::{ExportBounds, FileType}; use crate::message_prelude::*; use graphene::boolean_ops::BooleanOperation as BooleanOperationType; use graphene::layers::blend_mode::BlendMode; use graphene::layers::style::ViewMode; use graphene::LayerId; use graphene::Operation as DocumentOperation; 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] Movement(MovementMessage), #[remain::unsorted] #[child] Overlays(OverlaysMessage), #[remain::unsorted] #[child] TransformLayers(TransformLayerMessage), #[remain::unsorted] #[child] PropertiesPanel(PropertiesPanelMessage), // Messages AbortTransaction, AddSelectedLayers { additional_layers: Vec>, }, AlignSelectedLayers { axis: AlignAxis, aggregate: AlignAggregate, }, BooleanOperation(BooleanOperationType), CommitTransaction, CreateEmptyFolder { container_path: Vec, }, DebugPrintDocument, DeleteLayer { layer_path: Vec, }, DeleteSelectedLayers, DeselectAllLayers, 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, }, GroupSelectedLayers, LayerChanged { affected_layer_path: Vec, }, MoveSelectedLayersTo { folder_path: Vec, insert_index: isize, reverse_index: bool, }, 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, ReorderSelectedLayers { relative_index_offset: isize, }, RollbackTransaction, SaveDocument, SelectAllLayers, SelectionChanged, SelectLayer { layer_path: Vec, ctrl: bool, shift: bool, }, SetBlendModeForSelectedLayers { blend_mode: BlendMode, }, 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, }, SetTexboxEditability { path: Vec, editable: bool, }, SetViewMode { view_mode: ViewMode, }, StartTransaction, ToggleLayerExpansion { layer_path: Vec, }, ToggleLayerVisibility { layer_path: Vec, }, Undo, UngroupLayers { folder_path: Vec, }, UngroupSelectedLayers, UpdateLayerMetadata { layer_path: Vec, layer_metadata: LayerMetadata, }, 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() } }