Fix property panel selection when layer is added or deleted through undo/redo action (#716)
* Fixed layer property panel visibility for a deleted layer through an undo action * Fix visible layer in property panel using broadcast signal for undo and redo actions * Changed redo variable name to "next_selected_paths" * Code review nit picks Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
05b93ae3f4
commit
5d1d93917d
|
|
@ -365,14 +365,26 @@ impl DocumentMessageHandler {
|
|||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||
|
||||
let selected_paths: Vec<Vec<LayerId>> = self.selected_layers().map(|path| path.to_vec()).collect();
|
||||
|
||||
match self.document_undo_history.pop() {
|
||||
Some((document, layer_metadata)) => {
|
||||
// Update the currently displayed layer on the Properties panel if the selection changes after an undo action
|
||||
// Also appropriately update the Properties panel if an undo action results in a layer being deleted
|
||||
let prev_selected_paths: Vec<Vec<LayerId>> = layer_metadata.iter().filter_map(|(layer_id, metadata)| metadata.selected.then(|| layer_id.clone())).collect();
|
||||
|
||||
if prev_selected_paths != selected_paths {
|
||||
responses.push_back(BroadcastSignal::SelectionChanged.into());
|
||||
}
|
||||
|
||||
let document = std::mem::replace(&mut self.graphene_document, document);
|
||||
let layer_metadata = std::mem::replace(&mut self.layer_metadata, layer_metadata);
|
||||
self.document_redo_history.push((document, layer_metadata));
|
||||
|
||||
for layer in self.layer_metadata.keys() {
|
||||
responses.push_back(DocumentMessage::LayerChanged { affected_layer_path: layer.clone() }.into())
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
None => Err(EditorError::NoTransactionInProgress),
|
||||
|
|
@ -383,14 +395,26 @@ impl DocumentMessageHandler {
|
|||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||
|
||||
let selected_paths: Vec<Vec<LayerId>> = self.selected_layers().map(|path| path.to_vec()).collect();
|
||||
|
||||
match self.document_redo_history.pop() {
|
||||
Some((document, layer_metadata)) => {
|
||||
// Update currently displayed layer on property panel if selection changes after redo action
|
||||
// Also appropriately update property panel if redo action results in a layer being added
|
||||
let next_selected_paths: Vec<Vec<LayerId>> = layer_metadata.iter().filter_map(|(layer_id, metadata)| metadata.selected.then(|| layer_id.clone())).collect();
|
||||
|
||||
if next_selected_paths != selected_paths {
|
||||
responses.push_back(BroadcastSignal::SelectionChanged.into());
|
||||
}
|
||||
|
||||
let document = std::mem::replace(&mut self.graphene_document, document);
|
||||
let layer_metadata = std::mem::replace(&mut self.layer_metadata, layer_metadata);
|
||||
self.document_undo_history.push((document, layer_metadata));
|
||||
|
||||
for layer in self.layer_metadata.keys() {
|
||||
responses.push_back(DocumentMessage::LayerChanged { affected_layer_path: layer.clone() }.into())
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
None => Err(EditorError::NoTransactionInProgress),
|
||||
|
|
|
|||
Loading…
Reference in New Issue