mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
dnd collision improvement
This commit is contained in:
+6
-7
@@ -766,27 +766,26 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (entry.getValue().contains(index)) {
|
if (entry.getValue().contains(index)) {
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
controlPoints[index].translate(dx, dy);
|
Point testPoint = new Point(controlPoints[index]);
|
||||||
|
testPoint.translate(dx, dy);
|
||||||
if (ConfigurationManager.getInstance().readBoolean(
|
if (ConfigurationManager.getInstance().readBoolean(
|
||||||
IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||||
CalcUtils.snapPointToGrid(controlPoints[index], currentProject
|
CalcUtils.snapPointToGrid(testPoint, currentProject
|
||||||
.getGridSpacing());
|
.getGridSpacing());
|
||||||
}
|
}
|
||||||
actualDx = controlPoints[index].x - component.getControlPoint(index).x;
|
actualDx = testPoint.x - component.getControlPoint(index).x;
|
||||||
actualDy = controlPoints[index].y - component.getControlPoint(index).y;
|
actualDy = testPoint.y - component.getControlPoint(index).y;
|
||||||
if (actualDx == 0 && actualDy == 0) {
|
if (actualDx == 0 && actualDy == 0) {
|
||||||
// Nothing to move.
|
// Nothing to move.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
controlPoints[index].translate(actualDx, actualDy);
|
controlPoints[index].translate(actualDx, actualDy);
|
||||||
if (controlPoints[index].x < 0 || controlPoints[index].y < 0
|
if (controlPoints[index].x < 0 || controlPoints[index].y < 0
|
||||||
|| controlPoints[index].x > width
|
|| controlPoints[index].x > width
|
||||||
|| controlPoints[index].y > height) {
|
|| controlPoints[index].y > height) {
|
||||||
// At least one control point went out of bounds.
|
// At least one control point went out of bounds.
|
||||||
return true;
|
return true;
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// For control points that may overlap, just write null,
|
// For control points that may overlap, just write null,
|
||||||
@@ -800,7 +799,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
for (int j = i + 1; j < controlPoints.length; j++) {
|
for (int j = i + 1; j < controlPoints.length; j++) {
|
||||||
if (controlPoints[i] != null && controlPoints[j] != null
|
if (controlPoints[i] != null && controlPoints[j] != null
|
||||||
&& controlPoints[i].equals(controlPoints[j])) {
|
&& controlPoints[i].equals(controlPoints[j])) {
|
||||||
LOG.warn("Control points collision detected, cannot make this move.");
|
// Control points collision detected, cannot make this move.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user