Standardize FrontendMessage message names

This commit is contained in:
Keavon Chambers
2022-01-12 14:16:13 -08:00
parent 4d9fcd0b77
commit cf66f387d5
17 changed files with 154 additions and 152 deletions

View File

@@ -68,14 +68,14 @@ impl MessageHandler<ArtboardMessage, (&mut LayerMetadata, &GrapheneDocument, &In
// Render an infinite canvas if there are no artboards
if self.artboard_ids.is_empty() {
responses.push_back(
FrontendMessage::UpdateArtboards {
FrontendMessage::UpdateDocumentArtboards {
svg: r##"<rect width="100%" height="100%" fill="#ffffff" />"##.to_string(),
}
.into(),
)
} else {
responses.push_back(
FrontendMessage::UpdateArtboards {
FrontendMessage::UpdateDocumentArtboards {
svg: self.artboards_graphene_document.render_root(ViewMode::Normal),
}
.into(),

View File

@@ -243,7 +243,7 @@ impl DocumentMessageHandler {
if let Some(layer) = self.layer_metadata.get_mut(path) {
layer.selected = true;
let data = self.layer_panel_entry(path.to_vec()).ok()?;
(!path.is_empty()).then(|| FrontendMessage::UpdateLayer { data }.into())
(!path.is_empty()).then(|| FrontendMessage::UpdateDocumentLayer { data }.into())
} else {
log::warn!("Tried to select non existing layer {:?}", path);
None
@@ -594,7 +594,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
false => self.name.clone() + FILE_EXPORT_SUFFIX,
};
responses.push_back(
FrontendMessage::ExportDocument {
FrontendMessage::TriggerFileDownload {
document: format!(
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="{} {} {} {}">{}{}</svg>"#,
bbox[0].x,
@@ -620,7 +620,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
false => self.name.clone() + FILE_SAVE_SUFFIX,
};
responses.push_back(
FrontendMessage::SaveDocument {
FrontendMessage::TriggerFileDownload {
document: self.serialize_document(),
name,
}
@@ -830,11 +830,11 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
}
DocumentStructureChanged => {
let data_buffer: RawBuffer = self.serialize_root().into();
responses.push_back(FrontendMessage::DisplayFolderTreeStructure { data_buffer }.into())
responses.push_back(FrontendMessage::DisplayDocumentLayerTreeStructure { data_buffer }.into())
}
LayerChanged(path) => {
if let Ok(layer_entry) = self.layer_panel_entry(path) {
responses.push_back(FrontendMessage::UpdateLayer { data: layer_entry }.into());
responses.push_back(FrontendMessage::UpdateDocumentLayer { data: layer_entry }.into());
}
}
DispatchOperation(op) => match self.graphene_document.handle_operation(&op) {
@@ -866,7 +866,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
},
RenderDocument => {
responses.push_back(
FrontendMessage::UpdateArtwork {
FrontendMessage::UpdateDocumentArtwork {
svg: self.graphene_document.render_root(self.view_mode),
}
.into(),
@@ -892,7 +892,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
let ruler_origin = self.graphene_document.root.transform.transform_point2(DVec2::ZERO);
responses.push_back(
FrontendMessage::UpdateScrollbars {
FrontendMessage::UpdateDocumentScrollbars {
position: scrollbar_position.into(),
size: scrollbar_size.into(),
multiplier: scrollbar_multiplier.into(),
@@ -901,7 +901,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
);
responses.push_back(
FrontendMessage::UpdateRulers {
FrontendMessage::UpdateDocumentRulers {
origin: ruler_origin.into(),
spacing: ruler_spacing,
interval: ruler_interval,

View File

@@ -235,7 +235,7 @@ impl MessageHandler<MovementMessage, (&Document, &InputPreprocessor)> for Moveme
}
SetCanvasZoom(new) => {
self.zoom = new.clamp(VIEWPORT_ZOOM_SCALE_MIN, VIEWPORT_ZOOM_SCALE_MAX);
responses.push_back(FrontendMessage::SetCanvasZoom { new_zoom: self.snapped_scale() }.into());
responses.push_back(FrontendMessage::UpdateCanvasZoom { factor: self.snapped_scale() }.into());
responses.push_back(ToolMessage::DocumentIsDirty.into());
responses.push_back(DocumentMessage::DirtyRenderDocumentInOutlineView.into());
self.create_document_transform(&ipp.viewport_bounds, responses);
@@ -275,7 +275,7 @@ impl MessageHandler<MovementMessage, (&Document, &InputPreprocessor)> for Moveme
self.tilt = new_radians;
self.create_document_transform(&ipp.viewport_bounds, responses);
responses.push_back(ToolMessage::DocumentIsDirty.into());
responses.push_back(FrontendMessage::SetCanvasRotation { new_radians: self.snapped_angle() }.into());
responses.push_back(FrontendMessage::UpdateCanvasRotation { angle_radians: self.snapped_angle() }.into());
}
FitViewportToBounds {
bounds: [bounds_corner_a, bounds_corner_b],
@@ -301,7 +301,7 @@ impl MessageHandler<MovementMessage, (&Document, &InputPreprocessor)> for Moveme
self.zoom = 1.
}
responses.push_back(FrontendMessage::SetCanvasZoom { new_zoom: self.zoom }.into());
responses.push_back(FrontendMessage::UpdateCanvasZoom { factor: self.zoom }.into());
responses.push_back(ToolMessage::DocumentIsDirty.into());
responses.push_back(DocumentMessage::DirtyRenderDocumentInOutlineView.into());
self.create_document_transform(&ipp.viewport_bounds, responses);

View File

@@ -41,7 +41,7 @@ impl MessageHandler<OverlayMessage, (&mut LayerMetadata, &Document, &InputPrepro
// Render overlays
responses.push_back(
FrontendMessage::UpdateOverlays {
FrontendMessage::UpdateDocumentOverlays {
svg: self.overlays_graphene_document.render_root(ViewMode::Normal),
}
.into(),

View File

@@ -124,7 +124,7 @@ impl PortfolioMessageHandler {
.layer_metadata
.keys()
.filter_map(|path| new_document.layer_panel_entry_from_path(path))
.map(|entry| FrontendMessage::UpdateLayer { data: entry }.into())
.map(|entry| FrontendMessage::UpdateDocumentLayer { data: entry }.into())
.collect::<Vec<_>>(),
);
@@ -181,7 +181,7 @@ impl MessageHandler<PortfolioMessage, &InputPreprocessor> for PortfolioMessageHa
use PortfolioMessage::*;
match message {
RequestAboutGraphiteDialog => {
responses.push_back(FrontendMessage::DisplayAboutGraphiteDialog.into());
responses.push_back(FrontendMessage::DisplayDialogAboutGraphite.into());
}
Document(message) => self.active_document_mut().process_action(message, ipp, responses),
SelectDocument(id) => {
@@ -190,7 +190,7 @@ impl MessageHandler<PortfolioMessage, &InputPreprocessor> for PortfolioMessageHa
responses.push_back(PortfolioMessage::AutoSaveDocument(self.active_document_id).into());
}
self.active_document_id = id;
responses.push_back(FrontendMessage::SetActiveDocument { document_id: id }.into());
responses.push_back(FrontendMessage::UpdateActiveDocument { document_id: id }.into());
responses.push_back(RenderDocument.into());
responses.push_back(DocumentMessage::DocumentStructureChanged.into());
for layer in self.active_document().layer_metadata.keys() {
@@ -259,8 +259,8 @@ impl MessageHandler<PortfolioMessage, &InputPreprocessor> for PortfolioMessageHa
.collect::<Vec<_>>();
responses.push_back(FrontendMessage::UpdateOpenDocumentsList { open_documents }.into());
responses.push_back(FrontendMessage::SetActiveDocument { document_id: self.active_document_id }.into());
responses.push_back(FrontendMessage::RemoveAutoSaveDocument { document_id: id }.into());
responses.push_back(FrontendMessage::UpdateActiveDocument { document_id: self.active_document_id }.into());
responses.push_back(FrontendMessage::TriggerIndexedDbRemoveDocument { document_id: id }.into());
responses.push_back(RenderDocument.into());
responses.push_back(DocumentMessage::DocumentStructureChanged.into());
for layer in self.active_document().layer_metadata.keys() {
@@ -275,7 +275,7 @@ impl MessageHandler<PortfolioMessage, &InputPreprocessor> for PortfolioMessageHa
self.load_document(new_document, document_id, false, responses);
}
OpenDocument => {
responses.push_back(FrontendMessage::OpenDocumentBrowse.into());
responses.push_back(FrontendMessage::TriggerFileUpload.into());
}
OpenDocumentFile(document_name, document) => {
responses.push_back(
@@ -301,7 +301,7 @@ impl MessageHandler<PortfolioMessage, &InputPreprocessor> for PortfolioMessageHa
self.load_document(document, document_id, true, responses);
}
Err(e) => responses.push_back(
FrontendMessage::DisplayError {
FrontendMessage::DisplayDialogError {
title: "Failed to open document".to_string(),
description: e.to_string(),
}
@@ -327,7 +327,7 @@ impl MessageHandler<PortfolioMessage, &InputPreprocessor> for PortfolioMessageHa
AutoSaveDocument(id) => {
let document = self.documents.get(&id).unwrap();
responses.push_back(
FrontendMessage::AutoSaveDocument {
FrontendMessage::TriggerIndexedDbWriteDocument {
document: document.serialize_document(),
details: FrontendDocumentDetails {
is_saved: document.is_saved(),