Moving multiple components doesn't honor snap to grid OFF setting

This commit is contained in:
bancika
2013-04-26 14:19:32 +00:00
parent 16ce229b57
commit eb58f1786a
3 changed files with 9 additions and 6 deletions
@@ -140,8 +140,8 @@ public class InstantiationManager {
} }
} }
} }
int x = (minX + maxX) / 2; int x = minX;
int y = (minY + maxY) / 2; int y = minY;
if (snapToGrid) { if (snapToGrid) {
x = CalcUtils.roundToGrid(x, gridSpacing); x = CalcUtils.roundToGrid(x, gridSpacing);
x = CalcUtils.roundToGrid(x, gridSpacing); x = CalcUtils.roundToGrid(x, gridSpacing);
@@ -687,7 +687,7 @@ public class Presenter implements IPlugInPort {
} }
Project oldProject = currentProject.clone(); Project oldProject = currentProject.clone();
moveSelectedComponents(controlPointMap, dx, dy, snapToGrid); moveComponents(controlPointMap, dx, dy, snapToGrid);
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
oldProject, currentProject.clone(), "Move Selection"); oldProject, currentProject.clone(), "Move Selection");
messageDispatcher.dispatchMessage(EventType.REPAINT); messageDispatcher.dispatchMessage(EventType.REPAINT);
@@ -1007,7 +1007,7 @@ public class Presenter implements IPlugInPort {
int dx = (scaledPoint.x - previousDragPoint.x); int dx = (scaledPoint.x - previousDragPoint.x);
int dy = (scaledPoint.y - previousDragPoint.y); int dy = (scaledPoint.y - previousDragPoint.y);
Point actualD = moveSelectedComponents(this.controlPointMap, dx, Point actualD = moveComponents(this.controlPointMap, dx,
dy, isSnapToGrid()); dy, isSnapToGrid());
if (actualD == null) if (actualD == null)
return true; return true;
@@ -1031,7 +1031,7 @@ public class Presenter implements IPlugInPort {
return true; return true;
} }
private Point moveSelectedComponents( private Point moveComponents(
Map<IDIYComponent<?>, Set<Integer>> controlPointMap, int dx, Map<IDIYComponent<?>, Set<Integer>> controlPointMap, int dx,
int dy, boolean snapToGrid) { int dy, boolean snapToGrid) {
// After we make the transfer and snap to grid, calculate actual dx // After we make the transfer and snap to grid, calculate actual dx
@@ -1058,11 +1058,14 @@ public class Presenter implements IPlugInPort {
actualDx = testPoint.x - firstPoint.x; actualDx = testPoint.x - firstPoint.x;
actualDy = testPoint.y - firstPoint.y; actualDy = testPoint.y - firstPoint.y;
} else { } else if (snapToGrid) {
actualDx = CalcUtils.roundToGrid(dx, currentProject actualDx = CalcUtils.roundToGrid(dx, currentProject
.getGridSpacing()); .getGridSpacing());
actualDy = CalcUtils.roundToGrid(dy, currentProject actualDy = CalcUtils.roundToGrid(dy, currentProject
.getGridSpacing()); .getGridSpacing());
} else {
actualDx = dx;
actualDy = dy;
} }
if (actualDx == 0 && actualDy == 0) { if (actualDx == 0 && actualDy == 0) {