Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
entry!(KeyDown(ArrowRight); action_dispatch=ArtboardToolMessage::NudgeSelected { delta_x: NUDGE_AMOUNT, delta_y: 0., resize: Alt, resize_opposite_corner: Control }),
entry!(KeyDown(MouseRight); action_dispatch=ArtboardToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=ArtboardToolMessage::Abort),
entry!(KeyDown(KeyG); action_dispatch=ArtboardToolMessage::GS { grab: KeyG, scale: KeyS }),
entry!(KeyDown(KeyS); action_dispatch=ArtboardToolMessage::GS { grab: KeyG, scale: KeyS }),
//
// NavigateToolMessage
entry!(KeyDown(MouseLeft); action_dispatch=NavigateToolMessage::ZoomCanvasBegin),
Expand Down
24 changes: 23 additions & 1 deletion editor/src/messages/tool/tool_messages/artboard_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

tool_data.get_snap_candidates(document, input);
ArtboardToolFsmState::ResizingBounds
Comment on lines +310 to +313
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The scale branch in the GS message handler is missing several critical initializations required for the ResizingBounds state to function correctly. Specifically, it needs to:

  1. Start a document transaction so the operation can be undone/aborted.
  2. Initialize bounding_box_manager.selected_edges and opposite_pivot. Without selected_edges, the resize_artboard function (called during PointerMove) will return early and do nothing.
  3. Call tool_data.start_resizing to set up the center of transformation and initial location.

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();
Expand Down Expand Up @@ -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![
Expand Down