@@ -7,16 +7,20 @@ use crate::viewport_tools::tool_message_handler::ToolMessageHandler;
77
88use std:: collections:: VecDeque ;
99
10+ use super :: BuildMetadata ;
11+
1012#[ derive( Debug , Default ) ]
1113pub struct Dispatcher {
1214 message_queue : VecDeque < Message > ,
1315 pub responses : Vec < FrontendMessage > ,
1416 message_handlers : DispatcherMessageHandlers ,
17+ build_metadata : BuildMetadata ,
1518}
1619
1720#[ remain:: sorted]
1821#[ derive( Debug , Default ) ]
1922struct DispatcherMessageHandlers {
23+ dialog_message_handler : DialogMessageHandler ,
2024 global_message_handler : GlobalMessageHandler ,
2125 input_mapper_message_handler : InputMapperMessageHandler ,
2226 input_preprocessor_message_handler : InputPreprocessorMessageHandler ,
@@ -31,6 +35,9 @@ struct DispatcherMessageHandlers {
3135const SIDE_EFFECT_FREE_MESSAGES : & [ MessageDiscriminant ] = & [
3236 MessageDiscriminant :: Portfolio ( PortfolioMessageDiscriminant :: Document ( DocumentMessageDiscriminant :: RenderDocument ) ) ,
3337 MessageDiscriminant :: Portfolio ( PortfolioMessageDiscriminant :: Document ( DocumentMessageDiscriminant :: Overlays ( OverlaysMessageDiscriminant :: Rerender ) ) ) ,
38+ MessageDiscriminant :: Portfolio ( PortfolioMessageDiscriminant :: Document ( DocumentMessageDiscriminant :: Artboard (
39+ ArtboardMessageDiscriminant :: RenderArtboards ,
40+ ) ) ) ,
3441 MessageDiscriminant :: Portfolio ( PortfolioMessageDiscriminant :: Document ( DocumentMessageDiscriminant :: FolderChanged ) ) ,
3542 MessageDiscriminant :: Frontend ( FrontendMessageDiscriminant :: UpdateDocumentLayer ) ,
3643 MessageDiscriminant :: Frontend ( FrontendMessageDiscriminant :: DisplayDocumentLayerTreeStructure ) ,
@@ -63,6 +70,11 @@ impl Dispatcher {
6370 match message {
6471 #[ remain:: unsorted]
6572 NoOp => { }
73+ Dialog ( message) => {
74+ self . message_handlers
75+ . dialog_message_handler
76+ . process_action ( message, ( & self . build_metadata , & self . message_handlers . portfolio_message_handler ) , & mut self . message_queue ) ;
77+ }
6678 Frontend ( message) => {
6779 // Image and font loading should be immediately handled
6880 if let FrontendMessage :: UpdateImageData { .. } | FrontendMessage :: TriggerFontLoad { .. } = message {
@@ -101,13 +113,17 @@ impl Dispatcher {
101113 & mut self . message_queue ,
102114 ) ;
103115 }
116+
117+ #[ remain:: unsorted]
118+ PopulateBuildMetadata { new } => self . build_metadata = new,
104119 }
105120 }
106121 }
107122
108123 pub fn collect_actions ( & self ) -> ActionList {
109124 // TODO: Reduce the number of heap allocations
110125 let mut list = Vec :: new ( ) ;
126+ list. extend ( self . message_handlers . dialog_message_handler . actions ( ) ) ;
111127 list. extend ( self . message_handlers . input_preprocessor_message_handler . actions ( ) ) ;
112128 list. extend ( self . message_handlers . input_mapper_message_handler . actions ( ) ) ;
113129 list. extend ( self . message_handlers . global_message_handler . actions ( ) ) ;
@@ -434,18 +450,22 @@ mod test {
434450 } ) ;
435451
436452 for response in responses {
437- if let FrontendMessage :: DisplayDialogError { title, description } = response {
438- println ! ( ) ;
439- println ! ( "-------------------------------------------------" ) ;
440- println ! ( "Failed test due to receiving a DisplayDialogError while loading the graphite sample file!" ) ;
441- println ! ( "This is most likely caused by forgetting to bump the `GRAPHITE_DOCUMENT_VERSION` in `editor/src/consts.rs`" ) ;
442- println ! ( "Once bumping this version number please replace the `graphite-test-document.graphite` with a valid file" ) ;
443- println ! ( "DisplayDialogError details:" ) ;
444- println ! ( "Title: {}" , title) ;
445- println ! ( "description: {}" , description) ;
446- println ! ( "-------------------------------------------------" ) ;
447- println ! ( ) ;
448- panic ! ( )
453+ if let FrontendMessage :: UpdateDialogDetails { layout_target : _, layout } = response {
454+ if let crate :: layout:: widgets:: LayoutRow :: Row { widgets } = & layout[ 0 ] {
455+ if let crate :: layout:: widgets:: Widget :: TextLabel ( crate :: layout:: widgets:: TextLabel { value, .. } ) = & widgets[ 0 ] . widget {
456+ println ! ( ) ;
457+ println ! ( "-------------------------------------------------" ) ;
458+ println ! ( "Failed test due to receiving a DisplayDialogError while loading the Graphite sample file!" ) ;
459+ println ! ( "This is most likely caused by forgetting to bump the `GRAPHITE_DOCUMENT_VERSION` in `editor/src/consts.rs`" ) ;
460+ println ! ( "Once bumping this version number please replace the `graphite-test-document.graphite` with a valid file." ) ;
461+ println ! ( "DisplayDialogError details:" ) ;
462+ println ! ( ) ;
463+ println ! ( "Description: {}" , value) ;
464+ println ! ( "-------------------------------------------------" ) ;
465+ println ! ( ) ;
466+ panic ! ( )
467+ }
468+ }
449469 }
450470 }
451471 }
0 commit comments