Clear properties panel and layer tree on close (#920)
* Clear properties panel and layer tree on close * Fix on close all documents Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
002b0fc1dd
commit
509aab72c1
|
|
@ -47,6 +47,7 @@ pub enum DocumentMessage {
|
||||||
aggregate: AlignAggregate,
|
aggregate: AlignAggregate,
|
||||||
},
|
},
|
||||||
BooleanOperation(BooleanOperationType),
|
BooleanOperation(BooleanOperationType),
|
||||||
|
ClearLayerTree,
|
||||||
CommitTransaction,
|
CommitTransaction,
|
||||||
CreateEmptyFolder {
|
CreateEmptyFolder {
|
||||||
container_path: Vec<LayerId>,
|
container_path: Vec<LayerId>,
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,20 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||||
);
|
);
|
||||||
responses.push_back(CommitTransaction.into());
|
responses.push_back(CommitTransaction.into());
|
||||||
}
|
}
|
||||||
|
ClearLayerTree => {
|
||||||
|
// Send an empty layer tree
|
||||||
|
let data_buffer: RawBuffer = Self::default().serialize_root().into();
|
||||||
|
responses.push_back(FrontendMessage::UpdateDocumentLayerTreeStructure { data_buffer }.into());
|
||||||
|
|
||||||
|
// Clear the options bar
|
||||||
|
responses.push_back(
|
||||||
|
LayoutMessage::SendLayout {
|
||||||
|
layout: Layout::WidgetLayout(Default::default()),
|
||||||
|
layout_target: LayoutTarget::LayerTreeOptions,
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
CommitTransaction => (),
|
CommitTransaction => (),
|
||||||
CreateEmptyFolder { mut container_path } => {
|
CreateEmptyFolder { mut container_path } => {
|
||||||
let id = generate_uuid();
|
let id = generate_uuid();
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ pub enum PortfolioMessage {
|
||||||
Cut {
|
Cut {
|
||||||
clipboard: Clipboard,
|
clipboard: Clipboard,
|
||||||
},
|
},
|
||||||
|
DeleteDocument {
|
||||||
|
document_id: u64,
|
||||||
|
},
|
||||||
DestroyAllDocuments,
|
DestroyAllDocuments,
|
||||||
FontLoaded {
|
FontLoaded {
|
||||||
font_family: String,
|
font_family: String,
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,10 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||||
responses.push_back(PropertiesPanelMessage::Deactivate.into());
|
responses.push_back(PropertiesPanelMessage::Deactivate.into());
|
||||||
responses.push_back(BroadcastEvent::ToolAbort.into());
|
responses.push_back(BroadcastEvent::ToolAbort.into());
|
||||||
responses.push_back(ToolMessage::DeactivateTools.into());
|
responses.push_back(ToolMessage::DeactivateTools.into());
|
||||||
|
|
||||||
|
// Clear properties panel and layer tree
|
||||||
|
responses.push_back(PropertiesPanelMessage::ClearSelection.into());
|
||||||
|
responses.push_back(DocumentMessage::ClearLayerTree.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
for document_id in &self.document_ids {
|
for document_id in &self.document_ids {
|
||||||
|
|
@ -101,22 +105,14 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||||
}
|
}
|
||||||
PortfolioMessage::CloseDocument { document_id } => {
|
PortfolioMessage::CloseDocument { document_id } => {
|
||||||
let document_index = self.document_index(document_id);
|
// Is this the last document?
|
||||||
self.documents.remove(&document_id);
|
if self.documents.len() == 1 && self.document_ids[0] == document_id {
|
||||||
self.document_ids.remove(document_index);
|
// Clear properties panel and layer tree
|
||||||
|
responses.push_back(PropertiesPanelMessage::ClearSelection.into());
|
||||||
if self.document_ids.is_empty() {
|
responses.push_back(DocumentMessage::ClearLayerTree.into());
|
||||||
self.active_document_id = None;
|
|
||||||
} else if self.active_document_id.is_some() {
|
|
||||||
let document_id = if document_index == self.document_ids.len() {
|
|
||||||
// If we closed the last document take the one previous (same as last)
|
|
||||||
*self.document_ids.last().unwrap()
|
|
||||||
} else {
|
|
||||||
// Move to the next tab
|
|
||||||
self.document_ids[document_index]
|
|
||||||
};
|
|
||||||
responses.push_back(PortfolioMessage::SelectDocument { document_id }.into());
|
|
||||||
}
|
}
|
||||||
|
// Actually delete the document (delay to delete document is required to let the document and properties panel messages above get processed)
|
||||||
|
responses.push_back(PortfolioMessage::DeleteDocument { document_id }.into());
|
||||||
|
|
||||||
// Send the new list of document tab names
|
// Send the new list of document tab names
|
||||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||||
|
|
@ -178,6 +174,24 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||||
responses.push_back(PortfolioMessage::Copy { clipboard }.into());
|
responses.push_back(PortfolioMessage::Copy { clipboard }.into());
|
||||||
responses.push_back(DocumentMessage::DeleteSelectedLayers.into());
|
responses.push_back(DocumentMessage::DeleteSelectedLayers.into());
|
||||||
}
|
}
|
||||||
|
PortfolioMessage::DeleteDocument { document_id } => {
|
||||||
|
let document_index = self.document_index(document_id);
|
||||||
|
self.documents.remove(&document_id);
|
||||||
|
self.document_ids.remove(document_index);
|
||||||
|
|
||||||
|
if self.document_ids.is_empty() {
|
||||||
|
self.active_document_id = None;
|
||||||
|
} else if self.active_document_id.is_some() {
|
||||||
|
let document_id = if document_index == self.document_ids.len() {
|
||||||
|
// If we closed the last document take the one previous (same as last)
|
||||||
|
*self.document_ids.last().unwrap()
|
||||||
|
} else {
|
||||||
|
// Move to the next tab
|
||||||
|
self.document_ids[document_index]
|
||||||
|
};
|
||||||
|
responses.push_back(PortfolioMessage::SelectDocument { document_id }.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
PortfolioMessage::DestroyAllDocuments => {
|
PortfolioMessage::DestroyAllDocuments => {
|
||||||
// Empty the list of internal document data
|
// Empty the list of internal document data
|
||||||
self.documents.clear();
|
self.documents.clear();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue