From a195cce0ca499c4dcd56b07298086adb70fbe8dd Mon Sep 17 00:00:00 2001 From: auto-kad Date: Thu, 19 Jan 2023 02:58:19 -0500 Subject: [PATCH 1/7] Added new DocumentResponse variant --- document-legacy/src/response.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/document-legacy/src/response.rs b/document-legacy/src/response.rs index 979ddddf65..39ecf9f9b4 100644 --- a/document-legacy/src/response.rs +++ b/document-legacy/src/response.rs @@ -21,6 +21,7 @@ pub enum DocumentResponse { LayerChanged { path: Vec, }, + DeletedSelectedManipulatorPoints, } impl fmt::Display for DocumentResponse { From 8f357913918fac9f91ec3517905b2f613169dfb8 Mon Sep 17 00:00:00 2001 From: auto-kad Date: Thu, 19 Jan 2023 03:11:21 -0500 Subject: [PATCH 2/7] Update Operation::DeleteSelectedManipulatorPoints to update Layer Tree by delegating deletion to Operation::DeleteLayer. Also emits Operation::DeletedSelectedManipulatorPoints to let editor clear Properties panel --- document-legacy/src/document.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/document-legacy/src/document.rs b/document-legacy/src/document.rs index e632cafa09..fb6fec602c 100644 --- a/document-legacy/src/document.rs +++ b/document-legacy/src/document.rs @@ -1098,10 +1098,16 @@ impl Document { // Delete the layer if there are no longer any manipulator groups if (shape.manipulator_groups().len() - 1) == 0 { - self.delete(&layer_path)?; - responses.push(DocumentChanged); - responses.push(DocumentResponse::DeletedLayer { path: layer_path }); - return Ok(Some(responses)); + // delegate deletion to DeleteLayer to update Layer Tree in frontend + match self.handle_operation(Operation::DeleteLayer { path: layer_path.clone() }, font_cache) { + Ok(Some(delete_responses)) => { + responses.extend(delete_responses); + responses.push(DocumentResponse::DeletedSelectedManipulatorPoints); + return Ok(Some(responses)); + } + Err(e) => error!("DocumentError: {:?}", e), + Ok(_) => {} + } } // If we still have manipulator groups, update the layer and thumbnails From e14df3a8a85d020519e0860cb472ff3acdab737b Mon Sep 17 00:00:00 2001 From: auto-kad Date: Thu, 19 Jan 2023 03:15:14 -0500 Subject: [PATCH 3/7] Update process_message() to deal with new DocumentResponse::DeletedSelectedManipulatorPoints match case. When this DocumentResponse is emitted, it clears the Properties panel. --- .../document/document_message_handler.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index 6c11d26e6e..b52d042f82 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -142,6 +142,29 @@ impl MessageHandler responses.push_back(RenderDocument.into()), + DocumentResponse::DeletedSelectedManipulatorPoints => { + // clear Properties panel after deleting all points + responses.push_back( + FrontendMessage::UpdatePropertyPanelOptionsLayout { + layout_target: PropertiesOptions, + diff: vec![WidgetDiff { + widget_path: vec![], + new_value: DiffUpdate::SubLayout(vec![]), + }], + } + .into(), + ); + responses.push_back( + FrontendMessage::UpdatePropertyPanelSectionsLayout { + layout_target: PropertiesSections, + diff: vec![WidgetDiff { + widget_path: vec![], + new_value: DiffUpdate::SubLayout(vec![]), + }], + } + .into(), + ); + } }; responses.push_back(BroadcastEvent::DocumentIsDirty.into()); } From a193f33ff1a648865e4ea59ede4044f83932ec7d Mon Sep 17 00:00:00 2001 From: auto-kad Date: Thu, 19 Jan 2023 03:30:30 -0500 Subject: [PATCH 4/7] Added Display trait implementation for DocumentResponse::DeletedSelectedManipulatorPoints. Updated imports in document_message_handler.rs to get the correct types for messages emitted from DocumentResponse::DeletedSelectedManipulatorPoints match case in process_message(). --- document-legacy/src/response.rs | 3 ++- .../messages/portfolio/document/document_message_handler.rs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/document-legacy/src/response.rs b/document-legacy/src/response.rs index 39ecf9f9b4..83e154d531 100644 --- a/document-legacy/src/response.rs +++ b/document-legacy/src/response.rs @@ -1,4 +1,4 @@ -use crate::LayerId; +use crate::{document::Document, LayerId}; use serde::{Deserialize, Serialize}; use std::fmt; @@ -32,6 +32,7 @@ impl fmt::Display for DocumentResponse { DocumentResponse::CreatedLayer { .. } => write!(f, "CreatedLayer"), DocumentResponse::LayerChanged { .. } => write!(f, "LayerChanged"), DocumentResponse::DeletedLayer { .. } => write!(f, "DeleteLayer"), + DocumentResponse::DeletedSelectedManipulatorPoints { .. } => write!(f, "DeletedSelectedManipulatorPoints"), } } } diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index b52d042f82..d7d001faea 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -5,7 +5,7 @@ use crate::consts::{ASYMPTOTIC_EFFECT, DEFAULT_DOCUMENT_NAME, FILE_SAVE_SUFFIX, use crate::messages::frontend::utility_types::ExportBounds; use crate::messages::frontend::utility_types::{FileType, FrontendImageData}; use crate::messages::input_mapper::utility_types::macros::action_keys; -use crate::messages::layout::utility_types::layout_widget::{Layout, LayoutGroup, Widget, WidgetCallback, WidgetHolder, WidgetLayout}; +use crate::messages::layout::utility_types::layout_widget::{DiffUpdate, Layout, LayoutGroup, Widget, WidgetCallback, WidgetDiff, WidgetHolder, WidgetLayout}; use crate::messages::layout::utility_types::misc::LayoutTarget; use crate::messages::layout::utility_types::widgets::button_widgets::{IconButton, PopoverButton}; use crate::messages::layout::utility_types::widgets::input_widgets::{ @@ -146,7 +146,7 @@ impl MessageHandler Date: Fri, 20 Jan 2023 21:52:31 -0500 Subject: [PATCH 5/7] Removed useless import. Capitalized comments for style consistency. --- document-legacy/src/document.rs | 2 +- document-legacy/src/response.rs | 2 +- .../src/messages/portfolio/document/document_message_handler.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/document-legacy/src/document.rs b/document-legacy/src/document.rs index fb6fec602c..28cdc0fc91 100644 --- a/document-legacy/src/document.rs +++ b/document-legacy/src/document.rs @@ -1098,7 +1098,7 @@ impl Document { // Delete the layer if there are no longer any manipulator groups if (shape.manipulator_groups().len() - 1) == 0 { - // delegate deletion to DeleteLayer to update Layer Tree in frontend + // Delegate deletion to DeleteLayer to update Layer Tree in frontend match self.handle_operation(Operation::DeleteLayer { path: layer_path.clone() }, font_cache) { Ok(Some(delete_responses)) => { responses.extend(delete_responses); diff --git a/document-legacy/src/response.rs b/document-legacy/src/response.rs index 83e154d531..3d1537dd56 100644 --- a/document-legacy/src/response.rs +++ b/document-legacy/src/response.rs @@ -1,4 +1,4 @@ -use crate::{document::Document, LayerId}; +use crate::LayerId; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index d7d001faea..26a51587bf 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -143,7 +143,7 @@ impl MessageHandler responses.push_back(RenderDocument.into()), DocumentResponse::DeletedSelectedManipulatorPoints => { - // clear Properties panel after deleting all points + // Clear Properties panel after deleting all points responses.push_back( FrontendMessage::UpdatePropertyPanelOptionsLayout { layout_target: LayoutTarget::PropertiesOptions, From 3ee089276f6c4a2b9934bad40e68ed6eb22b15f4 Mon Sep 17 00:00:00 2001 From: auto-kad Date: Sat, 28 Jan 2023 17:29:50 -0500 Subject: [PATCH 6/7] Updated messages emitted to clear Properties panel by emitting LayoutMessage::SendLayout's instead, which update the backend widget state --- .../document/document_message_handler.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index 42c638ad06..44b8f5e8e9 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -144,24 +144,18 @@ impl MessageHandler responses.push_back(RenderDocument.into()), DocumentResponse::DeletedSelectedManipulatorPoints => { - // Clear Properties panel after deleting all points + // Clear Properties panel after deleting all points by updating backend widget state. responses.push_back( - FrontendMessage::UpdatePropertyPanelOptionsLayout { + LayoutMessage::SendLayout { + layout: Layout::WidgetLayout(WidgetLayout::new(vec![])), layout_target: LayoutTarget::PropertiesOptions, - diff: vec![WidgetDiff { - widget_path: vec![], - new_value: DiffUpdate::SubLayout(vec![]), - }], } .into(), ); responses.push_back( - FrontendMessage::UpdatePropertyPanelSectionsLayout { + LayoutMessage::SendLayout { + layout: Layout::WidgetLayout(WidgetLayout::new(vec![])), layout_target: LayoutTarget::PropertiesSections, - diff: vec![WidgetDiff { - widget_path: vec![], - new_value: DiffUpdate::SubLayout(vec![]), - }], } .into(), ); From ac3b0cbf37499e6282ed0a2309beafe9939c39e6 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sat, 28 Jan 2023 15:25:51 -0800 Subject: [PATCH 7/7] Revert inclusion of unused imports --- .../src/messages/portfolio/document/document_message_handler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index 44b8f5e8e9..8972484e9a 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -5,7 +5,7 @@ use crate::consts::{ASYMPTOTIC_EFFECT, DEFAULT_DOCUMENT_NAME, FILE_SAVE_SUFFIX, use crate::messages::frontend::utility_types::ExportBounds; use crate::messages::frontend::utility_types::{FileType, FrontendImageData}; use crate::messages::input_mapper::utility_types::macros::action_keys; -use crate::messages::layout::utility_types::layout_widget::{DiffUpdate, Layout, LayoutGroup, Widget, WidgetCallback, WidgetDiff, WidgetHolder, WidgetLayout}; +use crate::messages::layout::utility_types::layout_widget::{Layout, LayoutGroup, Widget, WidgetCallback, WidgetHolder, WidgetLayout}; use crate::messages::layout::utility_types::misc::LayoutTarget; use crate::messages::layout::utility_types::widgets::button_widgets::{IconButton, PopoverButton}; use crate::messages::layout::utility_types::widgets::input_widgets::{