Fix switch to/from Artboard tool firing an undo (#1668)

* Fix tool switch causing abort of ArtboardTool transaction when it shouldn't

* Add cancellation keyhints

* Unify the cancel keyhints with other tools

* Consolidate hints

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
milan-sedivy 2024-03-11 09:46:38 +02:00 committed by GitHub
parent fd54cda445
commit dcce519426
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -404,7 +404,7 @@ impl Fsm for ArtboardToolFsmState {
ArtboardToolFsmState::Ready
}
(_, ArtboardToolMessage::Abort) => {
(ArtboardToolFsmState::Dragging | ArtboardToolFsmState::Drawing | ArtboardToolFsmState::ResizingBounds, ArtboardToolMessage::Abort) => {
responses.add(DocumentMessage::AbortTransaction);
// ArtboardTool currently doesn't implement snapping
@ -425,10 +425,14 @@ impl Fsm for ArtboardToolFsmState {
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Move Artboard")]),
HintGroup(vec![HintInfo::keys([Key::Backspace], "Delete Artboard")]),
]),
ArtboardToolFsmState::Dragging => HintData(vec![HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain to Axis")])]),
ArtboardToolFsmState::Drawing | ArtboardToolFsmState::ResizingBounds => {
HintData(vec![HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Square"), HintInfo::keys([Key::Alt], "From Center")])])
}
ArtboardToolFsmState::Dragging => HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()]),
HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain to Axis")]),
]),
ArtboardToolFsmState::Drawing | ArtboardToolFsmState::ResizingBounds => HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()]),
HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Square"), HintInfo::keys([Key::Alt], "From Center")]),
]),
};
responses.add(FrontendMessage::UpdateInputHints { hint_data });