Fix serialising document (#1526)
* Fix serialising document * Remove unused import --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
92203f3576
commit
4733134b22
|
|
@ -72,8 +72,6 @@ pub struct DocumentMessageHandler {
|
||||||
pub commit_hash: String,
|
pub commit_hash: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub collapsed: Vec<LayerNodeIdentifier>,
|
pub collapsed: Vec<LayerNodeIdentifier>,
|
||||||
#[serde(default)]
|
|
||||||
pub selected: HashMap<Vec<LayerId>, bool>,
|
|
||||||
|
|
||||||
// Fields omitted from the saved document format
|
// Fields omitted from the saved document format
|
||||||
//
|
//
|
||||||
|
|
@ -114,7 +112,6 @@ impl Default for DocumentMessageHandler {
|
||||||
document_undo_history: VecDeque::new(),
|
document_undo_history: VecDeque::new(),
|
||||||
document_redo_history: VecDeque::new(),
|
document_redo_history: VecDeque::new(),
|
||||||
undo_in_progress: false,
|
undo_in_progress: false,
|
||||||
selected: vec![(vec![], true)].into_iter().collect(),
|
|
||||||
layer_range_selection_reference: None,
|
layer_range_selection_reference: None,
|
||||||
navigation_handler: NavigationMessageHandler::default(),
|
navigation_handler: NavigationMessageHandler::default(),
|
||||||
overlays_message_handler: OverlaysMessageHandler::default(),
|
overlays_message_handler: OverlaysMessageHandler::default(),
|
||||||
|
|
@ -223,7 +220,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
PropertiesPanel(message) => {
|
PropertiesPanel(message) => {
|
||||||
let properties_panel_message_handler_data = PropertiesPanelMessageHandlerData {
|
let properties_panel_message_handler_data = PropertiesPanelMessageHandlerData {
|
||||||
selected_layers: &mut self.selected.iter().filter_map(|(path, selected)| selected.then_some(path.as_slice())),
|
|
||||||
node_graph_message_handler: &self.node_graph_handler,
|
node_graph_message_handler: &self.node_graph_handler,
|
||||||
executor,
|
executor,
|
||||||
document_name: self.name.as_str(),
|
document_name: self.name.as_str(),
|
||||||
|
|
@ -319,7 +315,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
||||||
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![id] });
|
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![id] });
|
||||||
}
|
}
|
||||||
DebugPrintDocument => {
|
DebugPrintDocument => {
|
||||||
info!("{:#?}\n{:#?}", self.network, self.selected);
|
info!("{:#?}", self.network);
|
||||||
}
|
}
|
||||||
DeleteLayer { layer_path } => {
|
DeleteLayer { layer_path } => {
|
||||||
responses.add(GraphOperationMessage::DeleteLayer { id: layer_path[0] });
|
responses.add(GraphOperationMessage::DeleteLayer { id: layer_path[0] });
|
||||||
|
|
@ -870,10 +866,6 @@ impl DocumentMessageHandler {
|
||||||
Ok(document)
|
Ok(document)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn selected_layers(&self) -> impl Iterator<Item = &[LayerId]> {
|
|
||||||
self.selected.iter().filter_map(|(path, selected)| selected.then_some(path.as_slice()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the bounding boxes for all visible layers.
|
/// Returns the bounding boxes for all visible layers.
|
||||||
pub fn bounding_boxes<'a>(&'a self) -> impl Iterator<Item = [DVec2; 2]> + 'a {
|
pub fn bounding_boxes<'a>(&'a self) -> impl Iterator<Item = [DVec2; 2]> + 'a {
|
||||||
// TODO: Remove this function entirely?
|
// TODO: Remove this function entirely?
|
||||||
|
|
@ -978,19 +970,11 @@ impl DocumentMessageHandler {
|
||||||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||||
|
|
||||||
let selected_paths: Vec<Vec<LayerId>> = self.selected_layers().map(|path| path.to_vec()).collect();
|
|
||||||
|
|
||||||
let Some(document) = self.document_undo_history.pop_back() else {
|
let Some(document) = self.document_undo_history.pop_back() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update the currently displayed layer on the Properties panel if the selection changes after an undo action
|
responses.add(BroadcastEvent::SelectionChanged);
|
||||||
// Also appropriately update the Properties panel if an undo action results in a layer being deleted
|
|
||||||
let prev_selected_paths: Vec<Vec<LayerId>> = self.selected.iter().filter_map(|(layer_id, selected)| selected.then_some(layer_id.clone())).collect();
|
|
||||||
|
|
||||||
if prev_selected_paths != selected_paths {
|
|
||||||
responses.add(BroadcastEvent::SelectionChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
let document_save = self.replace_document(document);
|
let document_save = self.replace_document(document);
|
||||||
|
|
||||||
|
|
@ -1007,17 +991,9 @@ impl DocumentMessageHandler {
|
||||||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||||
|
|
||||||
let selected_paths: Vec<Vec<LayerId>> = self.selected_layers().map(|path| path.to_vec()).collect();
|
|
||||||
|
|
||||||
let Some(document) = self.document_redo_history.pop_back() else { return };
|
let Some(document) = self.document_redo_history.pop_back() else { return };
|
||||||
|
|
||||||
// Update currently displayed layer on property panel if selection changes after redo action
|
responses.add(BroadcastEvent::SelectionChanged);
|
||||||
// Also appropriately update property panel if redo action results in a layer being added
|
|
||||||
let next_selected_paths: Vec<Vec<LayerId>> = self.selected.iter().filter_map(|(layer_id, selected)| selected.then_some(layer_id.clone())).collect();
|
|
||||||
|
|
||||||
if next_selected_paths != selected_paths {
|
|
||||||
responses.add(BroadcastEvent::SelectionChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
let document_save = self.replace_document(document);
|
let document_save = self.replace_document(document);
|
||||||
self.document_undo_history.push_back(document_save);
|
self.document_undo_history.push_back(document_save);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::messages::portfolio::document::utility_types::document_metadata::DocumentMetadata;
|
use crate::messages::portfolio::document::utility_types::document_metadata::DocumentMetadata;
|
||||||
use crate::messages::portfolio::document::utility_types::LayerId;
|
|
||||||
use crate::messages::prelude::NodeGraphMessageHandler;
|
use crate::messages::prelude::NodeGraphMessageHandler;
|
||||||
use crate::node_graph_executor::NodeGraphExecutor;
|
use crate::node_graph_executor::NodeGraphExecutor;
|
||||||
|
|
||||||
|
|
@ -9,7 +8,6 @@ pub struct PropertiesPanelMessageHandlerData<'a> {
|
||||||
pub document_name: &'a str,
|
pub document_name: &'a str,
|
||||||
pub document_network: &'a mut NodeNetwork,
|
pub document_network: &'a mut NodeNetwork,
|
||||||
pub document_metadata: &'a mut DocumentMetadata,
|
pub document_metadata: &'a mut DocumentMetadata,
|
||||||
pub selected_layers: &'a mut dyn Iterator<Item = &'a [LayerId]>,
|
|
||||||
pub node_graph_message_handler: &'a NodeGraphMessageHandler,
|
pub node_graph_message_handler: &'a NodeGraphMessageHandler,
|
||||||
pub executor: &'a mut NodeGraphExecutor,
|
pub executor: &'a mut NodeGraphExecutor,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue