@@ -82,7 +82,7 @@ impl Default for DocumentMessageHandler {
82
82
document_legacy : DocumentLegacy :: default ( ) ,
83
83
saved_document_identifier : 0 ,
84
84
auto_saved_document_identifier : 0 ,
85
- name : String :: from ( "Untitled Document" ) ,
85
+ name : DEFAULT_DOCUMENT_NAME . to_string ( ) ,
86
86
version : GRAPHITE_DOCUMENT_VERSION . to_string ( ) ,
87
87
commit_hash : crate :: application:: GRAPHITE_GIT_COMMIT_HASH . to_string ( ) ,
88
88
@@ -211,7 +211,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
211
211
// Messages
212
212
AbortTransaction => {
213
213
if !self . undo_in_progress {
214
- self . undo ( responses) . unwrap_or_else ( |e| warn ! ( "{e}" ) ) ;
214
+ self . undo ( responses) ;
215
215
responses. extend ( [ RenderDocument . into ( ) , DocumentStructureChanged . into ( ) ] ) ;
216
216
}
217
217
}
@@ -329,8 +329,8 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
329
329
responses. add_front ( DocumentMessage :: DirtyRenderDocument ) ;
330
330
}
331
331
}
332
- DocumentHistoryBackward => self . undo ( responses) . unwrap_or_else ( |e| warn ! ( "{e}" ) ) ,
333
- DocumentHistoryForward => self . redo ( responses) . unwrap_or_else ( |e| warn ! ( "{e}" ) ) ,
332
+ DocumentHistoryBackward => self . undo ( responses) ,
333
+ DocumentHistoryForward => self . redo ( responses) ,
334
334
DocumentStructureChanged => {
335
335
let data_buffer: RawBuffer = self . serialize_root ( ) . as_slice ( ) . into ( ) ;
336
336
responses. add ( FrontendMessage :: UpdateDocumentLayerTreeStructure { data_buffer } )
@@ -577,7 +577,11 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
577
577
578
578
responses. add ( DocumentMessage :: StartTransaction ) ;
579
579
580
- let image_frame = ImageFrame { image, transform : DAffine2 :: IDENTITY } ;
580
+ let image_frame = ImageFrame {
581
+ image,
582
+ transform : DAffine2 :: IDENTITY ,
583
+ blend_mode : BlendMode :: Normal ,
584
+ } ;
581
585
582
586
use crate :: messages:: tool:: common_functionality:: graph_modification_utils;
583
587
let layer = graph_modification_utils:: new_image_layer ( image_frame, generate_uuid ( ) , self . new_layer_parent ( ) , responses) ;
@@ -649,7 +653,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
649
653
} ) ;
650
654
}
651
655
RollbackTransaction => {
652
- self . rollback ( responses) . unwrap_or_else ( |e| warn ! ( "{e}" ) ) ;
656
+ self . rollback ( responses) ;
653
657
responses. extend ( [ RenderDocument . into ( ) , DocumentStructureChanged . into ( ) ] ) ;
654
658
}
655
659
SaveDocument => {
@@ -771,15 +775,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
771
775
responses. add ( DocumentStructureChanged ) ;
772
776
responses. add ( LayerChanged { affected_layer_path : layer_path } )
773
777
}
774
- SetLayerName { layer_path, name } => {
775
- if let Some ( layer) = self . layer_panel_entry_from_path ( & layer_path, & render_data) {
776
- // Only save the history state if the name actually changed to something different
777
- if layer. name != name {
778
- self . backup ( responses) ;
779
- responses. add ( DocumentOperation :: SetLayerName { path : layer_path, name } ) ;
780
- }
781
- }
782
- }
783
778
SetOpacityForSelectedLayers { opacity } => {
784
779
self . backup ( responses) ;
785
780
let opacity = opacity. clamp ( 0. , 1. ) ;
@@ -1238,9 +1233,9 @@ impl DocumentMessageHandler {
1238
1233
} ) ;
1239
1234
}
1240
1235
1241
- pub fn rollback ( & mut self , responses : & mut VecDeque < Message > ) -> Result < ( ) , EditorError > {
1236
+ pub fn rollback ( & mut self , responses : & mut VecDeque < Message > ) {
1242
1237
self . backup ( responses) ;
1243
- self . undo ( responses)
1238
+ self . undo ( responses) ;
1244
1239
// TODO: Consider if we should check if the document is saved
1245
1240
}
1246
1241
@@ -1257,72 +1252,62 @@ impl DocumentMessageHandler {
1257
1252
DocumentSave { document, layer_metadata }
1258
1253
}
1259
1254
1260
- pub fn undo ( & mut self , responses : & mut VecDeque < Message > ) -> Result < ( ) , EditorError > {
1255
+ pub fn undo ( & mut self , responses : & mut VecDeque < Message > ) {
1261
1256
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
1262
1257
responses. add ( PortfolioMessage :: UpdateOpenDocumentsList ) ;
1263
1258
1264
1259
let selected_paths: Vec < Vec < LayerId > > = self . selected_layers ( ) . map ( |path| path. to_vec ( ) ) . collect ( ) ;
1265
1260
1266
- match self . document_undo_history . pop_back ( ) {
1267
- Some ( DocumentSave { document, layer_metadata } ) => {
1268
- // Update the currently displayed layer on the Properties panel if the selection changes after an undo action
1269
- // Also appropriately update the Properties panel if an undo action results in a layer being deleted
1270
- let prev_selected_paths: Vec < Vec < LayerId > > = layer_metadata. iter ( ) . filter_map ( |( layer_id, metadata) | metadata. selected . then_some ( layer_id. clone ( ) ) ) . collect ( ) ;
1271
-
1272
- if prev_selected_paths != selected_paths {
1273
- responses. add ( BroadcastEvent :: SelectionChanged ) ;
1274
- }
1261
+ if let Some ( DocumentSave { document, layer_metadata } ) = self . document_undo_history . pop_back ( ) {
1262
+ // Update the currently displayed layer on the Properties panel if the selection changes after an undo action
1263
+ // Also appropriately update the Properties panel if an undo action results in a layer being deleted
1264
+ let prev_selected_paths: Vec < Vec < LayerId > > = layer_metadata. iter ( ) . filter_map ( |( layer_id, metadata) | metadata. selected . then_some ( layer_id. clone ( ) ) ) . collect ( ) ;
1275
1265
1276
- let document_save = self . replace_document ( DocumentSave { document, layer_metadata } ) ;
1277
-
1278
- self . document_redo_history . push_back ( document_save) ;
1279
- if self . document_redo_history . len ( ) > crate :: consts:: MAX_UNDO_HISTORY_LEN {
1280
- self . document_redo_history . pop_front ( ) ;
1281
- }
1266
+ if prev_selected_paths != selected_paths {
1267
+ responses. add ( BroadcastEvent :: SelectionChanged ) ;
1268
+ }
1282
1269
1283
- for layer in self . layer_metadata . keys ( ) {
1284
- responses. add ( DocumentMessage :: LayerChanged { affected_layer_path : layer. clone ( ) } )
1285
- }
1270
+ let document_save = self . replace_document ( DocumentSave { document, layer_metadata } ) ;
1286
1271
1287
- responses. add ( NodeGraphMessage :: SendGraph { should_rerender : true } ) ;
1272
+ self . document_redo_history . push_back ( document_save) ;
1273
+ if self . document_redo_history . len ( ) > crate :: consts:: MAX_UNDO_HISTORY_LEN {
1274
+ self . document_redo_history . pop_front ( ) ;
1275
+ }
1288
1276
1289
- Ok ( ( ) )
1277
+ for layer in self . layer_metadata . keys ( ) {
1278
+ responses. add ( DocumentMessage :: LayerChanged { affected_layer_path : layer. clone ( ) } )
1290
1279
}
1291
- None => Err ( EditorError :: NoTransactionInProgress ) ,
1280
+
1281
+ responses. add ( NodeGraphMessage :: SendGraph { should_rerender : true } ) ;
1292
1282
}
1293
1283
}
1294
1284
1295
- pub fn redo ( & mut self , responses : & mut VecDeque < Message > ) -> Result < ( ) , EditorError > {
1285
+ pub fn redo ( & mut self , responses : & mut VecDeque < Message > ) {
1296
1286
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
1297
1287
responses. add ( PortfolioMessage :: UpdateOpenDocumentsList ) ;
1298
1288
1299
1289
let selected_paths: Vec < Vec < LayerId > > = self . selected_layers ( ) . map ( |path| path. to_vec ( ) ) . collect ( ) ;
1300
1290
1301
- match self . document_redo_history . pop_back ( ) {
1302
- Some ( DocumentSave { document, layer_metadata } ) => {
1303
- // Update currently displayed layer on property panel if selection changes after redo action
1304
- // Also appropriately update property panel if redo action results in a layer being added
1305
- let next_selected_paths: Vec < Vec < LayerId > > = layer_metadata. iter ( ) . filter_map ( |( layer_id, metadata) | metadata. selected . then_some ( layer_id. clone ( ) ) ) . collect ( ) ;
1306
-
1307
- if next_selected_paths != selected_paths {
1308
- responses. add ( BroadcastEvent :: SelectionChanged ) ;
1309
- }
1310
-
1311
- let document_save = self . replace_document ( DocumentSave { document, layer_metadata } ) ;
1312
- self . document_undo_history . push_back ( document_save) ;
1313
- if self . document_undo_history . len ( ) > crate :: consts:: MAX_UNDO_HISTORY_LEN {
1314
- self . document_undo_history . pop_front ( ) ;
1315
- }
1291
+ if let Some ( DocumentSave { document, layer_metadata } ) = self . document_redo_history . pop_back ( ) {
1292
+ // Update currently displayed layer on property panel if selection changes after redo action
1293
+ // Also appropriately update property panel if redo action results in a layer being added
1294
+ let next_selected_paths: Vec < Vec < LayerId > > = layer_metadata. iter ( ) . filter_map ( |( layer_id, metadata) | metadata. selected . then_some ( layer_id. clone ( ) ) ) . collect ( ) ;
1316
1295
1317
- for layer in self . layer_metadata . keys ( ) {
1318
- responses. add ( DocumentMessage :: LayerChanged { affected_layer_path : layer . clone ( ) } )
1319
- }
1296
+ if next_selected_paths != selected_paths {
1297
+ responses. add ( BroadcastEvent :: SelectionChanged ) ;
1298
+ }
1320
1299
1321
- responses. add ( NodeGraphMessage :: SendGraph { should_rerender : true } ) ;
1300
+ let document_save = self . replace_document ( DocumentSave { document, layer_metadata } ) ;
1301
+ self . document_undo_history . push_back ( document_save) ;
1302
+ if self . document_undo_history . len ( ) > crate :: consts:: MAX_UNDO_HISTORY_LEN {
1303
+ self . document_undo_history . pop_front ( ) ;
1304
+ }
1322
1305
1323
- Ok ( ( ) )
1306
+ for layer in self . layer_metadata . keys ( ) {
1307
+ responses. add ( DocumentMessage :: LayerChanged { affected_layer_path : layer. clone ( ) } )
1324
1308
}
1325
- None => Err ( EditorError :: NoTransactionInProgress ) ,
1309
+
1310
+ responses. add ( NodeGraphMessage :: SendGraph { should_rerender : true } ) ;
1326
1311
}
1327
1312
}
1328
1313
0 commit comments