Skip to content

Commit

Permalink
[501716] Clear snapping feedback when precise.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwienand committed May 22, 2017
1 parent 855a87d commit 621f234
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ public void drag(MouseEvent e, Dimension delta) {
Point endPositionInScene = startPositionInScene.getTranslated(delta);

// snap to grid
if (!isPrecise(e)) {
endPositionInScene.translate(snapToSupport.snap(delta));
if (snapToSupport != null) {
if (!isPrecise(e)) {
endPositionInScene.translate(snapToSupport.snap(delta));
} else {
snapToSupport.clearSnappingFeedback();
}
}

// perform changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ public void drag(MouseEvent e, Dimension delta) {
}

Point newEndPointInScene = new Point(e.getSceneX(), e.getSceneY());
if (!isPrecise(e)) {
newEndPointInScene.translate(snapToSupport.snap(delta));
if (snapToSupport != null) {
if (!isPrecise(e)) {
newEndPointInScene.translate(snapToSupport.snap(delta));
} else {
snapToSupport.clearSnappingFeedback();
}
}

// perform changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ public void drag(MouseEvent e, Dimension delta) {

// snap the moved vertex (unless isPrecise(e))
Point snappedVertex = newVertex;
if (!isPrecise(e)) {
snappedVertex.translate(snapToSupport
.snap(new Dimension(deltaInScene.x, deltaInScene.y)));
if (snapToSupport != null) {
if (!isPrecise(e)) {
snappedVertex.translate(snapToSupport
.snap(new Dimension(deltaInScene.x, deltaInScene.y)));
} else {
snapToSupport.clearSnappingFeedback();
}
}

// compute delta between initial and snapped vertex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ public class SnapToSupport extends IAdaptable.Bound.Impl<IViewer> {
public SnapToSupport() {
}

/**
* Clear snapping feedback.
*/
public void clearSnappingFeedback() {
// XXX: SnappingModel is only altered during interaction, therefore,
// we do not need to carry these changes out via operations.
SnappingModel snappingModel = getSnappingModel();
if (snappingModel != null) {
snappingModel.setSnappingLocations(
Collections.<SnappingLocation> emptyList());
}
}

private Dimension determineMinimum(ISnapToStrategy snapper,
List<SnappingLocation> locs, Dimension delta) {
Dimension min = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ public void drag(MouseEvent e, Dimension delta) {
Point endInScene = startInScene.getTranslated(delta);

// snap to
if (performSnapping && snapToSupport != null) {
endInScene.translate(snapToSupport.snap(delta));
if (snapToSupport != null) {
if (performSnapping) {
endInScene.translate(snapToSupport.snap(delta));
} else {
snapToSupport.clearSnappingFeedback();
}
}
Point newEndInScene = endInScene.getCopy();

Expand Down

0 comments on commit 621f234

Please sign in to comment.