mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-03 20:38:12 +08:00
Fix snapping bug where snapped-together shapes couldn't be moved (#1818)
* Fixup dragging snap * Reenable snapping by default on some demo art files --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
3657b37574
commit
dba0433100
Generated
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Generated
+1
-1
File diff suppressed because one or more lines are too long
@@ -72,7 +72,7 @@ pub struct SnappingState {
|
|||||||
impl Default for SnappingState {
|
impl Default for SnappingState {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
snapping_enabled: false, // TODO: Reenable this by default once <https://github.com/GraphiteEditor/Graphite/issues/1817> is fixed
|
snapping_enabled: true,
|
||||||
grid_snapping: false,
|
grid_snapping: false,
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
nodes: Default::default(),
|
nodes: Default::default(),
|
||||||
|
|||||||
@@ -226,24 +226,25 @@ pub fn snap_drag(start: DVec2, current: DVec2, axis_align: bool, snap_data: Snap
|
|||||||
let mut best_snap = SnappedPoint::infinite_snap(document.metadata.document_to_viewport.inverse().transform_point2(mouse_position));
|
let mut best_snap = SnappedPoint::infinite_snap(document.metadata.document_to_viewport.inverse().transform_point2(mouse_position));
|
||||||
|
|
||||||
for point in candidates {
|
for point in candidates {
|
||||||
let origin = point.document_point + total_mouse_delta_document;
|
let mut point = point.clone();
|
||||||
|
point.document_point += total_mouse_delta_document;
|
||||||
|
|
||||||
let snapped = if axis_align {
|
let snapped = if axis_align {
|
||||||
snap_manager.constrained_snap(
|
snap_manager.constrained_snap(
|
||||||
&snap_data,
|
&snap_data,
|
||||||
point,
|
&point,
|
||||||
SnapConstraint::Line {
|
SnapConstraint::Line {
|
||||||
origin,
|
origin: point.document_point,
|
||||||
direction: total_mouse_delta_document.try_normalize().unwrap_or(DVec2::X),
|
direction: total_mouse_delta_document.try_normalize().unwrap_or(DVec2::X),
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
snap_manager.free_snap(&snap_data, point, None, false)
|
snap_manager.free_snap(&snap_data, &point, None, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
if best_snap.other_snap_better(&snapped) {
|
if best_snap.other_snap_better(&snapped) {
|
||||||
offset = snapped.snapped_point_document - origin + mouse_delta_document;
|
offset = snapped.snapped_point_document - point.document_point + mouse_delta_document;
|
||||||
best_snap = snapped;
|
best_snap = snapped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
[target.wasm32-unknown-unknown]
|
[target.wasm32-unknown-unknown]
|
||||||
|
|
||||||
rustflags = [
|
rustflags = [
|
||||||
# Currently disabled because of https://github.com/GraphiteEditor/Graphite/issues/1262
|
# Currently disabled because of https://github.com/GraphiteEditor/Graphite/issues/1262
|
||||||
# The current simd implementation leads to undefined behavior
|
# The current simd implementation leads to undefined behavior
|
||||||
|
|||||||
Reference in New Issue
Block a user