mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 06:58:12 +08:00
Layer snapping
* Test snapping * Snap new shapes * Fix snapping when zoomed * Refactor to use viewport bounds * Reduce snap tolerance to 3 * Snap line and path tool * Add disable snapping and refactor * new_snap -> new status * Rearrange import * Cleanup * Fix incorrect variable name * Store snap data in tool data
This commit is contained in:
committed by
Keavon Chambers
parent
26835d8d29
commit
0e33498b9b
@@ -49,7 +49,6 @@ impl Default for RectangleToolFsmState {
|
||||
}
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct RectangleToolData {
|
||||
sides: u8,
|
||||
data: Resize,
|
||||
}
|
||||
|
||||
@@ -59,7 +58,7 @@ impl Fsm for RectangleToolFsmState {
|
||||
fn transition(
|
||||
self,
|
||||
event: ToolMessage,
|
||||
_document: &DocumentMessageHandler,
|
||||
document: &DocumentMessageHandler,
|
||||
tool_data: &DocumentToolData,
|
||||
data: &mut Self::ToolData,
|
||||
input: &InputPreprocessor,
|
||||
@@ -71,7 +70,7 @@ impl Fsm for RectangleToolFsmState {
|
||||
if let ToolMessage::Rectangle(event) = event {
|
||||
match (self, event) {
|
||||
(Ready, DragStart) => {
|
||||
shape_data.drag_start = input.mouse.position;
|
||||
shape_data.start(document, input.mouse.position);
|
||||
responses.push_back(DocumentMessage::StartTransaction.into());
|
||||
shape_data.path = Some(vec![generate_uuid()]);
|
||||
responses.push_back(DocumentMessage::DeselectAllLayers.into());
|
||||
@@ -89,7 +88,7 @@ impl Fsm for RectangleToolFsmState {
|
||||
Dragging
|
||||
}
|
||||
(state, Resize { center, lock_ratio }) => {
|
||||
if let Some(message) = shape_data.calculate_transform(center, lock_ratio, input) {
|
||||
if let Some(message) = shape_data.calculate_transform(document, center, lock_ratio, input) {
|
||||
responses.push_back(message);
|
||||
}
|
||||
|
||||
@@ -102,12 +101,12 @@ impl Fsm for RectangleToolFsmState {
|
||||
false => responses.push_back(DocumentMessage::CommitTransaction.into()),
|
||||
}
|
||||
|
||||
shape_data.path = None;
|
||||
shape_data.cleanup();
|
||||
Ready
|
||||
}
|
||||
(Dragging, Abort) => {
|
||||
responses.push_back(DocumentMessage::AbortTransaction.into());
|
||||
shape_data.path = None;
|
||||
shape_data.cleanup();
|
||||
|
||||
Ready
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user