Skip to content
14 changes: 10 additions & 4 deletions document-legacy/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions document-legacy/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum DocumentResponse {
LayerChanged {
path: Vec<LayerId>,
},
DeletedSelectedManipulatorPoints,
}

impl fmt::Display for DocumentResponse {
Expand All @@ -31,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"),
}
}
}
17 changes: 17 additions & 0 deletions editor/src/messages/portfolio/document/document_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
);
}
DocumentResponse::DocumentChanged => responses.push_back(RenderDocument.into()),
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.push_back(BroadcastEvent::DocumentIsDirty.into());
}
Expand Down