mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 06:38:12 +08:00
Allow deleting artboards (#533)
This commit is contained in:
committed by
Keavon Chambers
parent
c4fdc28449
commit
e22030ffb2
@@ -18,9 +18,12 @@ pub enum ArtboardMessage {
|
|||||||
position: (f64, f64),
|
position: (f64, f64),
|
||||||
size: (f64, f64),
|
size: (f64, f64),
|
||||||
},
|
},
|
||||||
|
DeleteArtboard {
|
||||||
|
artboard: LayerId,
|
||||||
|
},
|
||||||
RenderArtboards,
|
RenderArtboards,
|
||||||
ResizeArtboard {
|
ResizeArtboard {
|
||||||
artboard: Vec<LayerId>,
|
artboard: LayerId,
|
||||||
position: (f64, f64),
|
position: (f64, f64),
|
||||||
size: (f64, f64),
|
size: (f64, f64),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ impl MessageHandler<ArtboardMessage, ()> for ArtboardMessageHandler {
|
|||||||
|
|
||||||
responses.push_back(DocumentMessage::RenderDocument.into());
|
responses.push_back(DocumentMessage::RenderDocument.into());
|
||||||
}
|
}
|
||||||
|
DeleteArtboard { artboard } => {
|
||||||
|
self.artboard_ids.retain(|&id| id != artboard);
|
||||||
|
|
||||||
|
responses.push_back(ArtboardMessage::DispatchOperation(Box::new(DocumentOperation::DeleteLayer { path: vec![artboard] })).into());
|
||||||
|
|
||||||
|
responses.push_back(DocumentMessage::RenderDocument.into());
|
||||||
|
}
|
||||||
RenderArtboards => {
|
RenderArtboards => {
|
||||||
// Render an infinite canvas if there are no artboards
|
// Render an infinite canvas if there are no artboards
|
||||||
if self.artboard_ids.is_empty() {
|
if self.artboard_ids.is_empty() {
|
||||||
@@ -76,7 +83,7 @@ impl MessageHandler<ArtboardMessage, ()> for ArtboardMessageHandler {
|
|||||||
ResizeArtboard { artboard, position, size } => {
|
ResizeArtboard { artboard, position, size } => {
|
||||||
responses.push_back(
|
responses.push_back(
|
||||||
ArtboardMessage::DispatchOperation(Box::new(DocumentOperation::SetLayerTransform {
|
ArtboardMessage::DispatchOperation(Box::new(DocumentOperation::SetLayerTransform {
|
||||||
path: artboard,
|
path: vec![artboard],
|
||||||
transform: DAffine2::from_scale_angle_translation(size.into(), 0., position.into()).to_cols_array(),
|
transform: DAffine2::from_scale_angle_translation(size.into(), 0., position.into()).to_cols_array(),
|
||||||
}))
|
}))
|
||||||
.into(),
|
.into(),
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ impl Default for Mapping {
|
|||||||
entry! {action=CropMessage::PointerDown, key_down=Lmb},
|
entry! {action=CropMessage::PointerDown, key_down=Lmb},
|
||||||
entry! {action=CropMessage::PointerMove { constrain_axis_or_aspect: KeyShift, center: KeyAlt }, message=InputMapperMessage::PointerMove},
|
entry! {action=CropMessage::PointerMove { constrain_axis_or_aspect: KeyShift, center: KeyAlt }, message=InputMapperMessage::PointerMove},
|
||||||
entry! {action=CropMessage::PointerUp, key_up=Lmb},
|
entry! {action=CropMessage::PointerUp, key_up=Lmb},
|
||||||
|
entry! {action=CropMessage::DeleteSelected, key_down=KeyDelete},
|
||||||
|
entry! {action=CropMessage::DeleteSelected, key_down=KeyBackspace},
|
||||||
// Navigate
|
// Navigate
|
||||||
entry! {action=NavigateMessage::ClickZoom { zoom_in: false }, key_up=Lmb, modifiers=[KeyShift]},
|
entry! {action=NavigateMessage::ClickZoom { zoom_in: false }, key_up=Lmb, modifiers=[KeyShift]},
|
||||||
entry! {action=NavigateMessage::ClickZoom { zoom_in: true }, key_up=Lmb},
|
entry! {action=NavigateMessage::ClickZoom { zoom_in: true }, key_up=Lmb},
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ pub enum CropMessage {
|
|||||||
DocumentIsDirty,
|
DocumentIsDirty,
|
||||||
|
|
||||||
// Tool-specific messages
|
// Tool-specific messages
|
||||||
|
DeleteSelected,
|
||||||
PointerDown,
|
PointerDown,
|
||||||
PointerMove {
|
PointerMove {
|
||||||
constrain_axis_or_aspect: Key,
|
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 {}
|
impl PropertyHolder for Crop {}
|
||||||
@@ -201,7 +202,7 @@ impl Fsm for CropToolFsmState {
|
|||||||
|
|
||||||
responses.push_back(
|
responses.push_back(
|
||||||
ArtboardMessage::ResizeArtboard {
|
ArtboardMessage::ResizeArtboard {
|
||||||
artboard: vec![data.selected_board.unwrap()],
|
artboard: data.selected_board.unwrap(),
|
||||||
position: position.round().into(),
|
position: position.round().into(),
|
||||||
size: size.round().into(),
|
size: size.round().into(),
|
||||||
}
|
}
|
||||||
@@ -229,7 +230,7 @@ impl Fsm for CropToolFsmState {
|
|||||||
|
|
||||||
responses.push_back(
|
responses.push_back(
|
||||||
ArtboardMessage::ResizeArtboard {
|
ArtboardMessage::ResizeArtboard {
|
||||||
artboard: vec![data.selected_board.unwrap()],
|
artboard: data.selected_board.unwrap(),
|
||||||
position: position.round().into(),
|
position: position.round().into(),
|
||||||
size: size.round().into(),
|
size: size.round().into(),
|
||||||
}
|
}
|
||||||
@@ -265,7 +266,7 @@ impl Fsm for CropToolFsmState {
|
|||||||
|
|
||||||
responses.push_back(
|
responses.push_back(
|
||||||
ArtboardMessage::ResizeArtboard {
|
ArtboardMessage::ResizeArtboard {
|
||||||
artboard: vec![data.selected_board.unwrap()],
|
artboard: data.selected_board.unwrap(),
|
||||||
position: start.round().into(),
|
position: start.round().into(),
|
||||||
size: size.round().into(),
|
size: size.round().into(),
|
||||||
}
|
}
|
||||||
@@ -315,6 +316,13 @@ impl Fsm for CropToolFsmState {
|
|||||||
|
|
||||||
CropToolFsmState::Ready
|
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) => {
|
(_, CropMessage::Abort) => {
|
||||||
if let Some(bounding_box_overlays) = data.bounding_box_overlays.take() {
|
if let Some(bounding_box_overlays) = data.bounding_box_overlays.take() {
|
||||||
bounding_box_overlays.delete(responses);
|
bounding_box_overlays.delete(responses);
|
||||||
|
|||||||
Reference in New Issue
Block a user