Reorganize the menu bar and add additional commands to it

This commit is contained in:
Keavon Chambers
2025-03-01 13:44:28 -08:00
parent fd81d043a2
commit ddb0c8c249
10 changed files with 337 additions and 99 deletions
@@ -60,6 +60,9 @@ pub enum DocumentMessage {
FlipSelectedLayers {
flip_axis: FlipAxis,
},
RotateSelectedLayers {
degrees: f64,
},
GraphViewOverlay {
open: bool,
},
@@ -454,6 +454,30 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
}
}
}
DocumentMessage::RotateSelectedLayers { degrees } => {
// Get the bounding box of selected layers in viewport space
if let Some([min, max]) = self.selected_visible_and_unlock_layers_bounding_box_viewport() {
// Calculate the center of the bounding box to use as rotation pivot
let center = (max + min) / 2.;
// Transform that moves pivot point to origin
let bbox_trans = DAffine2::from_translation(-center);
let mut added_transaction = false;
for layer in self.network_interface.selected_nodes(&[]).unwrap().selected_unlocked_layers(&self.network_interface) {
if !added_transaction {
responses.add(DocumentMessage::AddTransaction);
added_transaction = true;
}
responses.add(GraphOperationMessage::TransformChange {
layer,
transform: DAffine2::from_angle(degrees.to_radians()),
transform_in: TransformIn::Scope { scope: bbox_trans },
skip_rerender: false,
});
}
}
}
DocumentMessage::GraphViewOverlay { open } => {
self.graph_view_overlay_open = open;