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,
|
||||
},
|
||||
BooleanOperation(BooleanOperationType),
|
||||
ClearLayerTree,
|
||||
CommitTransaction,
|
||||
CreateEmptyFolder {
|
||||
container_path: Vec<LayerId>,
|
||||
|
|
|
|||
|
|
@ -243,6 +243,20 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
|||
);
|
||||
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 => (),
|
||||
CreateEmptyFolder { mut container_path } => {
|
||||
let id = generate_uuid();
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ pub enum PortfolioMessage {
|
|||
Cut {
|
||||
clipboard: Clipboard,
|
||||
},
|
||||
DeleteDocument {
|
||||
document_id: u64,
|
||||
},
|
||||
DestroyAllDocuments,
|
||||
FontLoaded {
|
||||
font_family: String,
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
responses.push_back(PropertiesPanelMessage::Deactivate.into());
|
||||
responses.push_back(BroadcastEvent::ToolAbort.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 {
|
||||
|
|
@ -101,22 +105,14 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||
}
|
||||
PortfolioMessage::CloseDocument { 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());
|
||||
// Is this the last document?
|
||||
if self.documents.len() == 1 && self.document_ids[0] == document_id {
|
||||
// Clear properties panel and layer tree
|
||||
responses.push_back(PropertiesPanelMessage::ClearSelection.into());
|
||||
responses.push_back(DocumentMessage::ClearLayerTree.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
|
||||
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(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 => {
|
||||
// Empty the list of internal document data
|
||||
self.documents.clear();
|
||||
|
|
|
|||
Loading…
Reference in New Issue