mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 16:28:12 +08:00
Fix cancellation of drag actions in all tools where it's missing (#1664)
* Change message sent from DocumentMessage::Undo to DocumentMessage::AbortTransaction while aborting select tool * Fix NavigationTool not aborting * Fix NavigationTool tilt * Make gradient tool abortable * Make PathTool drag actions abortable * Make FreeHand Tool abortable * Make BrushTool abortable * Fix filename typo * Make artboards also abortable * Rearrange key bindings for consistency --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
218e9675fd
commit
aa9a3e648a
@@ -6,4 +6,4 @@ pub mod resize;
|
||||
pub mod shape_editor;
|
||||
pub mod snapping;
|
||||
pub mod transformation_cage;
|
||||
pub mod utility_funcitons;
|
||||
pub mod utility_functions;
|
||||
|
||||
@@ -49,14 +49,23 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for Artboar
|
||||
self.fsm_state.process_event(message, &mut self.data, tool_data, &(), responses, false);
|
||||
}
|
||||
|
||||
advertise_actions!(ArtboardToolMessageDiscriminant;
|
||||
PointerDown,
|
||||
PointerUp,
|
||||
PointerMove,
|
||||
DeleteSelected,
|
||||
NudgeSelected,
|
||||
Abort,
|
||||
);
|
||||
fn actions(&self) -> ActionList {
|
||||
use ArtboardToolFsmState::*;
|
||||
|
||||
let mut common = actions!(ArtboardToolMessageDiscriminant;
|
||||
DeleteSelected,
|
||||
NudgeSelected,
|
||||
PointerMove,
|
||||
);
|
||||
|
||||
let additional = match self.fsm_state {
|
||||
Ready => actions!(ArtboardToolMessageDiscriminant; PointerDown),
|
||||
_ => actions!(ArtboardToolMessageDiscriminant; PointerUp, Abort),
|
||||
};
|
||||
common.extend(additional);
|
||||
|
||||
common
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutHolder for ArtboardTool {
|
||||
@@ -396,8 +405,13 @@ impl Fsm for ArtboardToolFsmState {
|
||||
ArtboardToolFsmState::Ready
|
||||
}
|
||||
(_, ArtboardToolMessage::Abort) => {
|
||||
tool_data.snap_manager.cleanup(responses);
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
|
||||
// ArtboardTool currently doesn't implement snapping
|
||||
// tool_data.snap_manager.cleanup(responses);
|
||||
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
|
||||
ArtboardToolFsmState::Ready
|
||||
}
|
||||
_ => self,
|
||||
|
||||
@@ -228,7 +228,6 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for BrushTo
|
||||
Ready => actions!(BrushToolMessageDiscriminant;
|
||||
DragStart,
|
||||
DragStop,
|
||||
Abort,
|
||||
UpdateOptions,
|
||||
),
|
||||
Drawing => actions!(BrushToolMessageDiscriminant;
|
||||
@@ -370,18 +369,20 @@ impl Fsm for BrushToolFsmState {
|
||||
BrushToolFsmState::Drawing
|
||||
}
|
||||
|
||||
(BrushToolFsmState::Drawing, BrushToolMessage::DragStop) | (BrushToolFsmState::Drawing, BrushToolMessage::Abort) => {
|
||||
(BrushToolFsmState::Drawing, BrushToolMessage::DragStop) => {
|
||||
if !tool_data.strokes.is_empty() {
|
||||
responses.add(DocumentMessage::CommitTransaction);
|
||||
} else {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
}
|
||||
|
||||
tool_data.strokes.clear();
|
||||
|
||||
BrushToolFsmState::Ready
|
||||
}
|
||||
(BrushToolFsmState::Drawing, BrushToolMessage::Abort) => {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
tool_data.strokes.clear();
|
||||
|
||||
BrushToolFsmState::Ready
|
||||
}
|
||||
(_, BrushToolMessage::WorkingColorChanged) => {
|
||||
responses.add(BrushToolMessage::UpdateOptions(BrushToolMessageOptionsUpdate::WorkingColors(
|
||||
Some(global_tool_data.primary_color),
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::messages::portfolio::document::overlays::utility_types::OverlayContex
|
||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||
use crate::messages::tool::common_functionality::color_selector::{ToolColorOptions, ToolColorType};
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils;
|
||||
use crate::messages::tool::common_functionality::utility_funcitons::should_extend;
|
||||
use crate::messages::tool::common_functionality::utility_functions::should_extend;
|
||||
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_core::uuid::generate_uuid;
|
||||
@@ -155,7 +155,6 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for Freehan
|
||||
Ready => actions!(FreehandToolMessageDiscriminant;
|
||||
DragStart,
|
||||
DragStop,
|
||||
Abort,
|
||||
),
|
||||
Drawing => actions!(FreehandToolMessageDiscriminant;
|
||||
DragStop,
|
||||
@@ -277,17 +276,21 @@ impl Fsm for FreehandToolFsmState {
|
||||
|
||||
FreehandToolFsmState::Drawing
|
||||
}
|
||||
(FreehandToolFsmState::Drawing, FreehandToolMessage::DragStop | FreehandToolMessage::Abort) => {
|
||||
(FreehandToolFsmState::Drawing, FreehandToolMessage::DragStop) => {
|
||||
if tool_data.dragged {
|
||||
responses.add(DocumentMessage::CommitTransaction);
|
||||
} else {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
}
|
||||
|
||||
tool_data.layer = None;
|
||||
|
||||
FreehandToolFsmState::Ready
|
||||
}
|
||||
(FreehandToolFsmState::Drawing, FreehandToolMessage::Abort) => {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
tool_data.layer = None;
|
||||
|
||||
FreehandToolFsmState::Ready
|
||||
}
|
||||
(_, FreehandToolMessage::WorkingColorChanged) => {
|
||||
responses.add(FreehandToolMessage::UpdateOptions(FreehandOptionsUpdate::WorkingColors(
|
||||
Some(global_tool_data.primary_color),
|
||||
|
||||
@@ -441,12 +441,14 @@ impl Fsm for GradientToolFsmState {
|
||||
GradientToolFsmState::Ready
|
||||
}
|
||||
|
||||
(_, GradientToolMessage::Abort) => {
|
||||
(GradientToolFsmState::Drawing, GradientToolMessage::Abort) => {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
tool_data.snap_manager.cleanup(responses);
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
|
||||
GradientToolFsmState::Ready
|
||||
}
|
||||
(_, GradientToolMessage::Abort) => GradientToolFsmState::Ready,
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,8 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PathToo
|
||||
DeleteAndBreakPath,
|
||||
),
|
||||
Dragging => actions!(PathToolMessageDiscriminant;
|
||||
Escape,
|
||||
RightClick,
|
||||
FlipSharp,
|
||||
DragStop,
|
||||
PointerMove,
|
||||
@@ -459,7 +461,6 @@ impl Fsm for PathToolFsmState {
|
||||
}
|
||||
tool_data.end_insertion(shape_editor, responses, InsertEndKind::Abort)
|
||||
}
|
||||
|
||||
// Mouse down
|
||||
(_, PathToolMessage::MouseDown { ctrl, shift }) => {
|
||||
let add_to_selection = input.keyboard.get(shift as usize);
|
||||
@@ -492,7 +493,12 @@ impl Fsm for PathToolFsmState {
|
||||
|
||||
PathToolFsmState::Ready
|
||||
}
|
||||
|
||||
(PathToolFsmState::Dragging, PathToolMessage::Escape | PathToolMessage::RightClick) => {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
shape_editor.deselect_all();
|
||||
tool_data.snap_manager.cleanup(responses);
|
||||
PathToolFsmState::Ready
|
||||
}
|
||||
// Mouse up
|
||||
(PathToolFsmState::DrawingBox, PathToolMessage::DragStop { shift_mirror_distance }) => {
|
||||
let shift_pressed = input.keyboard.get(shift_mirror_distance as usize);
|
||||
@@ -507,7 +513,6 @@ impl Fsm for PathToolFsmState {
|
||||
|
||||
PathToolFsmState::Ready
|
||||
}
|
||||
|
||||
(_, PathToolMessage::DragStop { shift_mirror_distance }) => {
|
||||
let shift_pressed = input.keyboard.get(shift_mirror_distance as usize);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::messages::tool::common_functionality::color_selector::{ToolColorOptio
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils;
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils::get_subpaths;
|
||||
use crate::messages::tool::common_functionality::snapping::{SnapCandidatePoint, SnapConstraint, SnapData, SnapManager};
|
||||
use crate::messages::tool::common_functionality::utility_funcitons::should_extend;
|
||||
use crate::messages::tool::common_functionality::utility_functions::should_extend;
|
||||
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_core::uuid::{generate_uuid, ManipulatorGroupId};
|
||||
|
||||
@@ -950,7 +950,7 @@ impl Fsm for SelectToolFsmState {
|
||||
}
|
||||
(SelectToolFsmState::Dragging, SelectToolMessage::Abort) => {
|
||||
tool_data.snap_manager.cleanup(responses);
|
||||
responses.add(DocumentMessage::Undo);
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
|
||||
SelectToolFsmState::Ready
|
||||
|
||||
Reference in New Issue
Block a user