mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 12:28:12 +08:00
Replace responses.push() with responses.add() everywhere (#1186)
This commit is contained in:
@@ -34,12 +34,12 @@ impl MessageHandler<ArtboardMessage, &PersistentData> for ArtboardMessageHandler
|
||||
Ok(Some(document_responses)) => {
|
||||
for response in document_responses {
|
||||
match &response {
|
||||
DocumentResponse::LayerChanged { path } => responses.push_back(PropertiesPanelMessage::CheckSelectedWasUpdated { path: path.clone() }.into()),
|
||||
DocumentResponse::DeletedLayer { path } => responses.push_back(PropertiesPanelMessage::CheckSelectedWasDeleted { path: path.clone() }.into()),
|
||||
DocumentResponse::DocumentChanged => responses.push_back(ArtboardMessage::RenderArtboards.into()),
|
||||
DocumentResponse::LayerChanged { path } => responses.add(PropertiesPanelMessage::CheckSelectedWasUpdated { path: path.clone() }),
|
||||
DocumentResponse::DeletedLayer { path } => responses.add(PropertiesPanelMessage::CheckSelectedWasDeleted { path: path.clone() }),
|
||||
DocumentResponse::DocumentChanged => responses.add(ArtboardMessage::RenderArtboards),
|
||||
_ => {}
|
||||
};
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
Ok(None) => {}
|
||||
@@ -52,50 +52,41 @@ impl MessageHandler<ArtboardMessage, &PersistentData> for ArtboardMessageHandler
|
||||
let artboard_id = id.unwrap_or_else(generate_uuid);
|
||||
self.artboard_ids.push(artboard_id);
|
||||
|
||||
responses.push_back(
|
||||
ArtboardMessage::DispatchOperation(
|
||||
DocumentOperation::AddRect {
|
||||
path: vec![artboard_id],
|
||||
insert_index: -1,
|
||||
transform: DAffine2::from_scale_angle_translation(size.into(), 0., position.into()).to_cols_array(),
|
||||
style: style::PathStyle::new(None, Fill::solid(Color::WHITE)),
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
responses.add(ArtboardMessage::DispatchOperation(
|
||||
DocumentOperation::AddRect {
|
||||
path: vec![artboard_id],
|
||||
insert_index: -1,
|
||||
transform: DAffine2::from_scale_angle_translation(size.into(), 0., position.into()).to_cols_array(),
|
||||
style: style::PathStyle::new(None, Fill::solid(Color::WHITE)),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
));
|
||||
|
||||
responses.push_back(DocumentMessage::RenderDocument.into());
|
||||
responses.add(DocumentMessage::RenderDocument);
|
||||
}
|
||||
ClearArtboards => {
|
||||
for &artboard in self.artboard_ids.iter() {
|
||||
responses.push_front(ArtboardMessage::DeleteArtboard { artboard }.into());
|
||||
responses.add_front(ArtboardMessage::DeleteArtboard { artboard });
|
||||
}
|
||||
}
|
||||
DeleteArtboard { artboard } => {
|
||||
self.artboard_ids.retain(|&id| id != artboard);
|
||||
|
||||
responses.push_back(ArtboardMessage::DispatchOperation(Box::new(DocumentOperation::DeleteLayer { path: vec![artboard] })).into());
|
||||
responses.add(ArtboardMessage::DispatchOperation(Box::new(DocumentOperation::DeleteLayer { path: vec![artboard] })));
|
||||
|
||||
responses.push_back(DocumentMessage::RenderDocument.into());
|
||||
responses.add(DocumentMessage::RenderDocument);
|
||||
}
|
||||
RenderArtboards => {
|
||||
// Render an infinite canvas if there are no artboards
|
||||
if self.artboard_ids.is_empty() {
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateDocumentArtboards {
|
||||
svg: r##"<rect width="100%" height="100%" fill="#ffffff" />"##.to_string(),
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
responses.add(FrontendMessage::UpdateDocumentArtboards {
|
||||
svg: r##"<rect width="100%" height="100%" fill="#ffffff" />"##.to_string(),
|
||||
})
|
||||
} else {
|
||||
let render_data = RenderData::new(&persistent_data.font_cache, ViewMode::Normal, None);
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateDocumentArtboards {
|
||||
svg: self.artboards_document.render_root(&render_data),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(FrontendMessage::UpdateDocumentArtboards {
|
||||
svg: self.artboards_document.render_root(&render_data),
|
||||
});
|
||||
}
|
||||
}
|
||||
ResizeArtboard { artboard, position, mut size } => {
|
||||
@@ -106,15 +97,12 @@ impl MessageHandler<ArtboardMessage, &PersistentData> for ArtboardMessageHandler
|
||||
size.1 = size.1.signum();
|
||||
}
|
||||
|
||||
responses.push_back(
|
||||
ArtboardMessage::DispatchOperation(Box::new(DocumentOperation::SetLayerTransform {
|
||||
path: vec![artboard],
|
||||
transform: DAffine2::from_scale_angle_translation(size.into(), 0., position.into()).to_cols_array(),
|
||||
}))
|
||||
.into(),
|
||||
);
|
||||
responses.add(ArtboardMessage::DispatchOperation(Box::new(DocumentOperation::SetLayerTransform {
|
||||
path: vec![artboard],
|
||||
transform: DAffine2::from_scale_angle_translation(size.into(), 0., position.into()).to_cols_array(),
|
||||
})));
|
||||
|
||||
responses.push_back(DocumentMessage::RenderDocument.into());
|
||||
responses.add(DocumentMessage::RenderDocument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,56 +124,46 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
Ok(Some(document_responses)) => {
|
||||
for response in document_responses {
|
||||
match &response {
|
||||
DocumentResponse::FolderChanged { path } => responses.push_back(FolderChanged { affected_folder_path: path.clone() }.into()),
|
||||
DocumentResponse::FolderChanged { path } => responses.add(FolderChanged { affected_folder_path: path.clone() }),
|
||||
DocumentResponse::DeletedLayer { path } => {
|
||||
self.layer_metadata.remove(path);
|
||||
}
|
||||
DocumentResponse::LayerChanged { path } => responses.push_back(LayerChanged { affected_layer_path: path.clone() }.into()),
|
||||
DocumentResponse::LayerChanged { path } => responses.add(LayerChanged { affected_layer_path: path.clone() }),
|
||||
DocumentResponse::CreatedLayer { path } => {
|
||||
if self.layer_metadata.contains_key(path) {
|
||||
warn!("CreatedLayer overrides existing layer metadata.");
|
||||
}
|
||||
self.layer_metadata.insert(path.clone(), LayerMetadata::new(false));
|
||||
|
||||
responses.push_back(LayerChanged { affected_layer_path: path.clone() }.into());
|
||||
responses.add(LayerChanged { affected_layer_path: path.clone() });
|
||||
self.layer_range_selection_reference = path.clone();
|
||||
responses.push_back(
|
||||
AddSelectedLayers {
|
||||
additional_layers: vec![path.clone()],
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(AddSelectedLayers {
|
||||
additional_layers: vec![path.clone()],
|
||||
});
|
||||
}
|
||||
DocumentResponse::DocumentChanged => responses.push_back(RenderDocument.into()),
|
||||
DocumentResponse::DocumentChanged => responses.add(RenderDocument),
|
||||
DocumentResponse::DeletedSelectedManipulatorPoints => {
|
||||
// Clear Properties panel after deleting all points by updating backend widget state.
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
});
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
});
|
||||
}
|
||||
};
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
// Display boolean operation error to the user (except if it is a nothing done error).
|
||||
Err(DocumentError::BooleanOperationError(boolean_operation_error)) if boolean_operation_error != BooleanOperationError::NothingDone => responses.push_back(
|
||||
DialogMessage::DisplayDialogError {
|
||||
Err(DocumentError::BooleanOperationError(boolean_operation_error)) if boolean_operation_error != BooleanOperationError::NothingDone => {
|
||||
responses.add(DialogMessage::DisplayDialogError {
|
||||
title: "Failed to calculate boolean operation".into(),
|
||||
description: format!("Unfortunately, this feature not that robust yet.\n\nError: {boolean_operation_error:?}"),
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
})
|
||||
}
|
||||
Err(e) => error!("DocumentError: {:?}", e),
|
||||
Ok(_) => (),
|
||||
}
|
||||
@@ -224,8 +214,8 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
}
|
||||
|
||||
// TODO: Correctly update layer panel in clear_selection instead of here
|
||||
responses.push_back(FolderChanged { affected_folder_path: vec![] }.into());
|
||||
responses.push_back(BroadcastEvent::SelectionChanged.into());
|
||||
responses.add(FolderChanged { affected_folder_path: vec![] });
|
||||
responses.add(BroadcastEvent::SelectionChanged);
|
||||
|
||||
self.update_layer_tree_options_bar_widgets(responses, &render_data);
|
||||
}
|
||||
@@ -262,95 +252,86 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
skip_rerender: false,
|
||||
});
|
||||
}
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
BackupDocument { document, artboard, layer_metadata } => self.backup_with_document(document, *artboard, layer_metadata, responses),
|
||||
BooleanOperation(op) => {
|
||||
// Convert Vec<&[LayerId]> to Vec<Vec<&LayerId>> because Vec<&[LayerId]> does not implement several traits (Debug, Serialize, Deserialize, ...) required by DocumentOperation enum
|
||||
responses.push_back(StartTransaction.into());
|
||||
responses.push_back(BroadcastEvent::ToolAbort.into());
|
||||
responses.push_back(
|
||||
DocumentOperation::BooleanOperation {
|
||||
operation: op,
|
||||
selected: self.selected_layers_sorted().iter().map(|slice| (*slice).into()).collect(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(CommitTransaction.into());
|
||||
responses.add(StartTransaction);
|
||||
responses.add(BroadcastEvent::ToolAbort);
|
||||
responses.add(DocumentOperation::BooleanOperation {
|
||||
operation: op,
|
||||
selected: self.selected_layers_sorted().iter().map(|slice| (*slice).into()).collect(),
|
||||
});
|
||||
responses.add(CommitTransaction);
|
||||
}
|
||||
ClearLayerTree => {
|
||||
// Send an empty layer tree
|
||||
let data_buffer: RawBuffer = Self::default().serialize_root().as_slice().into();
|
||||
responses.push_back(FrontendMessage::UpdateDocumentLayerTreeStructure { data_buffer }.into());
|
||||
responses.add(FrontendMessage::UpdateDocumentLayerTreeStructure { data_buffer });
|
||||
|
||||
// Clear the options bar
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(Default::default()),
|
||||
layout_target: LayoutTarget::LayerTreeOptions,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(Default::default()),
|
||||
layout_target: LayoutTarget::LayerTreeOptions,
|
||||
});
|
||||
}
|
||||
CommitTransaction => (),
|
||||
CreateEmptyFolder { mut container_path } => {
|
||||
let id = generate_uuid();
|
||||
container_path.push(id);
|
||||
responses.push_back(DocumentMessage::DeselectAllLayers.into());
|
||||
responses.push_back(DocumentOperation::CreateFolder { path: container_path.clone() }.into());
|
||||
responses.push_back(
|
||||
DocumentMessage::SetLayerExpansion {
|
||||
layer_path: container_path,
|
||||
set_expanded: true,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(DocumentMessage::DeselectAllLayers);
|
||||
responses.add(DocumentOperation::CreateFolder { path: container_path.clone() });
|
||||
responses.add(DocumentMessage::SetLayerExpansion {
|
||||
layer_path: container_path,
|
||||
set_expanded: true,
|
||||
});
|
||||
}
|
||||
DebugPrintDocument => {
|
||||
info!("{:#?}\n{:#?}", self.document_legacy, self.layer_metadata);
|
||||
}
|
||||
DeleteLayer { layer_path } => {
|
||||
responses.push_front(DocumentOperation::DeleteLayer { path: layer_path.clone() }.into());
|
||||
responses.push_front(BroadcastEvent::ToolAbort.into());
|
||||
responses.push_back(PropertiesPanelMessage::CheckSelectedWasDeleted { path: layer_path }.into());
|
||||
responses.add_front(DocumentOperation::DeleteLayer { path: layer_path.clone() });
|
||||
responses.add_front(BroadcastEvent::ToolAbort);
|
||||
responses.add(PropertiesPanelMessage::CheckSelectedWasDeleted { path: layer_path });
|
||||
}
|
||||
DeleteSelectedLayers => {
|
||||
self.backup(responses);
|
||||
|
||||
for path in self.selected_layers_without_children() {
|
||||
responses.push_front(DocumentMessage::DeleteLayer { layer_path: path.to_vec() }.into());
|
||||
responses.add_front(DocumentMessage::DeleteLayer { layer_path: path.to_vec() });
|
||||
}
|
||||
|
||||
responses.push_front(BroadcastEvent::SelectionChanged.into());
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add_front(BroadcastEvent::SelectionChanged);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
DeselectAllLayers => {
|
||||
responses.push_front(SetSelectedLayers { replacement_selected_layers: vec![] }.into());
|
||||
responses.add_front(SetSelectedLayers { replacement_selected_layers: vec![] });
|
||||
self.layer_range_selection_reference.clear();
|
||||
}
|
||||
DirtyRenderDocument => {
|
||||
// Mark all non-overlay caches as dirty
|
||||
DocumentLegacy::mark_children_as_dirty(&mut self.document_legacy.root);
|
||||
responses.push_back(DocumentMessage::RenderDocument.into());
|
||||
responses.add(DocumentMessage::RenderDocument);
|
||||
}
|
||||
DirtyRenderDocumentInOutlineView => {
|
||||
if self.view_mode == ViewMode::Outline {
|
||||
responses.push_front(DocumentMessage::DirtyRenderDocument.into());
|
||||
responses.add_front(DocumentMessage::DirtyRenderDocument);
|
||||
}
|
||||
}
|
||||
DocumentHistoryBackward => self.undo(responses).unwrap_or_else(|e| warn!("{}", e)),
|
||||
DocumentHistoryForward => self.redo(responses).unwrap_or_else(|e| warn!("{}", e)),
|
||||
DocumentStructureChanged => {
|
||||
let data_buffer: RawBuffer = self.serialize_root().as_slice().into();
|
||||
responses.push_back(FrontendMessage::UpdateDocumentLayerTreeStructure { data_buffer }.into())
|
||||
responses.add(FrontendMessage::UpdateDocumentLayerTreeStructure { data_buffer })
|
||||
}
|
||||
DuplicateSelectedLayers => {
|
||||
self.backup(responses);
|
||||
responses.push_front(SetSelectedLayers { replacement_selected_layers: vec![] }.into());
|
||||
responses.add_front(SetSelectedLayers { replacement_selected_layers: vec![] });
|
||||
self.layer_range_selection_reference.clear();
|
||||
for path in self.selected_layers_sorted() {
|
||||
responses.push_back(DocumentOperation::DuplicateLayer { path: path.to_vec() }.into());
|
||||
responses.add(DocumentOperation::DuplicateLayer { path: path.to_vec() });
|
||||
}
|
||||
}
|
||||
ExportDocument {
|
||||
@@ -381,11 +362,11 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
};
|
||||
|
||||
if file_type == FileType::Svg {
|
||||
responses.push_back(FrontendMessage::TriggerFileDownload { document, name }.into());
|
||||
responses.add(FrontendMessage::TriggerFileDownload { document, name });
|
||||
} else {
|
||||
let mime = file_type.to_mime().to_string();
|
||||
let size = (size * scale_factor).into();
|
||||
responses.push_back(FrontendMessage::TriggerRasterDownload { svg: document, name, mime, size }.into());
|
||||
responses.add(FrontendMessage::TriggerRasterDownload { svg: document, name, mime, size });
|
||||
}
|
||||
}
|
||||
FlipSelectedLayers { flip_axis } => {
|
||||
@@ -405,7 +386,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
skip_rerender: false,
|
||||
});
|
||||
}
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
FolderChanged { affected_folder_path } => {
|
||||
@@ -429,9 +410,9 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
};
|
||||
|
||||
if let Some(url) = previous_blob_url {
|
||||
responses.push_back(FrontendMessage::TriggerRevokeBlobUrl { url: url.clone() }.into());
|
||||
responses.add(FrontendMessage::TriggerRevokeBlobUrl { url: url.clone() });
|
||||
}
|
||||
responses.push_back(DocumentOperation::ClearBlobURL { path: layer_path.into() }.into());
|
||||
responses.add(DocumentOperation::ClearBlobURL { path: layer_path.into() });
|
||||
}
|
||||
GroupSelectedLayers => {
|
||||
let mut new_folder_path = self.document_legacy.shallowest_common_folder(self.selected_layers()).unwrap_or(&[]).to_vec();
|
||||
@@ -443,30 +424,24 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
|
||||
new_folder_path.push(generate_uuid());
|
||||
|
||||
responses.push_back(PortfolioMessage::Copy { clipboard: Clipboard::Internal }.into());
|
||||
responses.push_back(DocumentMessage::DeleteSelectedLayers.into());
|
||||
responses.push_back(DocumentOperation::CreateFolder { path: new_folder_path.clone() }.into());
|
||||
responses.push_back(DocumentMessage::ToggleLayerExpansion { layer_path: new_folder_path.clone() }.into());
|
||||
responses.push_back(
|
||||
PortfolioMessage::PasteIntoFolder {
|
||||
clipboard: Clipboard::Internal,
|
||||
folder_path: new_folder_path.clone(),
|
||||
insert_index: -1,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(
|
||||
DocumentMessage::SetSelectedLayers {
|
||||
replacement_selected_layers: vec![new_folder_path],
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
|
||||
responses.add(DocumentMessage::DeleteSelectedLayers);
|
||||
responses.add(DocumentOperation::CreateFolder { path: new_folder_path.clone() });
|
||||
responses.add(DocumentMessage::ToggleLayerExpansion { layer_path: new_folder_path.clone() });
|
||||
responses.add(PortfolioMessage::PasteIntoFolder {
|
||||
clipboard: Clipboard::Internal,
|
||||
folder_path: new_folder_path.clone(),
|
||||
insert_index: -1,
|
||||
});
|
||||
responses.add(DocumentMessage::SetSelectedLayers {
|
||||
replacement_selected_layers: vec![new_folder_path],
|
||||
});
|
||||
}
|
||||
LayerChanged { affected_layer_path } => {
|
||||
if let Ok(layer_entry) = self.layer_panel_entry(affected_layer_path.clone(), &render_data) {
|
||||
responses.push_back(FrontendMessage::UpdateDocumentLayerDetails { data: layer_entry }.into());
|
||||
responses.add(FrontendMessage::UpdateDocumentLayerDetails { data: layer_entry });
|
||||
}
|
||||
responses.push_back(PropertiesPanelMessage::CheckSelectedWasUpdated { path: affected_layer_path }.into());
|
||||
responses.add(PropertiesPanelMessage::CheckSelectedWasUpdated { path: affected_layer_path });
|
||||
self.update_layer_tree_options_bar_widgets(responses, &render_data);
|
||||
}
|
||||
MoveSelectedLayersTo {
|
||||
@@ -483,16 +458,13 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
|
||||
let insert_index = self.update_insert_index(&selected_layers, &folder_path, insert_index, reverse_index).unwrap();
|
||||
|
||||
responses.push_back(PortfolioMessage::Copy { clipboard: Clipboard::Internal }.into());
|
||||
responses.push_back(DocumentMessage::DeleteSelectedLayers.into());
|
||||
responses.push_back(
|
||||
PortfolioMessage::PasteIntoFolder {
|
||||
clipboard: Clipboard::Internal,
|
||||
folder_path,
|
||||
insert_index,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
|
||||
responses.add(DocumentMessage::DeleteSelectedLayers);
|
||||
responses.add(PortfolioMessage::PasteIntoFolder {
|
||||
clipboard: Clipboard::Internal,
|
||||
folder_path,
|
||||
insert_index,
|
||||
});
|
||||
}
|
||||
NodeGraphFrameClear {
|
||||
layer_path,
|
||||
@@ -500,17 +472,17 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
cached_index: input_index,
|
||||
} => {
|
||||
let value = graph_craft::document::value::TaggedValue::RcImage(None);
|
||||
responses.push_back(NodeGraphMessage::SetInputValue { node_id, input_index, value }.into());
|
||||
responses.push_back(NodeGraphFrameGenerate { layer_path }.into());
|
||||
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value });
|
||||
responses.add(NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
NodeGraphFrameGenerate { layer_path } => {
|
||||
if let Some(message) = self.call_node_graph_frame(document_id, layer_path, preferences, persistent_data, None) {
|
||||
responses.push_back(message);
|
||||
responses.add(message);
|
||||
}
|
||||
}
|
||||
NodeGraphFrameImaginate { layer_path, imaginate_node } => {
|
||||
if let Some(message) = self.call_node_graph_frame(document_id, layer_path, preferences, persistent_data, Some(imaginate_node)) {
|
||||
responses.push_back(message);
|
||||
responses.add(message);
|
||||
}
|
||||
}
|
||||
NodeGraphFrameImaginateRandom {
|
||||
@@ -519,31 +491,25 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
then_generate,
|
||||
} => {
|
||||
// Set a random seed input
|
||||
responses.push_back(
|
||||
NodeGraphMessage::SetInputValue {
|
||||
node_id: *imaginate_node.last().unwrap(),
|
||||
// Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeType` in `document_node_type.rs`
|
||||
input_index: 1,
|
||||
value: graph_craft::document::value::TaggedValue::F64((generate_uuid() >> 1) as f64),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(NodeGraphMessage::SetInputValue {
|
||||
node_id: *imaginate_node.last().unwrap(),
|
||||
// Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeType` in `document_node_type.rs`
|
||||
input_index: 1,
|
||||
value: graph_craft::document::value::TaggedValue::F64((generate_uuid() >> 1) as f64),
|
||||
});
|
||||
|
||||
// Generate the image
|
||||
if then_generate {
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameImaginate { layer_path, imaginate_node }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameImaginate { layer_path, imaginate_node });
|
||||
}
|
||||
}
|
||||
NodeGraphFrameImaginateTerminate { layer_path, node_path } => {
|
||||
responses.push_back(
|
||||
FrontendMessage::TriggerImaginateTerminate {
|
||||
document_id,
|
||||
layer_path,
|
||||
node_path,
|
||||
hostname: preferences.imaginate_server_hostname.clone(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(FrontendMessage::TriggerImaginateTerminate {
|
||||
document_id,
|
||||
layer_path,
|
||||
node_path,
|
||||
hostname: preferences.imaginate_server_hostname.clone(),
|
||||
});
|
||||
}
|
||||
NudgeSelectedLayers {
|
||||
delta_x,
|
||||
@@ -591,7 +557,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
});
|
||||
}
|
||||
}
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
PasteImage { image, mouse } => {
|
||||
let image_size = DVec2::new(image.width as f64, image.height as f64);
|
||||
@@ -629,7 +595,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
|
||||
let transform = center_in_viewport_layerspace * fit_image_size;
|
||||
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let mut pos = 8;
|
||||
let mut next_pos = || {
|
||||
@@ -656,21 +622,15 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
downres_node_type.to_document_node_default_inputs([Some(graph_craft::document::NodeInput::node(transform_node_id, 0))], next_pos()),
|
||||
);
|
||||
|
||||
responses.push_back(
|
||||
DocumentOperation::AddNodeGraphFrame {
|
||||
path: path.clone(),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::ZERO.to_cols_array(),
|
||||
network,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(
|
||||
DocumentMessage::SetSelectedLayers {
|
||||
replacement_selected_layers: vec![path.clone()],
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(DocumentOperation::AddNodeGraphFrame {
|
||||
path: path.clone(),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::ZERO.to_cols_array(),
|
||||
network,
|
||||
});
|
||||
responses.add(DocumentMessage::SetSelectedLayers {
|
||||
replacement_selected_layers: vec![path.clone()],
|
||||
});
|
||||
|
||||
responses.add(GraphOperationMessage::TransformSet {
|
||||
layer: path.clone(),
|
||||
@@ -679,27 +639,24 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
skip_rerender: false,
|
||||
});
|
||||
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameGenerate { layer_path: path }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path: path });
|
||||
|
||||
// Force chosen tool to be Select Tool after importing image.
|
||||
responses.push_back(ToolMessage::ActivateTool { tool_type: ToolType::Select }.into());
|
||||
responses.add(ToolMessage::ActivateTool { tool_type: ToolType::Select });
|
||||
}
|
||||
Redo => {
|
||||
responses.push_back(SelectToolMessage::Abort.into());
|
||||
responses.push_back(DocumentHistoryForward.into());
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.push_back(RenderDocument.into());
|
||||
responses.push_back(FolderChanged { affected_folder_path: vec![] }.into());
|
||||
responses.add(SelectToolMessage::Abort);
|
||||
responses.add(DocumentHistoryForward);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(RenderDocument);
|
||||
responses.add(FolderChanged { affected_folder_path: vec![] });
|
||||
}
|
||||
RenameLayer { layer_path, new_name } => responses.push_back(DocumentOperation::RenameLayer { layer_path, new_name }.into()),
|
||||
RenameLayer { layer_path, new_name } => responses.add(DocumentOperation::RenameLayer { layer_path, new_name }),
|
||||
RenderDocument => {
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateDocumentArtwork {
|
||||
svg: self.document_legacy.render_root(&render_data),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(ArtboardMessage::RenderArtboards.into());
|
||||
responses.add(FrontendMessage::UpdateDocumentArtwork {
|
||||
svg: self.document_legacy.render_root(&render_data),
|
||||
});
|
||||
responses.add(ArtboardMessage::RenderArtboards);
|
||||
|
||||
let document_transform_scale = self.navigation_handler.snapped_scale();
|
||||
let scale = 0.5 + ASYMPTOTIC_EFFECT + document_transform_scale * SCALE_EFFECT;
|
||||
@@ -719,23 +676,17 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
|
||||
let ruler_origin = self.document_legacy.root.transform.transform_point2(DVec2::ZERO);
|
||||
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateDocumentScrollbars {
|
||||
position: scrollbar_position.into(),
|
||||
size: scrollbar_size.into(),
|
||||
multiplier: scrollbar_multiplier.into(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(FrontendMessage::UpdateDocumentScrollbars {
|
||||
position: scrollbar_position.into(),
|
||||
size: scrollbar_size.into(),
|
||||
multiplier: scrollbar_multiplier.into(),
|
||||
});
|
||||
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateDocumentRulers {
|
||||
origin: ruler_origin.into(),
|
||||
spacing: ruler_spacing,
|
||||
interval: ruler_interval,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(FrontendMessage::UpdateDocumentRulers {
|
||||
origin: ruler_origin.into(),
|
||||
spacing: ruler_spacing,
|
||||
interval: ruler_interval,
|
||||
});
|
||||
}
|
||||
RollbackTransaction => {
|
||||
self.rollback(responses).unwrap_or_else(|e| warn!("{}", e));
|
||||
@@ -743,37 +694,34 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
}
|
||||
SaveDocument => {
|
||||
self.set_save_state(true);
|
||||
responses.push_back(PortfolioMessage::AutoSaveActiveDocument.into());
|
||||
responses.add(PortfolioMessage::AutoSaveActiveDocument);
|
||||
// Update the save status of the just saved document
|
||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||
|
||||
let name = match self.name.ends_with(FILE_SAVE_SUFFIX) {
|
||||
true => self.name.clone(),
|
||||
false => self.name.clone() + FILE_SAVE_SUFFIX,
|
||||
};
|
||||
responses.push_back(
|
||||
FrontendMessage::TriggerFileDownload {
|
||||
document: self.serialize_document(),
|
||||
name,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
responses.add(FrontendMessage::TriggerFileDownload {
|
||||
document: self.serialize_document(),
|
||||
name,
|
||||
})
|
||||
}
|
||||
SelectAllLayers => {
|
||||
let all = self.all_layers().map(|path| path.to_vec()).collect();
|
||||
responses.push_front(SetSelectedLayers { replacement_selected_layers: all }.into());
|
||||
responses.add_front(SetSelectedLayers { replacement_selected_layers: all });
|
||||
}
|
||||
SelectedLayersLower => {
|
||||
responses.push_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: -1 }.into());
|
||||
responses.add_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: -1 });
|
||||
}
|
||||
SelectedLayersLowerToBack => {
|
||||
responses.push_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: isize::MIN }.into());
|
||||
responses.add_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: isize::MIN });
|
||||
}
|
||||
SelectedLayersRaise => {
|
||||
responses.push_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: 1 }.into());
|
||||
responses.add_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: 1 });
|
||||
}
|
||||
SelectedLayersRaiseToFront => {
|
||||
responses.push_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: isize::MAX }.into());
|
||||
responses.add_front(DocumentMessage::SelectedLayersReorder { relative_index_offset: isize::MAX });
|
||||
}
|
||||
SelectedLayersReorder { relative_index_offset } => {
|
||||
self.selected_layers_reorder(relative_index_offset, responses);
|
||||
@@ -796,13 +744,10 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
// Toggle selection when holding ctrl
|
||||
let layer = self.layer_metadata_mut(&layer_path);
|
||||
layer.selected = !layer.selected;
|
||||
responses.push_back(
|
||||
LayerChanged {
|
||||
affected_layer_path: layer_path.clone(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(BroadcastEvent::SelectionChanged.into());
|
||||
responses.add(LayerChanged {
|
||||
affected_layer_path: layer_path.clone(),
|
||||
});
|
||||
responses.add(BroadcastEvent::SelectionChanged);
|
||||
} else {
|
||||
paths.push(layer_path.clone());
|
||||
}
|
||||
@@ -815,16 +760,16 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
if !paths.is_empty() {
|
||||
// Add or set our selected layers
|
||||
if ctrl {
|
||||
responses.push_front(AddSelectedLayers { additional_layers: paths }.into());
|
||||
responses.add_front(AddSelectedLayers { additional_layers: paths });
|
||||
} else {
|
||||
responses.push_front(SetSelectedLayers { replacement_selected_layers: paths }.into());
|
||||
responses.add_front(SetSelectedLayers { replacement_selected_layers: paths });
|
||||
}
|
||||
}
|
||||
}
|
||||
SetBlendModeForSelectedLayers { blend_mode } => {
|
||||
self.backup(responses);
|
||||
for path in self.selected_layers() {
|
||||
responses.push_back(DocumentOperation::SetLayerBlendMode { path: path.to_vec(), blend_mode }.into());
|
||||
responses.add(DocumentOperation::SetLayerBlendMode { path: path.to_vec(), blend_mode });
|
||||
}
|
||||
}
|
||||
SetImageBlobUrl {
|
||||
@@ -842,7 +787,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
match &layer.data {
|
||||
LayerDataType::NodeGraphFrame(node_graph_frame) => {
|
||||
if let Some(url) = node_graph_frame.as_blob_url() {
|
||||
responses.push_back(FrontendMessage::TriggerRevokeBlobUrl { url: url.clone() }.into());
|
||||
responses.add(FrontendMessage::TriggerRevokeBlobUrl { url: url.clone() });
|
||||
}
|
||||
}
|
||||
other => {
|
||||
@@ -854,25 +799,22 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
}
|
||||
}
|
||||
|
||||
responses.push_back(
|
||||
PortfolioMessage::DocumentPassMessage {
|
||||
document_id,
|
||||
message: DocumentOperation::SetLayerBlobUrl { layer_path, blob_url, resolution }.into(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(PortfolioMessage::DocumentPassMessage {
|
||||
document_id,
|
||||
message: DocumentOperation::SetLayerBlobUrl { layer_path, blob_url, resolution }.into(),
|
||||
});
|
||||
}
|
||||
SetLayerExpansion { layer_path, set_expanded } => {
|
||||
self.layer_metadata_mut(&layer_path).expanded = set_expanded;
|
||||
responses.push_back(DocumentStructureChanged.into());
|
||||
responses.push_back(LayerChanged { affected_layer_path: layer_path }.into())
|
||||
responses.add(DocumentStructureChanged);
|
||||
responses.add(LayerChanged { affected_layer_path: layer_path })
|
||||
}
|
||||
SetLayerName { layer_path, name } => {
|
||||
if let Some(layer) = self.layer_panel_entry_from_path(&layer_path, &render_data) {
|
||||
// Only save the history state if the name actually changed to something different
|
||||
if layer.name != name {
|
||||
self.backup(responses);
|
||||
responses.push_back(DocumentOperation::SetLayerName { path: layer_path, name }.into());
|
||||
responses.add(DocumentOperation::SetLayerName { path: layer_path, name });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -881,57 +823,57 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
let opacity = opacity.clamp(0., 1.);
|
||||
|
||||
for path in self.selected_layers().map(|path| path.to_vec()) {
|
||||
responses.push_back(DocumentOperation::SetLayerOpacity { path, opacity }.into());
|
||||
responses.add(DocumentOperation::SetLayerOpacity { path, opacity });
|
||||
}
|
||||
}
|
||||
SetOverlaysVisibility { visible } => {
|
||||
self.overlays_visible = visible;
|
||||
responses.push_back(BroadcastEvent::ToolAbort.into());
|
||||
responses.push_back(OverlaysMessage::ClearAllOverlays.into());
|
||||
responses.push_back(OverlaysMessage::Rerender.into());
|
||||
responses.add(BroadcastEvent::ToolAbort);
|
||||
responses.add(OverlaysMessage::ClearAllOverlays);
|
||||
responses.add(OverlaysMessage::Rerender);
|
||||
}
|
||||
SetSelectedLayers { replacement_selected_layers } => {
|
||||
let selected = self.layer_metadata.iter_mut().filter(|(_, layer_metadata)| layer_metadata.selected);
|
||||
selected.for_each(|(path, layer_metadata)| {
|
||||
layer_metadata.selected = false;
|
||||
responses.push_back(LayerChanged { affected_layer_path: path.clone() }.into())
|
||||
responses.add(LayerChanged { affected_layer_path: path.clone() })
|
||||
});
|
||||
|
||||
let additional_layers = replacement_selected_layers;
|
||||
responses.push_front(AddSelectedLayers { additional_layers }.into());
|
||||
responses.add_front(AddSelectedLayers { additional_layers });
|
||||
}
|
||||
SetSnapping { snap } => {
|
||||
self.snapping_enabled = snap;
|
||||
}
|
||||
SetViewMode { view_mode } => {
|
||||
self.view_mode = view_mode;
|
||||
responses.push_front(DocumentMessage::DirtyRenderDocument.into());
|
||||
responses.add_front(DocumentMessage::DirtyRenderDocument);
|
||||
}
|
||||
StartTransaction => self.backup(responses),
|
||||
ToggleLayerExpansion { layer_path } => {
|
||||
self.layer_metadata_mut(&layer_path).expanded ^= true;
|
||||
responses.push_back(DocumentStructureChanged.into());
|
||||
responses.push_back(LayerChanged { affected_layer_path: layer_path }.into())
|
||||
responses.add(DocumentStructureChanged);
|
||||
responses.add(LayerChanged { affected_layer_path: layer_path })
|
||||
}
|
||||
ToggleLayerVisibility { layer_path } => {
|
||||
responses.push_back(DocumentOperation::ToggleLayerVisibility { path: layer_path }.into());
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(DocumentOperation::ToggleLayerVisibility { path: layer_path });
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
Undo => {
|
||||
self.undo_in_progress = true;
|
||||
responses.push_back(BroadcastEvent::ToolAbort.into());
|
||||
responses.push_back(DocumentHistoryBackward.into());
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.push_back(RenderDocument.into());
|
||||
responses.push_back(FolderChanged { affected_folder_path: vec![] }.into());
|
||||
responses.push_back(UndoFinished.into());
|
||||
responses.add(BroadcastEvent::ToolAbort);
|
||||
responses.add(DocumentHistoryBackward);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(RenderDocument);
|
||||
responses.add(FolderChanged { affected_folder_path: vec![] });
|
||||
responses.add(UndoFinished);
|
||||
}
|
||||
UndoFinished => self.undo_in_progress = false,
|
||||
UngroupLayers { folder_path } => {
|
||||
// Select all the children of the folder
|
||||
let select = self.document_legacy.folder_children_paths(&folder_path);
|
||||
|
||||
let message_buffer = [
|
||||
let message_buffer: [Message; 4] = [
|
||||
// Select them
|
||||
DocumentMessage::SetSelectedLayers { replacement_selected_layers: select }.into(),
|
||||
// Copy them
|
||||
@@ -949,36 +891,33 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
|
||||
// Push these messages in reverse due to push_front
|
||||
for message in message_buffer.into_iter().rev() {
|
||||
responses.push_front(message);
|
||||
responses.add_front(message);
|
||||
}
|
||||
}
|
||||
UngroupSelectedLayers => {
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
let folder_paths = self.document_legacy.sorted_folders_by_depth(self.selected_layers());
|
||||
for folder_path in folder_paths {
|
||||
responses.push_back(DocumentMessage::UngroupLayers { folder_path: folder_path.to_vec() }.into());
|
||||
responses.add(DocumentMessage::UngroupLayers { folder_path: folder_path.to_vec() });
|
||||
}
|
||||
responses.push_back(DocumentMessage::CommitTransaction.into());
|
||||
responses.add(DocumentMessage::CommitTransaction);
|
||||
}
|
||||
UpdateLayerMetadata { layer_path, layer_metadata } => {
|
||||
self.layer_metadata.insert(layer_path, layer_metadata);
|
||||
}
|
||||
ZoomCanvasTo100Percent => {
|
||||
responses.push_front(NavigationMessage::SetCanvasZoom { zoom_factor: 1. }.into());
|
||||
responses.add_front(NavigationMessage::SetCanvasZoom { zoom_factor: 1. });
|
||||
}
|
||||
ZoomCanvasTo200Percent => {
|
||||
responses.push_front(NavigationMessage::SetCanvasZoom { zoom_factor: 2. }.into());
|
||||
responses.add_front(NavigationMessage::SetCanvasZoom { zoom_factor: 2. });
|
||||
}
|
||||
ZoomCanvasToFitAll => {
|
||||
if let Some(bounds) = self.document_bounds(&render_data) {
|
||||
responses.push_back(
|
||||
NavigationMessage::FitViewportToBounds {
|
||||
bounds,
|
||||
padding_scale_factor: Some(VIEWPORT_ZOOM_TO_FIT_PADDING_SCALE_FACTOR),
|
||||
prevent_zoom_past_100: true,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
responses.add(NavigationMessage::FitViewportToBounds {
|
||||
bounds,
|
||||
padding_scale_factor: Some(VIEWPORT_ZOOM_TO_FIT_PADDING_SCALE_FACTOR),
|
||||
prevent_zoom_past_100: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1387,7 +1326,7 @@ 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());
|
||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||
}
|
||||
|
||||
/// Copies the entire document into the history system
|
||||
@@ -1397,14 +1336,11 @@ impl DocumentMessageHandler {
|
||||
|
||||
/// Push a message backing up the document in its current state
|
||||
pub fn backup_nonmut(&self, responses: &mut VecDeque<Message>) {
|
||||
responses.push_back(
|
||||
DocumentMessage::BackupDocument {
|
||||
document: self.document_legacy.clone(),
|
||||
artboard: Box::new(self.artboard_message_handler.clone()),
|
||||
layer_metadata: self.layer_metadata.clone(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(DocumentMessage::BackupDocument {
|
||||
document: self.document_legacy.clone(),
|
||||
artboard: Box::new(self.artboard_message_handler.clone()),
|
||||
layer_metadata: self.layer_metadata.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
pub fn rollback(&mut self, responses: &mut VecDeque<Message>) -> Result<(), EditorError> {
|
||||
@@ -1432,7 +1368,7 @@ impl DocumentMessageHandler {
|
||||
|
||||
pub fn undo(&mut self, responses: &mut VecDeque<Message>) -> Result<(), EditorError> {
|
||||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||
|
||||
let selected_paths: Vec<Vec<LayerId>> = self.selected_layers().map(|path| path.to_vec()).collect();
|
||||
|
||||
@@ -1443,7 +1379,7 @@ impl DocumentMessageHandler {
|
||||
let prev_selected_paths: Vec<Vec<LayerId>> = layer_metadata.iter().filter_map(|(layer_id, metadata)| metadata.selected.then_some(layer_id.clone())).collect();
|
||||
|
||||
if prev_selected_paths != selected_paths {
|
||||
responses.push_back(BroadcastEvent::SelectionChanged.into());
|
||||
responses.add(BroadcastEvent::SelectionChanged);
|
||||
}
|
||||
|
||||
let document_save = self.replace_document(DocumentSave { document, artboard, layer_metadata });
|
||||
@@ -1454,10 +1390,10 @@ impl DocumentMessageHandler {
|
||||
}
|
||||
|
||||
for layer in self.layer_metadata.keys() {
|
||||
responses.push_back(DocumentMessage::LayerChanged { affected_layer_path: layer.clone() }.into())
|
||||
responses.add(DocumentMessage::LayerChanged { affected_layer_path: layer.clone() })
|
||||
}
|
||||
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender: true }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1467,7 +1403,7 @@ impl DocumentMessageHandler {
|
||||
|
||||
pub fn redo(&mut self, responses: &mut VecDeque<Message>) -> Result<(), EditorError> {
|
||||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||
|
||||
let selected_paths: Vec<Vec<LayerId>> = self.selected_layers().map(|path| path.to_vec()).collect();
|
||||
|
||||
@@ -1478,7 +1414,7 @@ impl DocumentMessageHandler {
|
||||
let next_selected_paths: Vec<Vec<LayerId>> = layer_metadata.iter().filter_map(|(layer_id, metadata)| metadata.selected.then_some(layer_id.clone())).collect();
|
||||
|
||||
if next_selected_paths != selected_paths {
|
||||
responses.push_back(BroadcastEvent::SelectionChanged.into());
|
||||
responses.add(BroadcastEvent::SelectionChanged);
|
||||
}
|
||||
|
||||
let document_save = self.replace_document(DocumentSave { document, artboard, layer_metadata });
|
||||
@@ -1488,10 +1424,10 @@ impl DocumentMessageHandler {
|
||||
}
|
||||
|
||||
for layer in self.layer_metadata.keys() {
|
||||
responses.push_back(DocumentMessage::LayerChanged { affected_layer_path: layer.clone() }.into())
|
||||
responses.add(DocumentMessage::LayerChanged { affected_layer_path: layer.clone() })
|
||||
}
|
||||
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender: true }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1630,7 +1566,7 @@ impl DocumentMessageHandler {
|
||||
let mut fonts = HashSet::new();
|
||||
walk_layers(root, &mut path, responses, &mut fonts);
|
||||
for font in fonts {
|
||||
responses.push_front(FrontendMessage::TriggerFontLoad { font, is_default: false }.into());
|
||||
responses.add_front(FrontendMessage::TriggerFontLoad { font, is_default: false });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1836,21 +1772,15 @@ impl DocumentMessageHandler {
|
||||
],
|
||||
}]);
|
||||
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(document_bar_layout),
|
||||
layout_target: LayoutTarget::DocumentBar,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(document_bar_layout),
|
||||
layout_target: LayoutTarget::DocumentBar,
|
||||
});
|
||||
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(document_mode_layout),
|
||||
layout_target: LayoutTarget::DocumentMode,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(document_mode_layout),
|
||||
layout_target: LayoutTarget::DocumentMode,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn update_layer_tree_options_bar_widgets(&self, responses: &mut VecDeque<Message>, render_data: &RenderData) {
|
||||
@@ -1963,13 +1893,10 @@ impl DocumentMessageHandler {
|
||||
],
|
||||
}]);
|
||||
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(layer_tree_options),
|
||||
layout_target: LayoutTarget::LayerTreeOptions,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(layer_tree_options),
|
||||
layout_target: LayoutTarget::LayerTreeOptions,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn selected_layers_reorder(&mut self, relative_index_offset: isize, responses: &mut VecDeque<Message>) {
|
||||
@@ -2014,14 +1941,11 @@ impl DocumentMessageHandler {
|
||||
// If moving down, insert below this layer. If moving up, insert above this layer.
|
||||
let insert_index = if relative_index_offset < 0 { neighbor_layer_index } else { neighbor_layer_index + 1 };
|
||||
|
||||
responses.push_back(
|
||||
DocumentMessage::MoveSelectedLayersTo {
|
||||
folder_path: folder_path.to_vec(),
|
||||
insert_index,
|
||||
reverse_index: false,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(DocumentMessage::MoveSelectedLayersTo {
|
||||
folder_path: folder_path.to_vec(),
|
||||
insert_index,
|
||||
reverse_index: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
DecreaseCanvasZoom { center_on_mouse } => {
|
||||
let new_scale = *VIEWPORT_ZOOM_LEVELS.iter().rev().find(|scale| **scale < self.zoom).unwrap_or(&self.zoom);
|
||||
if center_on_mouse {
|
||||
responses.push_back(self.center_zoom(ipp.viewport_bounds.size(), new_scale / self.zoom, ipp.mouse.position));
|
||||
responses.add(self.center_zoom(ipp.viewport_bounds.size(), new_scale / self.zoom, ipp.mouse.position));
|
||||
}
|
||||
responses.push_back(SetCanvasZoom { zoom_factor: new_scale }.into());
|
||||
responses.add(SetCanvasZoom { zoom_factor: new_scale });
|
||||
}
|
||||
FitViewportToBounds {
|
||||
bounds: [bounds_corner_a, bounds_corner_b],
|
||||
@@ -89,29 +89,26 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
self.zoom = 1.
|
||||
}
|
||||
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.push_back(DocumentMessage::DirtyRenderDocumentInOutlineView.into());
|
||||
responses.push_back(PortfolioMessage::UpdateDocumentWidgets.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(DocumentMessage::DirtyRenderDocumentInOutlineView);
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
self.create_document_transform(&ipp.viewport_bounds, responses);
|
||||
}
|
||||
FitViewportToSelection => {
|
||||
if let Some(bounds) = selection_bounds {
|
||||
responses.push_back(
|
||||
FitViewportToBounds {
|
||||
bounds,
|
||||
padding_scale_factor: Some(VIEWPORT_ZOOM_TO_FIT_PADDING_SCALE_FACTOR),
|
||||
prevent_zoom_past_100: false,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
responses.add(FitViewportToBounds {
|
||||
bounds,
|
||||
padding_scale_factor: Some(VIEWPORT_ZOOM_TO_FIT_PADDING_SCALE_FACTOR),
|
||||
prevent_zoom_past_100: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
IncreaseCanvasZoom { center_on_mouse } => {
|
||||
let new_scale = *VIEWPORT_ZOOM_LEVELS.iter().find(|scale| **scale > self.zoom).unwrap_or(&self.zoom);
|
||||
if center_on_mouse {
|
||||
responses.push_back(self.center_zoom(ipp.viewport_bounds.size(), new_scale / self.zoom, ipp.mouse.position));
|
||||
responses.add(self.center_zoom(ipp.viewport_bounds.size(), new_scale / self.zoom, ipp.mouse.position));
|
||||
}
|
||||
responses.push_back(SetCanvasZoom { zoom_factor: new_scale }.into());
|
||||
responses.add(SetCanvasZoom { zoom_factor: new_scale });
|
||||
}
|
||||
PointerMove {
|
||||
snap_angle,
|
||||
@@ -122,7 +119,7 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
if self.panning {
|
||||
let delta = ipp.mouse.position - self.mouse_position;
|
||||
|
||||
responses.push_back(TranslateCanvas { delta }.into());
|
||||
responses.add(TranslateCanvas { delta });
|
||||
}
|
||||
|
||||
if self.tilting {
|
||||
@@ -143,7 +140,7 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
start_offset.angle_between(end_offset)
|
||||
};
|
||||
|
||||
responses.push_back(SetCanvasRotation { angle_radians: self.tilt + rotation }.into());
|
||||
responses.add(SetCanvasRotation { angle_radians: self.tilt + rotation });
|
||||
}
|
||||
|
||||
if self.zooming {
|
||||
@@ -163,29 +160,26 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
if let Some(mouse) = zoom_from_viewport {
|
||||
let zoom_factor = self.snapped_scale() / zoom_start;
|
||||
|
||||
responses.push_back(SetCanvasZoom { zoom_factor: self.zoom }.into());
|
||||
responses.push_back(self.center_zoom(ipp.viewport_bounds.size(), zoom_factor, mouse));
|
||||
responses.add(SetCanvasZoom { zoom_factor: self.zoom });
|
||||
responses.add(self.center_zoom(ipp.viewport_bounds.size(), zoom_factor, mouse));
|
||||
} else {
|
||||
responses.push_back(SetCanvasZoom { zoom_factor: self.zoom }.into());
|
||||
responses.add(SetCanvasZoom { zoom_factor: self.zoom });
|
||||
}
|
||||
}
|
||||
|
||||
self.mouse_position = ipp.mouse.position;
|
||||
}
|
||||
RotateCanvasBegin => {
|
||||
responses.push_back(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Default }.into());
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateInputHints {
|
||||
hint_data: HintData(vec![HintGroup(vec![HintInfo {
|
||||
key_groups: vec![KeysGroup(vec![Key::Control]).into()],
|
||||
key_groups_mac: None,
|
||||
mouse: None,
|
||||
label: String::from("Snap 15°"),
|
||||
plus: false,
|
||||
}])]),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Default });
|
||||
responses.add(FrontendMessage::UpdateInputHints {
|
||||
hint_data: HintData(vec![HintGroup(vec![HintInfo {
|
||||
key_groups: vec![KeysGroup(vec![Key::Control]).into()],
|
||||
key_groups_mac: None,
|
||||
mouse: None,
|
||||
label: String::from("Snap 15°"),
|
||||
plus: false,
|
||||
}])]),
|
||||
});
|
||||
|
||||
self.tilting = true;
|
||||
self.mouse_position = ipp.mouse.position;
|
||||
@@ -193,22 +187,22 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
SetCanvasRotation { angle_radians } => {
|
||||
self.tilt = angle_radians;
|
||||
self.create_document_transform(&ipp.viewport_bounds, responses);
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.push_back(PortfolioMessage::UpdateDocumentWidgets.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
}
|
||||
SetCanvasZoom { zoom_factor } => {
|
||||
self.zoom = zoom_factor.clamp(VIEWPORT_ZOOM_SCALE_MIN, VIEWPORT_ZOOM_SCALE_MAX);
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.push_back(DocumentMessage::DirtyRenderDocumentInOutlineView.into());
|
||||
responses.push_back(PortfolioMessage::UpdateDocumentWidgets.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(DocumentMessage::DirtyRenderDocumentInOutlineView);
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
self.create_document_transform(&ipp.viewport_bounds, responses);
|
||||
}
|
||||
TransformCanvasEnd => {
|
||||
self.tilt = self.snapped_angle();
|
||||
self.zoom = self.snapped_scale();
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.push_back(ToolMessage::UpdateCursor.into());
|
||||
responses.push_back(ToolMessage::UpdateHints.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(ToolMessage::UpdateCursor);
|
||||
responses.add(ToolMessage::UpdateHints);
|
||||
self.snap_tilt = false;
|
||||
self.snap_tilt_released = false;
|
||||
self.snap_zoom = false;
|
||||
@@ -220,12 +214,12 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
let transformed_delta = document.root.transform.inverse().transform_vector2(delta);
|
||||
|
||||
self.pan += transformed_delta;
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
self.create_document_transform(&ipp.viewport_bounds, responses);
|
||||
}
|
||||
TranslateCanvasBegin => {
|
||||
responses.push_back(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Grabbing }.into());
|
||||
responses.push_back(FrontendMessage::UpdateInputHints { hint_data: HintData(Vec::new()) }.into());
|
||||
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Grabbing });
|
||||
responses.add(FrontendMessage::UpdateInputHints { hint_data: HintData(Vec::new()) });
|
||||
|
||||
self.panning = true;
|
||||
self.mouse_position = ipp.mouse.position;
|
||||
@@ -234,7 +228,7 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
let transformed_delta = document.root.transform.inverse().transform_vector2(delta * ipp.viewport_bounds.size());
|
||||
|
||||
self.pan += transformed_delta;
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
self.create_document_transform(&ipp.viewport_bounds, responses);
|
||||
}
|
||||
WheelCanvasTranslate { use_y_as_x } => {
|
||||
@@ -242,7 +236,7 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
false => -ipp.mouse.scroll_delta.as_dvec2(),
|
||||
true => (-ipp.mouse.scroll_delta.y as f64, 0.).into(),
|
||||
} * VIEWPORT_SCROLL_RATE;
|
||||
responses.push_back(TranslateCanvas { delta }.into());
|
||||
responses.add(TranslateCanvas { delta });
|
||||
}
|
||||
WheelCanvasZoom => {
|
||||
let scroll = ipp.mouse.scroll_delta.scroll_delta();
|
||||
@@ -251,23 +245,20 @@ impl MessageHandler<NavigationMessage, (&Document, &InputPreprocessorMessageHand
|
||||
zoom_factor = 1. / zoom_factor
|
||||
};
|
||||
|
||||
responses.push_back(self.center_zoom(ipp.viewport_bounds.size(), zoom_factor, ipp.mouse.position));
|
||||
responses.push_back(SetCanvasZoom { zoom_factor: self.zoom * zoom_factor }.into());
|
||||
responses.add(self.center_zoom(ipp.viewport_bounds.size(), zoom_factor, ipp.mouse.position));
|
||||
responses.add(SetCanvasZoom { zoom_factor: self.zoom * zoom_factor });
|
||||
}
|
||||
ZoomCanvasBegin => {
|
||||
responses.push_back(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::ZoomIn }.into());
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateInputHints {
|
||||
hint_data: HintData(vec![HintGroup(vec![HintInfo {
|
||||
key_groups: vec![KeysGroup(vec![Key::Control]).into()],
|
||||
key_groups_mac: None,
|
||||
mouse: None,
|
||||
label: String::from("Snap Increments"),
|
||||
plus: false,
|
||||
}])]),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::ZoomIn });
|
||||
responses.add(FrontendMessage::UpdateInputHints {
|
||||
hint_data: HintData(vec![HintGroup(vec![HintInfo {
|
||||
key_groups: vec![KeysGroup(vec![Key::Control]).into()],
|
||||
key_groups_mac: None,
|
||||
mouse: None,
|
||||
label: String::from("Snap Increments"),
|
||||
plus: false,
|
||||
}])]),
|
||||
});
|
||||
|
||||
self.zooming = true;
|
||||
self.mouse_position = ipp.mouse.position;
|
||||
@@ -338,24 +329,18 @@ impl NavigationMessageHandler {
|
||||
fn create_document_transform(&self, viewport_bounds: &ViewportBounds, responses: &mut VecDeque<Message>) {
|
||||
let half_viewport = viewport_bounds.size() / 2.;
|
||||
let scaled_half_viewport = half_viewport / self.snapped_scale();
|
||||
responses.push_back(
|
||||
responses.add(DocumentOperation::SetLayerTransform {
|
||||
path: vec![],
|
||||
transform: self.calculate_offset_transform(scaled_half_viewport).to_cols_array(),
|
||||
});
|
||||
|
||||
responses.add(ArtboardMessage::DispatchOperation(
|
||||
DocumentOperation::SetLayerTransform {
|
||||
path: vec![],
|
||||
transform: self.calculate_offset_transform(scaled_half_viewport).to_cols_array(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
responses.push_back(
|
||||
ArtboardMessage::DispatchOperation(
|
||||
DocumentOperation::SetLayerTransform {
|
||||
path: vec![],
|
||||
transform: self.calculate_offset_transform(scaled_half_viewport).to_cols_array(),
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
pub fn center_zoom(&self, viewport_bounds: DVec2, zoom_factor: f64, mouse: DVec2) -> Message {
|
||||
|
||||
@@ -137,13 +137,10 @@ impl NodeGraphMessageHandler {
|
||||
|
||||
/// Send the cached layout for the bar at the top of the node panel to the frontend
|
||||
fn send_node_bar_layout(&self, responses: &mut VecDeque<Message>) {
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(self.widgets.to_vec())),
|
||||
layout_target: crate::messages::layout::utility_types::misc::LayoutTarget::NodeGraphBar,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(self.widgets.to_vec())),
|
||||
layout_target: crate::messages::layout::utility_types::misc::LayoutTarget::NodeGraphBar,
|
||||
});
|
||||
}
|
||||
|
||||
/// Collect the addresses of the currently viewed nested node e.g. Root -> MyFunFilter -> Exposure
|
||||
@@ -249,7 +246,7 @@ impl NodeGraphMessageHandler {
|
||||
}
|
||||
|
||||
fn send_graph(network: &NodeNetwork, responses: &mut VecDeque<Message>) {
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into());
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties);
|
||||
|
||||
// List of links in format (link_start, link_end, link_end_input_index)
|
||||
let links = network
|
||||
@@ -315,18 +312,15 @@ impl NodeGraphMessageHandler {
|
||||
disabled: network.disabled.contains(id),
|
||||
})
|
||||
}
|
||||
responses.push_back(FrontendMessage::UpdateNodeGraph { nodes, links }.into());
|
||||
responses.add(FrontendMessage::UpdateNodeGraph { nodes, links });
|
||||
}
|
||||
|
||||
/// Updates the frontend's selection state in line with the backend
|
||||
fn update_selected(&mut self, document: &mut Document, responses: &mut VecDeque<Message>) {
|
||||
self.update_selection_action_buttons(document, responses);
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateNodeGraphSelection {
|
||||
selected: self.selected_nodes.clone(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(FrontendMessage::UpdateNodeGraphSelection {
|
||||
selected: self.selected_nodes.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
fn remove_references_from_network(network: &mut NodeNetwork, deleting_node_id: NodeId) -> bool {
|
||||
@@ -410,7 +404,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
NodeGraphMessage::CloseNodeGraph => {
|
||||
if let Some(_old_layer_path) = self.layer_path.take() {
|
||||
Self::clear_graph(responses);
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into());
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties);
|
||||
}
|
||||
}
|
||||
NodeGraphMessage::ConnectNodesByLink {
|
||||
@@ -434,13 +428,13 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
return;
|
||||
};
|
||||
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let input = NodeInput::node(output_node, output_node_connector_index);
|
||||
responses.push_back(NodeGraphMessage::SetNodeInput { node_id, input_index, input }.into());
|
||||
responses.add(NodeGraphMessage::SetNodeInput { node_id, input_index, input });
|
||||
|
||||
let should_rerender = network.connected_to_output(node_id, true);
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender });
|
||||
}
|
||||
NodeGraphMessage::Copy => {
|
||||
let Some(network) = self.get_active_network(document) else {
|
||||
@@ -456,29 +450,29 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
let mut copy_text = String::from("graphite/nodes: ");
|
||||
copy_text += &serde_json::to_string(&copied_nodes).expect("Could not serialize paste");
|
||||
|
||||
responses.push_back(FrontendMessage::TriggerTextCopy { copy_text }.into());
|
||||
responses.add(FrontendMessage::TriggerTextCopy { copy_text });
|
||||
}
|
||||
NodeGraphMessage::CreateNode { node_id, node_type, x, y } => {
|
||||
let node_id = node_id.unwrap_or_else(crate::application::generate_uuid);
|
||||
|
||||
let Some(document_node_type) = document_node_types::resolve_document_node_type(&node_type) else {
|
||||
responses.push_back(DialogMessage::DisplayDialogError { title: "Cannot insert node".to_string(), description: format!("The document node '{node_type}' does not exist in the document node list") }.into());
|
||||
responses.add(DialogMessage::DisplayDialogError { title: "Cannot insert node".to_string(), description: format!("The document node '{node_type}' does not exist in the document node list") });
|
||||
return;
|
||||
};
|
||||
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let document_node = document_node_type.to_document_node(
|
||||
document_node_type.inputs.iter().map(|input| input.default.clone()),
|
||||
graph_craft::document::DocumentNodeMetadata::position((x, y)),
|
||||
);
|
||||
responses.push_back(NodeGraphMessage::InsertNode { node_id, document_node }.into());
|
||||
responses.add(NodeGraphMessage::InsertNode { node_id, document_node });
|
||||
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender: false }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender: false });
|
||||
}
|
||||
NodeGraphMessage::Cut => {
|
||||
responses.push_back(NodeGraphMessage::Copy.into());
|
||||
responses.push_back(NodeGraphMessage::DeleteSelectedNodes.into());
|
||||
responses.add(NodeGraphMessage::Copy);
|
||||
responses.add(NodeGraphMessage::DeleteSelectedNodes);
|
||||
}
|
||||
NodeGraphMessage::DeleteNode { node_id } => {
|
||||
if let Some(network) = self.get_active_network_mut(document) {
|
||||
@@ -487,19 +481,19 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
self.update_selected(document, responses);
|
||||
}
|
||||
NodeGraphMessage::DeleteSelectedNodes => {
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
for node_id in self.selected_nodes.clone() {
|
||||
responses.push_back(NodeGraphMessage::DeleteNode { node_id }.into());
|
||||
responses.add(NodeGraphMessage::DeleteNode { node_id });
|
||||
}
|
||||
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender: false }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender: false });
|
||||
|
||||
if let Some(network) = self.get_active_network(document) {
|
||||
// Only generate node graph if one of the selected nodes is connected to the output
|
||||
if self.selected_nodes.iter().any(|&node_id| network.connected_to_output(node_id, true)) {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameGenerate { layer_path }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,13 +512,13 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
return;
|
||||
};
|
||||
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let input = node_type.inputs[input_index].default.clone();
|
||||
responses.push_back(NodeGraphMessage::SetNodeInput { node_id, input_index, input }.into());
|
||||
responses.add(NodeGraphMessage::SetNodeInput { node_id, input_index, input });
|
||||
|
||||
let should_rerender = network.connected_to_output(node_id, true);
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender });
|
||||
}
|
||||
NodeGraphMessage::DoubleClickNode { node } => {
|
||||
if let Some(network) = self.get_active_network(document) {
|
||||
@@ -540,7 +534,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
}
|
||||
NodeGraphMessage::DuplicateSelectedNodes => {
|
||||
if let Some(network) = self.get_active_network(document) {
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let new_ids = &self.selected_nodes.iter().map(|&id| (id, crate::application::generate_uuid())).collect();
|
||||
self.selected_nodes.clear();
|
||||
@@ -555,7 +549,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
self.selected_nodes.push(node_id);
|
||||
|
||||
// Insert new node into graph
|
||||
responses.push_back(NodeGraphMessage::InsertNode { node_id, document_node }.into());
|
||||
responses.add(NodeGraphMessage::InsertNode { node_id, document_node });
|
||||
}
|
||||
|
||||
Self::send_graph(network, responses);
|
||||
@@ -584,7 +578,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
return;
|
||||
};
|
||||
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let mut input = node.inputs[input_index].clone();
|
||||
if let NodeInput::Value { exposed, .. } = &mut input {
|
||||
@@ -597,11 +591,11 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
};
|
||||
}
|
||||
}
|
||||
responses.push_back(NodeGraphMessage::SetNodeInput { node_id, input_index, input }.into());
|
||||
responses.add(NodeGraphMessage::SetNodeInput { node_id, input_index, input });
|
||||
|
||||
let should_rerender = network.connected_to_output(node_id, true);
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender }.into());
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender });
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties);
|
||||
}
|
||||
NodeGraphMessage::InsertNode { node_id, document_node } => {
|
||||
if let Some(network) = self.get_active_network_mut(document) {
|
||||
@@ -630,7 +624,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
Self::send_graph(network, responses);
|
||||
|
||||
let node_types = document_node_types::collect_node_types();
|
||||
responses.push_back(FrontendMessage::UpdateNodeTypes { node_types }.into());
|
||||
responses.add(FrontendMessage::UpdateNodeTypes { node_types });
|
||||
}
|
||||
self.collect_nested_addresses(document, responses);
|
||||
self.update_selected(document, responses);
|
||||
@@ -658,7 +652,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
shift += IVec2::splat(2);
|
||||
}
|
||||
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let new_ids: HashMap<_, _> = data.iter().map(|&(id, _)| (id, crate::application::generate_uuid())).collect();
|
||||
for (old_id, mut document_node) in data {
|
||||
@@ -670,26 +664,26 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
document_node = document_node.map_ids(Self::default_node_input, &new_ids);
|
||||
|
||||
// Insert node into network
|
||||
responses.push_back(NodeGraphMessage::InsertNode { node_id, document_node }.into());
|
||||
responses.add(NodeGraphMessage::InsertNode { node_id, document_node });
|
||||
}
|
||||
|
||||
let nodes = new_ids.values().copied().collect();
|
||||
responses.push_back(NodeGraphMessage::SelectNodes { nodes }.into());
|
||||
responses.add(NodeGraphMessage::SelectNodes { nodes });
|
||||
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender: false }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender: false });
|
||||
}
|
||||
NodeGraphMessage::SelectNodes { nodes } => {
|
||||
self.selected_nodes = nodes;
|
||||
self.update_selection_action_buttons(document, responses);
|
||||
self.update_selected(document, responses);
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into());
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties);
|
||||
}
|
||||
NodeGraphMessage::SendGraph { should_rerender } => {
|
||||
if let Some(network) = self.get_active_network(document) {
|
||||
Self::send_graph(network, responses);
|
||||
if should_rerender {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameGenerate { layer_path }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -698,14 +692,14 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
NodeGraphMessage::SetInputValue { node_id, input_index, value } => {
|
||||
if let Some(network) = self.get_active_network(document) {
|
||||
if let Some(node) = network.nodes.get(&node_id) {
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let input = NodeInput::Value { tagged_value: value, exposed: false };
|
||||
responses.push_back(NodeGraphMessage::SetNodeInput { node_id, input_index, input }.into());
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into());
|
||||
responses.add(NodeGraphMessage::SetNodeInput { node_id, input_index, input });
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties);
|
||||
if (node.name != "Imaginate" || input_index == 0) && network.connected_to_output(node_id, true) {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameGenerate { layer_path }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -743,7 +737,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
}
|
||||
node.inputs[input_index] = NodeInput::Value { tagged_value: value, exposed: false };
|
||||
if network.connected_to_output(*node_id, true) {
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameGenerate { layer_path }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -793,11 +787,11 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
stack.extend(outwards_links.get(&id).unwrap_or(&Vec::new()).iter().copied())
|
||||
}
|
||||
}
|
||||
responses.push_back(NodeGraphMessage::SendGraph { should_rerender: false }.into());
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender: false });
|
||||
}
|
||||
NodeGraphMessage::ToggleHidden => {
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.push_back(NodeGraphMessage::ToggleHiddenImpl.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
responses.add(NodeGraphMessage::ToggleHiddenImpl);
|
||||
}
|
||||
NodeGraphMessage::ToggleHiddenImpl => {
|
||||
if let Some(network) = self.get_active_network_mut(document) {
|
||||
@@ -817,15 +811,15 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
// Only generate node graph if one of the selected nodes is connected to the output
|
||||
if self.selected_nodes.iter().any(|&node_id| network.connected_to_output(node_id, true)) {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameGenerate { layer_path }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
self.update_selection_action_buttons(document, responses);
|
||||
}
|
||||
NodeGraphMessage::TogglePreview { node_id } => {
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.push_back(NodeGraphMessage::TogglePreviewImpl { node_id }.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
responses.add(NodeGraphMessage::TogglePreviewImpl { node_id });
|
||||
}
|
||||
NodeGraphMessage::TogglePreviewImpl { node_id } => {
|
||||
if let Some(network) = self.get_active_network_mut(document) {
|
||||
@@ -842,7 +836,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
}
|
||||
self.update_selection_action_buttons(document, responses);
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.push_back(DocumentMessage::NodeGraphFrameGenerate { layer_path }.into());
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -923,7 +923,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
let server_status = {
|
||||
let status = match &context.persistent_data.imaginate_server_status {
|
||||
ImaginateServerStatus::Unknown => {
|
||||
context.responses.push_back(PortfolioMessage::ImaginateCheckServerStatus.into());
|
||||
context.responses.add(PortfolioMessage::ImaginateCheckServerStatus);
|
||||
"Checking..."
|
||||
}
|
||||
ImaginateServerStatus::Checking => "Checking...",
|
||||
|
||||
@@ -22,7 +22,7 @@ impl MessageHandler<OverlaysMessage, (bool, &PersistentData, &InputPreprocessorM
|
||||
let render_data = RenderData::new(&persistent_data.font_cache, ViewMode::Normal, Some(ipp.document_bounds()));
|
||||
|
||||
match self.overlays_document.handle_operation(*operation, &render_data) {
|
||||
Ok(_) => responses.push_back(OverlaysMessage::Rerender.into()),
|
||||
Ok(_) => responses.add(OverlaysMessage::Rerender),
|
||||
Err(e) => error!("OverlaysError: {:?}", e),
|
||||
}
|
||||
}
|
||||
@@ -34,17 +34,14 @@ impl MessageHandler<OverlaysMessage, (bool, &PersistentData, &InputPreprocessorM
|
||||
Rerender =>
|
||||
// Render overlays
|
||||
{
|
||||
responses.push_back(
|
||||
FrontendMessage::UpdateDocumentOverlays {
|
||||
svg: if overlays_visible {
|
||||
let render_data = RenderData::new(&persistent_data.font_cache, ViewMode::Normal, Some(ipp.document_bounds()));
|
||||
self.overlays_document.render_root(&render_data)
|
||||
} else {
|
||||
String::from("")
|
||||
},
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
responses.add(FrontendMessage::UpdateDocumentOverlays {
|
||||
svg: if overlays_visible {
|
||||
let render_data = RenderData::new(&persistent_data.font_cache, ViewMode::Normal, Some(ipp.document_bounds()));
|
||||
self.overlays_document.render_root(&render_data)
|
||||
} else {
|
||||
String::from("")
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+39
-60
@@ -40,8 +40,8 @@ impl<'a> MessageHandler<PropertiesPanelMessage, (&PersistentData, PropertiesPane
|
||||
SetActiveLayers { paths, document } => {
|
||||
if paths.len() != 1 {
|
||||
// TODO: Allow for multiple selected layers
|
||||
responses.push_back(PropertiesPanelMessage::ClearSelection.into());
|
||||
responses.push_back(NodeGraphMessage::CloseNodeGraph.into());
|
||||
responses.add(PropertiesPanelMessage::ClearSelection);
|
||||
responses.add(NodeGraphMessage::CloseNodeGraph);
|
||||
} else {
|
||||
let path = paths.into_iter().next().unwrap();
|
||||
if Some((path.clone(), document)) != self.active_selection {
|
||||
@@ -52,48 +52,36 @@ impl<'a> MessageHandler<PropertiesPanelMessage, (&PersistentData, PropertiesPane
|
||||
.filter(|layer| LayerDataTypeDiscriminant::from(&layer.data) == LayerDataTypeDiscriminant::NodeGraphFrame)
|
||||
.is_some()
|
||||
{
|
||||
responses.push_back(NodeGraphMessage::OpenNodeGraph { layer_path: path.clone() }.into());
|
||||
responses.add(NodeGraphMessage::OpenNodeGraph { layer_path: path.clone() });
|
||||
} else {
|
||||
responses.push_back(NodeGraphMessage::CloseNodeGraph.into());
|
||||
responses.add(NodeGraphMessage::CloseNodeGraph);
|
||||
}
|
||||
|
||||
self.active_selection = Some((path, document));
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into());
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
ClearSelection => {
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(NodeGraphMessage::CloseNodeGraph.into());
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
});
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(vec![])),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
});
|
||||
responses.add(NodeGraphMessage::CloseNodeGraph);
|
||||
self.active_selection = None;
|
||||
}
|
||||
Deactivate => responses.push_back(
|
||||
BroadcastMessage::UnsubscribeEvent {
|
||||
on: BroadcastEvent::SelectionChanged,
|
||||
message: Box::new(PropertiesPanelMessage::UpdateSelectedDocumentProperties.into()),
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
Init => responses.push_back(
|
||||
BroadcastMessage::SubscribeEvent {
|
||||
on: BroadcastEvent::SelectionChanged,
|
||||
send: Box::new(PropertiesPanelMessage::UpdateSelectedDocumentProperties.into()),
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
Deactivate => responses.add(BroadcastMessage::UnsubscribeEvent {
|
||||
on: BroadcastEvent::SelectionChanged,
|
||||
message: Box::new(PropertiesPanelMessage::UpdateSelectedDocumentProperties.into()),
|
||||
}),
|
||||
Init => responses.add(BroadcastMessage::SubscribeEvent {
|
||||
on: BroadcastEvent::SelectionChanged,
|
||||
send: Box::new(PropertiesPanelMessage::UpdateSelectedDocumentProperties.into()),
|
||||
}),
|
||||
ModifyTransform { value, transform_op } => {
|
||||
let (path, target_document) = self.active_selection.as_ref().expect("Received update for properties panel with no active layer");
|
||||
let layer = get_document(*target_document).layer(path).unwrap();
|
||||
@@ -128,27 +116,21 @@ impl<'a> MessageHandler<PropertiesPanelMessage, (&PersistentData, PropertiesPane
|
||||
}
|
||||
CheckSelectedWasUpdated { path } => {
|
||||
if self.matches_selected(&path) {
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into())
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties)
|
||||
}
|
||||
}
|
||||
CheckSelectedWasDeleted { path } => {
|
||||
if self.matches_selected(&path) {
|
||||
self.active_selection = None;
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
layout: Layout::WidgetLayout(WidgetLayout::default()),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
layout: Layout::WidgetLayout(WidgetLayout::default()),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(NodeGraphMessage::CloseNodeGraph.into());
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
layout: Layout::WidgetLayout(WidgetLayout::default()),
|
||||
});
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
layout: Layout::WidgetLayout(WidgetLayout::default()),
|
||||
});
|
||||
responses.add(NodeGraphMessage::CloseNodeGraph);
|
||||
}
|
||||
}
|
||||
ResendActiveProperties => {
|
||||
@@ -161,13 +143,10 @@ impl<'a> MessageHandler<PropertiesPanelMessage, (&PersistentData, PropertiesPane
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateSelectedDocumentProperties => responses.push_back(
|
||||
PropertiesPanelMessage::SetActiveLayers {
|
||||
paths: selected_layers.map(|path| path.to_vec()).collect(),
|
||||
document: TargetDocument::Artwork,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
UpdateSelectedDocumentProperties => responses.add(PropertiesPanelMessage::SetActiveLayers {
|
||||
paths: selected_layers.map(|path| path.to_vec()).collect(),
|
||||
document: TargetDocument::Artwork,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,16 +169,16 @@ impl PropertiesPanelMessageHandler {
|
||||
// Commit history is not respected as the artboard document is not saved in the history system.
|
||||
|
||||
// Dispatch the relevant operation to the artboard document
|
||||
responses.push_back(ArtboardMessage::DispatchOperation(Box::new(operation)).into())
|
||||
responses.add(ArtboardMessage::DispatchOperation(Box::new(operation)))
|
||||
}
|
||||
TargetDocument::Artwork => {
|
||||
// Commit to history before the modification
|
||||
if commit_history {
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
}
|
||||
|
||||
// Dispatch the relevant operation to the main document
|
||||
responses.push_back(DocumentMessage::DispatchOperation(Box::new(operation)).into());
|
||||
responses.add(DocumentMessage::DispatchOperation(Box::new(operation)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,20 +225,14 @@ pub fn register_artboard_layer_properties(layer: &Layer, responses: &mut VecDequ
|
||||
}]
|
||||
};
|
||||
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(options_bar)),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(properties_body)),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(options_bar)),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
});
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(properties_body)),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn register_artwork_layer_properties(
|
||||
@@ -325,20 +319,14 @@ pub fn register_artwork_layer_properties(
|
||||
}
|
||||
};
|
||||
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(options_bar)),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(
|
||||
LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(properties_body)),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(options_bar)),
|
||||
layout_target: LayoutTarget::PropertiesOptions,
|
||||
});
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout::new(properties_body)),
|
||||
layout_target: LayoutTarget::PropertiesSections,
|
||||
});
|
||||
}
|
||||
|
||||
fn node_section_transform(layer: &Layer, persistent_data: &PersistentData) -> LayoutGroup {
|
||||
|
||||
@@ -423,7 +423,7 @@ impl<'a> Selected<'a> {
|
||||
});
|
||||
}
|
||||
}
|
||||
self.responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
self.responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user