Skip to content

Commit 65100b3

Browse files
committed
Add Grab shortcut functionality to Artboard tool
1 parent e2117d9 commit 65100b3

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

editor/src/messages/input_mapper/input_mappings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
149149
entry!(KeyDown(ArrowRight); action_dispatch=ArtboardToolMessage::NudgeSelected { delta_x: NUDGE_AMOUNT, delta_y: 0., resize: Alt, resize_opposite_corner: Control }),
150150
entry!(KeyDown(MouseRight); action_dispatch=ArtboardToolMessage::Abort),
151151
entry!(KeyDown(Escape); action_dispatch=ArtboardToolMessage::Abort),
152+
entry!(KeyDown(KeyG); action_dispatch=ArtboardToolMessage::GS { grab: KeyG, scale: KeyS }),
153+
entry!(KeyDown(KeyS); action_dispatch=ArtboardToolMessage::GS { grab: KeyG, scale: KeyS }),
152154
//
153155
// NavigateToolMessage
154156
entry!(KeyDown(MouseLeft); action_dispatch=NavigateToolMessage::ZoomCanvasBegin),

editor/src/messages/tool/tool_messages/artboard_tool.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub enum ArtboardToolMessage {
3737
PointerMove { constrain_axis_or_aspect: Key, center: Key },
3838
PointerOutsideViewport { constrain_axis_or_aspect: Key, center: Key },
3939
PointerUp,
40+
GS { grab: Key, scale: Key },
4041
}
4142

4243
impl ToolMetadata for ArtboardTool {
@@ -65,7 +66,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Artb
6566
);
6667

6768
let additional = match self.fsm_state {
68-
ArtboardToolFsmState::Ready { .. } => actions!(ArtboardToolMessageDiscriminant; PointerDown),
69+
ArtboardToolFsmState::Ready { .. } => actions!(ArtboardToolMessageDiscriminant; PointerDown, GS),
6970
_ => actions!(ArtboardToolMessageDiscriminant; PointerUp, Abort),
7071
};
7172
common.extend(additional);
@@ -294,6 +295,26 @@ impl Fsm for ArtboardToolFsmState {
294295

295296
self
296297
}
298+
(ArtboardToolFsmState::Ready { .. }, ArtboardToolMessage::GS { grab, scale }) => {
299+
let to_viewport = document.metadata().document_to_viewport;
300+
let to_document = to_viewport.inverse();
301+
tool_data.drag_start = to_document.transform_point2(input.mouse.position);
302+
tool_data.drag_current = to_document.transform_point2(input.mouse.position);
303+
304+
if input.keyboard.key(grab) && tool_data.selected_artboard.is_some() {
305+
tool_data.get_snap_candidates(document, input);
306+
307+
responses.add(DocumentMessage::StartTransaction);
308+
309+
ArtboardToolFsmState::Dragging
310+
} else if input.keyboard.key(scale) && tool_data.selected_artboard.is_some() {
311+
//tool_data.start_resizing(selected_edges, document, input);
312+
tool_data.get_snap_candidates(document, input);
313+
ArtboardToolFsmState::ResizingBounds
314+
} else {
315+
ArtboardToolFsmState::Ready { hovered }
316+
}
317+
}
297318
(ArtboardToolFsmState::Ready { .. }, ArtboardToolMessage::PointerDown) => {
298319
let to_viewport = document.metadata().document_to_viewport;
299320
let to_document = to_viewport.inverse();
@@ -586,6 +607,7 @@ impl Fsm for ArtboardToolFsmState {
586607
ArtboardToolFsmState::Ready { .. } => HintData(vec![
587608
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Draw Artboard")]),
588609
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Move Artboard")]),
610+
HintGroup(vec![HintInfo::multi_keys([[Key::KeyG], [Key::KeyS]], "Grab/Scale Selected")]),
589611
HintGroup(vec![HintInfo::keys([Key::Backspace], "Delete Artboard")]),
590612
]),
591613
ArtboardToolFsmState::Dragging => HintData(vec![

0 commit comments

Comments
 (0)