Allow deleting artboards (#533)

This commit is contained in:
0HyperCube
2022-02-10 20:03:14 +00:00
committed by Keavon Chambers
parent c4fdc28449
commit e22030ffb2
4 changed files with 26 additions and 6 deletions
+12 -4
View File
@@ -33,6 +33,7 @@ pub enum CropMessage {
DocumentIsDirty,
// Tool-specific messages
DeleteSelected,
PointerDown,
PointerMove {
constrain_axis_or_aspect: Key,
@@ -61,7 +62,7 @@ impl<'a> MessageHandler<ToolMessage, ToolActionHandlerData<'a>> for Crop {
}
}
advertise_actions!(CropMessageDiscriminant; PointerDown, PointerUp, PointerMove, Abort);
advertise_actions!(CropMessageDiscriminant; PointerDown, PointerUp, PointerMove, DeleteSelected, Abort);
}
impl PropertyHolder for Crop {}
@@ -201,7 +202,7 @@ impl Fsm for CropToolFsmState {
responses.push_back(
ArtboardMessage::ResizeArtboard {
artboard: vec![data.selected_board.unwrap()],
artboard: data.selected_board.unwrap(),
position: position.round().into(),
size: size.round().into(),
}
@@ -229,7 +230,7 @@ impl Fsm for CropToolFsmState {
responses.push_back(
ArtboardMessage::ResizeArtboard {
artboard: vec![data.selected_board.unwrap()],
artboard: data.selected_board.unwrap(),
position: position.round().into(),
size: size.round().into(),
}
@@ -265,7 +266,7 @@ impl Fsm for CropToolFsmState {
responses.push_back(
ArtboardMessage::ResizeArtboard {
artboard: vec![data.selected_board.unwrap()],
artboard: data.selected_board.unwrap(),
position: start.round().into(),
size: size.round().into(),
}
@@ -315,6 +316,13 @@ impl Fsm for CropToolFsmState {
CropToolFsmState::Ready
}
(_, CropMessage::DeleteSelected) => {
if let Some(artboard) = data.selected_board.take() {
responses.push_back(ArtboardMessage::DeleteArtboard { artboard }.into());
responses.push_back(ToolMessage::DocumentIsDirty.into());
}
CropToolFsmState::Ready
}
(_, CropMessage::Abort) => {
if let Some(bounding_box_overlays) = data.bounding_box_overlays.take() {
bounding_box_overlays.delete(responses);