mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 05:08:12 +08:00
Add Path tool support for G/R/S rotation and scaling with a single selected handle (#2180)
* grab_scale_path and backspace for pen * minor improvements and fixes * code-review changes * Avoid more nesting, and other code cleanup --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
9ad6c31483
commit
2e4fb95dea
@@ -648,19 +648,7 @@ impl Fsm for PathToolFsmState {
|
||||
self
|
||||
}
|
||||
(Self::InsertPoint, PathToolMessage::Escape | PathToolMessage::Delete | PathToolMessage::RightClick) => tool_data.end_insertion(shape_editor, responses, InsertEndKind::Abort),
|
||||
(Self::InsertPoint, PathToolMessage::GRS { key: propagate }) => {
|
||||
// MAYBE: use `InputMapperMessage::KeyDown(..)` instead
|
||||
match propagate {
|
||||
// TODO: Don't use `Key::G` directly, instead take it as a variable from the input mappings list like in all other places
|
||||
Key::KeyG => responses.add(TransformLayerMessage::BeginGrab),
|
||||
// TODO: Don't use `Key::R` directly, instead take it as a variable from the input mappings list like in all other places
|
||||
Key::KeyR => responses.add(TransformLayerMessage::BeginRotate),
|
||||
// TODO: Don't use `Key::S` directly, instead take it as a variable from the input mappings list like in all other places
|
||||
Key::KeyS => responses.add(TransformLayerMessage::BeginScale),
|
||||
_ => warn!("Unexpected GRS key"),
|
||||
}
|
||||
tool_data.end_insertion(shape_editor, responses, InsertEndKind::Abort)
|
||||
}
|
||||
(Self::InsertPoint, PathToolMessage::GRS { key: _ }) => PathToolFsmState::InsertPoint,
|
||||
// Mouse down
|
||||
(
|
||||
_,
|
||||
|
||||
@@ -62,6 +62,7 @@ pub enum PenToolMessage {
|
||||
Undo,
|
||||
UpdateOptions(PenOptionsUpdate),
|
||||
RecalculateLatestPointsPosition,
|
||||
RemovePreviousHandle,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
@@ -175,6 +176,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PenTool
|
||||
PointerMove,
|
||||
Confirm,
|
||||
Abort,
|
||||
RemovePreviousHandle,
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -685,6 +687,15 @@ impl Fsm for PenToolFsmState {
|
||||
PenToolFsmState::PlacingAnchor
|
||||
}
|
||||
}
|
||||
(PenToolFsmState::PlacingAnchor, PenToolMessage::RemovePreviousHandle) => {
|
||||
if let Some(last_point) = tool_data.latest_points.last_mut() {
|
||||
last_point.handle_start = last_point.pos;
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
} else {
|
||||
log::warn!("No latest point available to modify handle_start.");
|
||||
}
|
||||
self
|
||||
}
|
||||
(PenToolFsmState::DraggingHandle, PenToolMessage::DragStop) => tool_data
|
||||
.finish_placing_handle(SnapData::new(document, input), transform, responses)
|
||||
.unwrap_or(PenToolFsmState::PlacingAnchor),
|
||||
|
||||
Reference in New Issue
Block a user