Editor structure

The Graphite editor is the application users interact with to create documents. Its code is one Rust crate sandwiched between the frontend and Graphene, the node-based graphics engine. The main business logic of all visual editing is handled by the editor backend. When running in the browser, it is compiled to WebAssembly and passes messages to the frontend.

Message system

The Graphite editor backend is organized into a hierarchy of subsystems which talk to one another through message passing. Messages are pushed to the front or back of a queue and each one is processed sequentially by the editor's dispatcher.

The dispatcher lives at the root of the editor hierarchy and acts as the owner of all its top-level message handlers. This satisfies Rust's restrictions on mutable borrows because only the dispatcher may mutate its message handlers, one at a time, while each message is processed.

Editor outline

Click to explore the outline of the editor subsystem hierarchy which forms the structure of the editor's subsystems, state, and interactions. Bookmark this page to reference it later.

  • Messagemessage.rs
    • Animation
      • AnimationMessageanimation_message.rs
        • ToggleLivePreview
        • EnableLivePreview
        • DisableLivePreview
        • RestartAnimation
        • SetFrameIndex
        • SetTime
        • UpdateTime
        • IncrementFrameCounter
        • SetAnimationTimeMode
      • AnimationMessageHandleranimation_message_handler.rs
        • live_preview_recently_zero: bool
        • timestamp: f64
        • frame_index: f64
        • animation_state: AnimationState
        • fps: f64
        • animation_time_mode: AnimationTimeMode
    • Broadcast
    • Debug
    • Dialog
      • DialogMessagedialog_message.rs
        • ExportDialog
        • NewDocumentDialog
        • PreferencesDialog
        • CloseAllDocumentsWithConfirmation
        • CloseDialogAndThen
        • DisplayDialogError
        • RequestAboutGraphiteDialog
        • RequestAboutGraphiteDialogWithLocalizedCommitDate
        • RequestComingSoonDialog
        • RequestDemoArtworkDialog
        • RequestExportDialog
        • RequestLicensesDialogWithLocalizedCommitDate
        • RequestNewDocumentDialog
        • RequestPreferencesDialog
      • DialogMessageHandlerdialog_message_handler.rs
        • export_dialog: ExportDialogMessageHandler
        • new_document_dialog: NewDocumentDialogMessageHandler
        • preferences_dialog: PreferencesDialogMessageHandler
      • DialogMessageContextdialog_message_handler.rs
        • portfolio: &'a PortfolioMessageHandler
        • preferences: &'a PreferencesMessageHandler
    • Frontend
      • FrontendMessagefrontend_message.rs
        • DisplayDialog
        • DisplayDialogDismiss
        • DisplayDialogPanic
        • DisplayEditableTextbox
        • DisplayEditableTextboxTransform
        • DisplayRemoveEditableTextbox
        • SendUIMetadata
        • TriggerAboutGraphiteLocalizedCommitDate
        • TriggerDelayedZoomCanvasToFitAll
        • TriggerDownloadImage
        • TriggerDownloadTextFile
        • TriggerFetchAndOpenDocument
        • TriggerFontLoad
        • TriggerImport
        • TriggerIndexedDbRemoveDocument
        • TriggerIndexedDbWriteDocument
        • TriggerLoadFirstAutoSaveDocument
        • TriggerLoadRestAutoSaveDocuments
        • TriggerLoadPreferences
        • TriggerOpenDocument
        • TriggerPaste
        • TriggerSavePreferences
        • TriggerSaveActiveDocument
        • TriggerTextCommit
        • TriggerTextCopy
        • TriggerVisitLink
        • UpdateActiveDocument
        • UpdateImportsExports
        • UpdateInSelectedNetwork
        • UpdateBox
        • UpdateContextMenuInformation
        • UpdateClickTargets
        • UpdateGraphViewOverlay
        • UpdateSpreadsheetState
        • UpdateSpreadsheetLayout
        • UpdateImportReorderIndex
        • UpdateExportReorderIndex
        • UpdateLayerWidths
        • UpdateDialogButtons
        • UpdateDialogColumn1
        • UpdateDialogColumn2
        • UpdateDocumentArtwork
        • UpdateImageData
        • UpdateDocumentBarLayout
        • UpdateDocumentLayerDetails
        • UpdateDocumentLayerStructure
        • UpdateDocumentLayerStructureJs
        • UpdateDocumentModeLayout
        • UpdateDocumentRulers
        • UpdateDocumentScrollbars
        • UpdateEyedropperSamplingState
        • UpdateGraphFadeArtwork
        • UpdateInputHints
        • UpdateLayersPanelControlBarLeftLayout
        • UpdateLayersPanelControlBarRightLayout
        • UpdateLayersPanelBottomBarLayout
        • UpdateMenuBarLayout
        • UpdateMouseCursor
        • UpdateNodeGraphNodes
        • UpdateVisibleNodes
        • UpdateNodeGraphWires
        • ClearAllNodeGraphWires
        • UpdateNodeGraphControlBarLayout
        • UpdateNodeGraphSelection
        • UpdateNodeGraphTransform
        • UpdateNodeThumbnail
        • UpdateOpenDocumentsList
        • UpdatePropertyPanelSectionsLayout
        • UpdateToolOptionsLayout
        • UpdateToolShelfLayout
        • UpdateWirePathInProgress
        • UpdateWorkingColorsLayout
    • Globals
    • InputPreprocessor
    • KeyMapping
    • Layout
    • Portfolio
      • PortfolioMessageportfolio_message.rs
        • MenuBar
          • MenuBarMessagemenu_bar_message.rs
            • SendLayout
          • MenuBarMessageHandlermenu_bar_message_handler.rs
            • has_active_document: bool
            • canvas_tilted: bool
            • canvas_flipped: bool
            • rulers_visible: bool
            • node_graph_open: bool
            • has_selected_nodes: bool
            • has_selected_layers: bool
            • has_selection_history: (bool, bool)
            • spreadsheet_view_open: bool
            • message_logging_verbosity: MessageLoggingVerbosity
            • reset_node_definitions_on_open: bool
            • single_path_node_compatible_layer_selected: bool
        • Document
          • DocumentMessagedocument_message.rs
            • Noop
            • GraphOperation
              • GraphOperationMessagegraph_operation_message.rs
                • FillSet
                • BlendingFillSet
                • OpacitySet
                • BlendModeSet
                • ClipModeToggle
                • StrokeSet
                • TransformChange
                • TransformSet
                • Vector
                • Brush
                • SetUpstreamToChain
                • NewArtboard
                • NewBitmapLayer
                • NewBooleanOperationLayer
                • NewCustomLayer
                • NewVectorLayer
                • NewTextLayer
                • ResizeArtboard
                • RemoveArtboards
                • NewSvg
              • GraphOperationMessageContextgraph_operation_message_handler.rs
                • network_interface: &'a mut NodeNetworkInterface
                • collapsed: &'a mut CollapsedLayers
                • node_graph: &'a mut NodeGraphMessageHandler
            • Navigation
              • NavigationMessagenavigation_message.rs
                • BeginCanvasPan
                • BeginCanvasTilt
                • BeginCanvasZoom
                • CanvasPan
                • CanvasPanAbortPrepare
                • CanvasPanAbort
                • CanvasPanByViewportFraction
                • CanvasPanMouseWheel
                • CanvasTiltResetAndZoomTo100Percent
                • CanvasTiltSet
                • CanvasZoomDecrease
                • CanvasZoomIncrease
                • CanvasZoomMouseWheel
                • CanvasZoomSet
                • CanvasFlip
                • EndCanvasPTZ
                • EndCanvasPTZWithClick
                • FitViewportToBounds
                • FitViewportToSelection
                • PointerMove
              • NavigationMessageHandlernavigation_message_handler.rs
                • navigation_operation: NavigationOperation
                • mouse_position: ViewportPosition
                • finish_operation_with_click: bool
                • abortable_pan_start: Option<f64>
              • NavigationMessageContextnavigation_message_handler.rs
                • network_interface: &'a mut NodeNetworkInterface
                • breadcrumb_network_path: &'a [NodeId]
                • ipp: &'a InputPreprocessorMessageHandler
                • document_ptz: &'a mut PTZ
                • graph_view_overlay_open: bool
                • preferences: &'a PreferencesMessageHandler
            • NodeGraph
              • NodeGraphMessagenode_graph_message.rs
                • AddNodes
                • AddPathNode
                • AddImport
                • AddExport
                • Init
                • SelectedNodesUpdated
                • Copy
                • CreateNodeInLayerNoTransaction
                • CreateNodeInLayerWithTransaction
                • CreateNodeFromContextMenu
                • CreateWire
                • ConnectUpstreamOutputToInput
                • Cut
                • DeleteNodes
                • DeleteSelectedNodes
                • DisconnectInput
                • DisconnectRootNode
                • EnterNestedNetwork
                • DuplicateSelectedNodes
                • ExposeInput
                • InsertNode
                • InsertNodeBetween
                • MergeSelectedNodes
                • MoveLayerToStack
                • MoveNodeToChainStart
                • SetChainPosition
                • PasteNodes
                • PointerDown
                • PointerMove
                • PointerUp
                • PointerOutsideViewport
                • ShakeNode
                • RemoveImport
                • RemoveExport
                • ReorderImport
                • ReorderExport
                • RunDocumentGraph
                • ForceRunDocumentGraph
                • SelectedNodesAdd
                • SelectedNodesRemove
                • SelectedNodesSet
                • SendClickTargets
                • EndSendClickTargets
                • UnloadWires
                • SendWires
                • UpdateVisibleNodes
                • SendGraph
                • SetGridAlignedEdges
                • SetInputValue
                • SetInput
                • SetDisplayName
                • SetDisplayNameImpl
                • SetToNodeOrLayer
                • ShiftNodePosition
                • ShiftSelectedNodes
                • ShiftSelectedNodesByAmount
                • TogglePreview
                • TogglePreviewImpl
                • SetImportExportName
                • SetImportExportNameImpl
                • ToggleSelectedAsLayersOrNodes
                • ToggleSelectedLocked
                • ToggleLocked
                • SetLocked
                • ToggleSelectedIsPinned
                • ToggleSelectedVisibility
                • ToggleVisibility
                • SetPinned
                • SetVisibility
                • SetLockedOrVisibilitySideEffects
                • UpdateEdges
                • UpdateBoxSelection
                • UpdateImportsExports
                • UpdateLayerPanel
                • UpdateNewNodeGraph
                • UpdateTypes
                • UpdateActionButtons
                • UpdateGraphBarRight
                • UpdateInSelectedNetwork
                • UpdateHints
                • SendSelectedNodes
              • NodeGraphMessageHandlernode_graph_message_handler.rs
                • network: Vec<NodeId>
                • node_graph_errors: GraphErrors
                • has_selection: bool
                • widgets: [LayoutGroup; 2]
                • begin_dragging: bool
                • node_has_moved_in_drag: bool
                • drag_start: Option<(DragStart, bool)>
                • drag_start_chain_nodes: Vec<NodeId>
                • box_selection_start: Option<(DVec2, bool)>
                • selection_before_pointer_down: Vec<NodeId>
                • shift_without_push: bool
                • disconnecting: Option<InputConnector>
                • initial_disconnecting: bool
                • select_if_not_dragged: Option<NodeId>
                • wire_in_progress_from_connector: Option<DVec2>
                • wire_in_progress_type: FrontendGraphDataType
                • wire_in_progress_to_connector: Option<DVec2>
                • context_menu: Option<ContextMenuInformation>
                • deselect_on_pointer_up: Option<usize>
                • auto_panning: AutoPanning
                • preview_on_mouse_up: Option<NodeId>
                • reordering_import: Option<usize>
                • reordering_export: Option<usize>
                • end_index: Option<usize>
                • frontend_nodes: Vec<NodeId>
                • frontend_wires: HashSet<(NodeId, usize)>
              • NodeGraphMessageContextnode_graph_message_handler.rs
                • network_interface: &'a mut NodeNetworkInterface
                • selection_network_path: &'a [NodeId]
                • breadcrumb_network_path: &'a [NodeId]
                • document_id: DocumentId
                • collapsed: &'a mut CollapsedLayers
                • ipp: &'a InputPreprocessorMessageHandler
                • graph_view_overlay_open: bool
                • graph_fade_artwork_percentage: f64
                • navigation_handler: &'a NavigationMessageHandler
                • preferences: &'a PreferencesMessageHandler
            • Overlays
            • PropertiesPanel
            • AlignSelectedLayers
            • RemoveArtboards
            • ClearLayersPanel
            • CreateEmptyFolder
            • DeleteNode
            • DeleteSelectedLayers
            • DeselectAllLayers
            • DocumentHistoryBackward
            • DocumentHistoryForward
            • DocumentStructureChanged
            • DrawArtboardOverlays
            • DuplicateSelectedLayers
            • EnterNestedNetwork
            • Escape
            • ExitNestedNetwork
            • FlipSelectedLayers
            • RotateSelectedLayers
            • GraphViewOverlay
            • GraphViewOverlayToggle
            • GridOptions
            • GridOverlays
            • GridVisibility
            • GroupSelectedLayers
            • MoveSelectedLayersTo
            • MoveSelectedLayersToGroup
            • NudgeSelectedLayers
            • PasteImage
            • PasteSvg
            • Redo
            • RenameDocument
            • RenderRulers
            • RenderScrollbars
            • SaveDocument
            • SelectParentLayer
            • SelectAllLayers
            • SelectedLayersLower
            • SelectedLayersLowerToBack
            • SelectedLayersRaise
            • SelectedLayersRaiseToFront
            • SelectedLayersReverse
            • SelectedLayersReorder
            • ClipLayer
            • SelectLayer
            • SetActivePanel
            • SetBlendModeForSelectedLayers
            • SetGraphFadeArtwork
            • SetNodePinned
            • SetOpacityForSelectedLayers
            • SetFillForSelectedLayers
            • SetOverlaysVisibility
            • SetRangeSelectionLayer
            • SetSnapping
            • SetToNodeOrLayer
            • SetViewMode
            • AddTransaction
            • StartTransaction
            • EndTransaction
            • CommitTransaction
            • AbortTransaction
            • RepeatedAbortTransaction
            • ToggleLayerExpansion
            • ToggleSelectedVisibility
            • ToggleSelectedLocked
            • ToggleGridVisibility
            • ToggleOverlaysVisibility
            • ToggleSnapping
            • UpdateUpstreamTransforms
            • UpdateClickTargets
            • UpdateClipTargets
            • Undo
            • UngroupSelectedLayers
            • UngroupLayer
            • PTZUpdate
            • SelectionStepBack
            • SelectionStepForward
            • WrapContentInArtboard
            • ZoomCanvasTo100Percent
            • ZoomCanvasTo200Percent
            • ZoomCanvasToFitAll
          • DocumentMessageHandlerdocument_message_handler.rs
            • navigation_handler: NavigationMessageHandler
            • node_graph_handler: NodeGraphMessageHandler
            • overlays_message_handler: OverlaysMessageHandler
            • properties_panel_message_handler: PropertiesPanelMessageHandler
            • network_interface: NodeNetworkInterface
            • collapsed: CollapsedLayers
            • name: String
            • commit_hash: String
            • document_ptz: PTZ
            • document_mode: DocumentMode
            • view_mode: ViewMode
            • overlays_visibility_settings: OverlaysVisibilitySettings
            • rulers_visible: bool
            • snapping_state: SnappingState
            • graph_view_overlay_open: bool
            • graph_fade_artwork_percentage: f64
            • breadcrumb_network_path: Vec<NodeId>
            • selection_network_path: Vec<NodeId>
            • document_undo_history: VecDeque<NodeNetworkInterface>
            • document_redo_history: VecDeque<NodeNetworkInterface>
            • saved_hash: Option<u64>
            • auto_saved_hash: Option<u64>
            • layer_range_selection_reference: Option<LayerNodeIdentifier>
            • is_loaded: bool
          • DocumentMessageContextdocument_message_handler.rs
            • document_id: DocumentId
            • ipp: &'a InputPreprocessorMessageHandler
            • persistent_data: &'a PersistentData
            • executor: &'a mut NodeGraphExecutor
            • current_tool: &'a ToolType
            • preferences: &'a PreferencesMessageHandler
            • device_pixel_ratio: f64
        • Spreadsheet
          • SpreadsheetMessagespreadsheet_message.rs
            • ToggleOpen
            • UpdateLayout
            • PushToInstancePath
            • TruncateInstancePath
            • ViewVectorDataDomain
          • SpreadsheetMessageHandlerspreadsheet_message_handler.rs
            • spreadsheet_view_open: bool
            • inspect_node: Option<NodeId>
            • introspected_data: Option<Arc<dyn Any + Send + Sync>>
            • instances_path: Vec<usize>
            • viewing_vector_data_domain: VectorDataDomain
        • Init
        • DocumentPassMessage
        • AutoSaveActiveDocument
        • AutoSaveAllDocuments
        • AutoSaveDocument
        • CloseActiveDocumentWithConfirmation
        • CloseAllDocuments
        • CloseAllDocumentsWithConfirmation
        • CloseDocument
        • CloseDocumentWithConfirmation
        • Copy
        • Cut
        • DeleteDocument
        • DestroyAllDocuments
        • EditorPreferences
        • FontLoaded
        • Import
        • LoadDocumentResources
        • LoadFont
        • NewDocumentWithName
        • NextDocument
        • OpenDocument
        • OpenDocumentFile
        • ToggleResetNodesToDefinitionsOnOpen
        • OpenDocumentFileWithId
        • PasteIntoFolder
        • PasteSerializedData
        • CenterPastedLayers
        • PasteImage
        • PasteSvg
        • PrevDocument
        • SetActivePanel
        • SetDevicePixelRatio
        • SelectDocument
        • SubmitDocumentExport
        • SubmitActiveGraphRender
        • SubmitGraphRender
        • ToggleRulers
        • UpdateDocumentWidgets
        • UpdateOpenDocumentsList
        • UpdateVelloPreference
      • PortfolioMessageHandlerportfolio_message_handler.rs
        • menu_bar_message_handler: MenuBarMessageHandler
        • documents: HashMap<DocumentId, DocumentMessageHandler>
        • document_ids: VecDeque<DocumentId>
        • active_panel: PanelType
        • active_document_id: Option<DocumentId>
        • copy_buffer: [Vec<CopyBufferEntry>; INTERNAL_CLIPBOARD_COUNT as usize]
        • persistent_data: PersistentData
        • executor: NodeGraphExecutor
        • selection_mode: SelectionMode
        • spreadsheet: SpreadsheetMessageHandler
        • device_pixel_ratio: Option<f64>
        • reset_node_definitions_on_open: bool
      • PortfolioMessageContextportfolio_message_handler.rs
        • ipp: &'a InputPreprocessorMessageHandler
        • preferences: &'a PreferencesMessageHandler
        • current_tool: &'a ToolType
        • message_logging_verbosity: MessageLoggingVerbosity
        • reset_node_definitions_on_open: bool
        • timing_information: TimingInformation
        • animation: &'a AnimationMessageHandler
    • Preferences
      • PreferencesMessagepreferences_message.rs
        • Load
        • ResetToDefaults
        • UseVello
        • SelectionMode
        • VectorMeshes
        • ModifyLayout
        • GraphWireStyle
        • ViewportZoomWheelRate
      • PreferencesMessageHandlerpreferences_message_handler.rs
        • selection_mode: SelectionMode
        • zoom_with_scroll: bool
        • use_vello: bool
        • vector_meshes: bool
        • graph_wire_style: GraphWireStyle
        • viewport_zoom_wheel_rate: f64
    • Tool
      • ToolMessagetool_message.rs
        • TransformLayer
          • TransformLayerMessagetransform_layer_message.rs
            • Overlays
            • ApplyTransformOperation
            • BeginTransformOperation
            • BeginGrab
            • BeginRotate
            • BeginScale
            • BeginGRS
            • BeginGrabPen
            • BeginRotatePen
            • BeginScalePen
            • CancelTransformOperation
            • ConstrainX
            • ConstrainY
            • PointerMove
            • SelectionChanged
            • TypeBackspace
            • TypeDecimalPoint
            • TypeDigit
            • TypeNegate
            • SetPivotGizmo
        • Select
          • SelectToolMessageselect_tool.rs
            • Abort
            • Overlays
            • DragStart
            • DragStop
            • EditLayer
            • Enter
            • PointerMove
            • PointerOutsideViewport
            • SelectOptions
            • SetPivot
            • SyncHistory
            • ShiftSelectedNodes
            • PivotShift
          • SelectToolselect_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: SelectToolFsmState
            • tool_data: SelectToolData
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Artboard
          • ArtboardToolMessageartboard_tool.rs
            • Abort
            • Overlays
            • UpdateSelectedArtboard
            • DeleteSelected
            • NudgeSelected
            • PointerDown
            • PointerMove
            • PointerOutsideViewport
            • PointerUp
          • ArtboardToolartboard_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: ArtboardToolFsmState
            • data: ArtboardToolData
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Navigate
          • NavigateToolMessagenavigate_tool.rs
            • Abort
            • PointerUp
            • PointerMove
            • TiltCanvasBegin
            • ZoomCanvasBegin
            • End
          • NavigateToolnavigate_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: NavigateToolFsmState
            • tool_data: NavigateToolData
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Eyedropper
          • EyedropperToolMessageeyedropper_tool.rs
            • Abort
            • SamplePrimaryColorBegin
            • SamplePrimaryColorEnd
            • PointerMove
            • SampleSecondaryColorBegin
            • SampleSecondaryColorEnd
          • EyedropperTooleyedropper_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: EyedropperToolFsmState
            • data: EyedropperToolData
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Fill
          • FillToolMessagefill_tool.rs
            • Abort
            • WorkingColorChanged
            • Overlays
            • PointerMove
            • PointerUp
            • FillPrimaryColor
            • FillSecondaryColor
          • FillToolfill_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: FillToolFsmState
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Gradient
          • GradientToolMessagegradient_tool.rs
            • Abort
            • Overlays
            • DeleteStop
            • InsertStop
            • PointerDown
            • PointerMove
            • PointerOutsideViewport
            • PointerUp
            • UpdateOptions
          • GradientToolgradient_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: GradientToolFsmState
            • data: GradientToolData
            • options: GradientOptions
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Path
          • PathToolMessagepath_tool.rs
            • Abort
            • Overlays
            • SelectionChanged
            • BreakPath
            • DeselectAllPoints
            • Delete
            • DeleteAndBreakPath
            • DragStop
            • Enter
            • Escape
            • ClosePath
            • DoubleClick
            • GRS
            • ManipulatorMakeHandlesFree
            • ManipulatorMakeHandlesColinear
            • MouseDown
            • NudgeSelectedPoints
            • PointerMove
            • PointerOutsideViewport
            • RightClick
            • SelectAllAnchors
            • SelectedPointUpdated
            • SelectedPointXChanged
            • SelectedPointYChanged
            • SetPivot
            • SwapSelectedHandles
            • UpdateOptions
            • UpdateSelectedPointsStatus
          • PathToolpath_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: PathToolFsmState
            • tool_data: PathToolData
            • options: PathToolOptions
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Pen
          • PenToolMessagepen_tool.rs
            • Abort
            • SelectionChanged
            • WorkingColorChanged
            • Overlays
            • AddPointLayerPosition
            • Confirm
            • DragStart
            • DragStop
            • PointerMove
            • PointerOutsideViewport
            • Redo
            • Undo
            • UpdateOptions
            • RecalculateLatestPointsPosition
            • RemovePreviousHandle
            • GRS
            • FinalPosition
            • SwapHandles
          • PenToolpen_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: PenToolFsmState
            • tool_data: PenToolData
            • options: PenOptions
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Freehand
          • FreehandToolMessagefreehand_tool.rs
            • Overlays
            • Abort
            • WorkingColorChanged
            • DragStart
            • DragStop
            • PointerMove
            • UpdateOptions
          • FreehandToolfreehand_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: FreehandToolFsmState
            • data: FreehandToolData
            • options: FreehandOptions
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Spline
          • SplineToolMessagespline_tool.rs
            • Overlays
            • CanvasTransformed
            • Abort
            • WorkingColorChanged
            • Confirm
            • DragStart
            • DragStop
            • MergeEndpoints
            • PointerMove
            • PointerOutsideViewport
            • Undo
            • UpdateOptions
          • SplineToolspline_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: SplineToolFsmState
            • tool_data: SplineToolData
            • options: SplineOptions
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Shape
          • ShapeToolMessageshape_tool.rs
            • Overlays
            • Abort
            • WorkingColorChanged
            • DragStart
            • DragStop
            • HideShapeTypeWidget
            • PointerMove
            • PointerOutsideViewport
            • UpdateOptions
            • SetShape
            • IncreaseSides
            • DecreaseSides
            • NudgeSelectedLayers
        • Text
          • TextToolMessagetext_tool.rs
            • Abort
            • WorkingColorChanged
            • Overlays
            • DragStart
            • DragStop
            • EditSelected
            • Interact
            • PointerMove
            • PointerOutsideViewport
            • TextChange
            • UpdateBounds
            • UpdateOptions
          • TextTooltext_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: TextToolFsmState
            • tool_data: TextToolData
            • options: TextOptions
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • Brush
          • BrushToolMessagebrush_tool.rs
            • Abort
            • WorkingColorChanged
            • DragStart
            • DragStop
            • PointerMove
            • UpdateOptions
          • BrushToolbrush_tool.rs(violates naming convention — should end with 'Message', 'MessageHandler', or 'MessageContext')
            • fsm_state: BrushToolFsmState
            • data: BrushToolData
            • options: BrushOptions
          • &mut ToolActionMessageContext<'a>utility_types.rs
            • document: &'a mut DocumentMessageHandler
            • document_id: DocumentId
            • global_tool_data: &'a DocumentToolData
            • input: &'a InputPreprocessorMessageHandler
            • font_cache: &'a FontCache
            • shape_editor: &'a mut ShapeState
            • node_graph: &'a NodeGraphExecutor
            • preferences: &'a PreferencesMessageHandler
        • ActivateToolSelect
        • ActivateToolArtboard
        • ActivateToolNavigate
        • ActivateToolEyedropper
        • ActivateToolFill
        • ActivateToolGradient
        • ActivateToolPath
        • ActivateToolPen
        • ActivateToolFreehand
        • ActivateToolSpline
        • ActivateToolShapeLine
        • ActivateToolShapeRectangle
        • ActivateToolShapeEllipse
        • ActivateToolShape
        • ActivateToolText
        • ActivateToolBrush
        • ActivateTool
        • DeactivateTools
        • InitTools
        • PreUndo
        • Redo
        • RefreshToolOptions
        • ResetColors
        • SelectWorkingColor
        • SelectRandomWorkingColor
        • ToggleSelectVsPath
        • SwapColors
        • Undo
        • UpdateCursor
        • UpdateHints
        • UpdateSelectionMode
      • ToolMessageHandlertool_message_handler.rs
        • tool_state: ToolFsmState
        • transform_layer_handler: TransformLayerMessageHandler
        • shape_editor: ShapeState
        • tool_is_active: bool
      • ToolMessageContexttool_message_handler.rs
        • document_id: DocumentId
        • document: &'a mut DocumentMessageHandler
        • input: &'a InputPreprocessorMessageHandler
        • persistent_data: &'a PersistentData
        • node_graph: &'a NodeGraphExecutor
        • preferences: &'a PreferencesMessageHandler
    • Workspace
    • NoOp
    • Batched
    • StartBuffer
    • EndBuffer

Parts of the hierarchy

Subsystem components

  • A *Message enum is the component of an editor subsystem that defines its message interfaces as enum variants. Messages are used for passing a request from anywhere in the application, optionally with some included data, to have a particular block of code be run by its respective message handler.

  • A *MessageHandler struct is the component of an editor subsystem that has ownership over its persistent editor state and its child message handlers for the lifetime of the application. It also defines the logic for handling each of its messages that it receives from the dispatcher. Those blocks of logic may further enqueue additional messages to be processed by itself or other message handlers during the same dispatch cycle.

  • A *MessageContext struct is the component of an editor subsystem that defines what data is made available from other subsystems when running the logic to handle a dispatched message. It is a struct that is passed to the message handler when processing a message, and it gets filled in with data (owned, borrowed, or mutably borrowed) from its parent message handler. Intermediate subsystem layers may forward data from their parent to their child contexts to make state available from further up the hierarchy.

Sub-messages

  • A #[child] * attribute-decorated message enum variant is a special kind of message that encapsulates a nested subsystem. As with all messages, its handler has a manually written code block. But that code must call its corresponding child message handler's process_message method. The child message handler is a field of this parent message handler's state struct.

Messages

  • A * message enum variant is used throughout the editor to request that a certain subsystem performs some action, potentially given some data. In that sense, it resembles a function call, but a key difference is that messages are queued up and processed sequentially in a flat order, always invoked by the dispatcher.

How messages work

Messages are enum variants that are dispatched to perform some intended activity within their respective message handlers. Here are two DocumentMessage definitions:

pub enum DocumentMessage {
	...
	// A message that carries one named data field
	DeleteLayer {
		id: NodeId,
	}
	// A message that carries no data
	DeleteSelectedLayers,
	...
}

As shown above, additional data fields can be included with each message. But as a special case denoted by the #[child] attribute, that data can also be a sub-message enum, which enables hierarchical nesting of message handler subsystems.

By convention, regular data must be written as struct-style named fields (shown above), while a sub-message enum must be written as a tuple/newtype-style field (shown below). The DocumentMessage enum of the previous example is defined as a child of PortfolioMessage which wraps it like this:

pub enum PortfolioMessage {
	...
	// A message that carries the `DocumentMessage` child enum as data
	#[child]
	Document(DocumentMessage),
	...
}

Likewise, the PortfolioMessage enum is wrapped by the top-level Message enum. The dispatcher operates on the queue of these base-level Message types.

So for example, the DeleteSelectedLayers message mentioned previously will look like this as a Message data type:

Message::Portfolio(
	PortfolioMessage::Document(
		DocumentMessage::DeleteSelectedLayers
	)
)

Writing out these nested message enum variants would be cumbersome, so that #[child] attribute shown earlier invokes a proc macro that automatically implements the From trait, letting you write this instead to get a Message data type:

DocumentMessage::DeleteSelectedLayers.into()

Most often, this is simplified even further because the .into() is called for you when pushing a message to the queue with .add() or .add_front(). So this becomes as simple as:

responses.add(DocumentMessage::DeleteSelectedLayers);

The responses message queue is composed of Message data types, and thanks to this system, child messages like DocumentMessage::DeleteSelectedLayers are automatically wrapped in their ancestor enum variants to become a Message, saving you from writing the verbose nested form.