Skip to content

Commit c807d08

Browse files
committed
Copy rectangles with APIs in DnD
This commit enforces the usage of Rectangle.copyWith and Rectangle.of while copying a rectangle from an existing rectangle and creating a rectangle from a Point making sure the internal state of the source resources are copied to the new resource. contributes to eclipse-platform/eclipse.platform.swt#62 and eclipse-platform/eclipse.platform.swt#128
1 parent a9ec6c9 commit c807d08

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DetachedDropAgent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ public Rectangle getRectangle(MUIElement dragElement) {
9494
}
9595

9696
Point cp = Display.getCurrent().getCursorLocation();
97-
curRect.x = cp.x - 15;
98-
curRect.y = cp.y - 15;
97+
cp.x -= 15;
98+
cp.y -= 15;
99+
curRect = Rectangle.of(cp, curRect.width, curRect.height);
99100

100101
return curRect;
101102
}

bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DnDManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@ private Rectangle getOverlayBounds() {
464464
Rectangle bounds = null;
465465
for (Rectangle fr : frames) {
466466
if (fr.width > 6) {
467-
Rectangle outerBounds = new Rectangle(fr.x - 3, fr.y - 3, fr.width + 6,
468-
fr.height + 6);
467+
Rectangle outerBounds = fr.copyWith(-3, -3, 6, 6);
469468
if (bounds == null) {
470469
bounds = outerBounds;
471470
}

0 commit comments

Comments
 (0)