-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add G/S shortcut handling to Artboard tool #4039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ pub enum ArtboardToolMessage { | |
| PointerMove { constrain_axis_or_aspect: Key, center: Key }, | ||
| PointerOutsideViewport { constrain_axis_or_aspect: Key, center: Key }, | ||
| PointerUp, | ||
| GS { grab: Key, scale: Key }, | ||
| } | ||
|
|
||
| impl ToolMetadata for ArtboardTool { | ||
|
|
@@ -65,7 +66,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Artb | |
| ); | ||
|
|
||
| let additional = match self.fsm_state { | ||
| ArtboardToolFsmState::Ready { .. } => actions!(ArtboardToolMessageDiscriminant; PointerDown), | ||
| ArtboardToolFsmState::Ready { .. } => actions!(ArtboardToolMessageDiscriminant; PointerDown, GS), | ||
| _ => actions!(ArtboardToolMessageDiscriminant; PointerUp, Abort), | ||
| }; | ||
| common.extend(additional); | ||
|
|
@@ -294,6 +295,26 @@ impl Fsm for ArtboardToolFsmState { | |
|
|
||
| self | ||
| } | ||
| (ArtboardToolFsmState::Ready { .. }, ArtboardToolMessage::GS { grab, scale }) => { | ||
| let to_viewport = document.metadata().document_to_viewport; | ||
| let to_document = to_viewport.inverse(); | ||
| tool_data.drag_start = to_document.transform_point2(input.mouse.position); | ||
| tool_data.drag_current = to_document.transform_point2(input.mouse.position); | ||
|
|
||
| if input.keyboard.key(grab) && tool_data.selected_artboard.is_some() { | ||
| tool_data.get_snap_candidates(document, input); | ||
|
|
||
| responses.add(DocumentMessage::StartTransaction); | ||
|
|
||
| ArtboardToolFsmState::Dragging | ||
| } else if input.keyboard.key(scale) && tool_data.selected_artboard.is_some() { | ||
| //tool_data.start_resizing(selected_edges, document, input); | ||
| tool_data.get_snap_candidates(document, input); | ||
| ArtboardToolFsmState::ResizingBounds | ||
|
Comment on lines
+310
to
+313
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Since this is a keyboard shortcut, you might want to default to resizing from the bottom-right corner or similar. |
||
| } else { | ||
| ArtboardToolFsmState::Ready { hovered } | ||
| } | ||
| } | ||
| (ArtboardToolFsmState::Ready { .. }, ArtboardToolMessage::PointerDown) => { | ||
| let to_viewport = document.metadata().document_to_viewport; | ||
| let to_document = to_viewport.inverse(); | ||
|
|
@@ -586,6 +607,7 @@ impl Fsm for ArtboardToolFsmState { | |
| ArtboardToolFsmState::Ready { .. } => HintData(vec![ | ||
| HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Draw Artboard")]), | ||
| HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Move Artboard")]), | ||
| HintGroup(vec![HintInfo::multi_keys([[Key::KeyG], [Key::KeyS]], "Grab/Scale Selected")]), | ||
| HintGroup(vec![HintInfo::keys([Key::Backspace], "Delete Artboard")]), | ||
| ]), | ||
| ArtboardToolFsmState::Dragging => HintData(vec![ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the commented-out code. If the functionality is intended to be part of this PR, it should be implemented; otherwise, it should be removed to keep the codebase clean.