diff --git a/diylc/diylc-core/src/org/diylc/common/IMouseProcessor.java b/diylc/diylc-core/src/org/diylc/common/IMouseProcessor.java index b567ca5f..c4c36b60 100644 --- a/diylc/diylc-core/src/org/diylc/common/IMouseProcessor.java +++ b/diylc/diylc-core/src/org/diylc/common/IMouseProcessor.java @@ -37,8 +37,9 @@ public interface IMouseProcessor { * * @param point * @param dragAction + * @param forceSelectionRect */ - void dragStarted(Point point, int dragAction); + void dragStarted(Point point, int dragAction, boolean forceSelectionRect); /** * Checks if it's possible to drop over the specified point. diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java index f63b4ae5..b096bb0e 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java +++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java @@ -899,7 +899,7 @@ public class Presenter implements IPlugInPort { } @Override - public void dragStarted(Point point, int dragAction) { + public void dragStarted(Point point, int dragAction, boolean forceSelectionRect) { LOG.debug(String.format("dragStarted(%s, %s)", point, dragAction)); if (instantiationManager.getComponentTypeSlot() != null) { LOG.debug("Cannot start drag because a new component is being created."); @@ -912,7 +912,7 @@ public class Presenter implements IPlugInPort { this.preDragProject = currentProject.clone(); Point scaledPoint = scalePoint(point); this.previousDragPoint = scaledPoint; - List> components = findComponentsAtScaled(scaledPoint); + List> components = forceSelectionRect ? null : findComponentsAtScaled(scaledPoint); if (!this.controlPointMap.isEmpty()) { // If we're dragging control points reset selection. updateSelection(new ArrayList>(this.controlPointMap.keySet())); @@ -921,7 +921,7 @@ public class Presenter implements IPlugInPort { // messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED, // calculateSelectionDimension()); messageDispatcher.dispatchMessage(EventType.REPAINT); - } else if (components.isEmpty()) { + } else if (components == null || components.isEmpty()) { // If there are no components are under the cursor, reset selection. updateSelection(EMPTY_SELECTION); // messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, @@ -1442,7 +1442,7 @@ public class Presenter implements IPlugInPort { updateSelection(newSelection); - messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), "Duplicate"); + messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), "Duplicate"); projectFileManager.notifyFileChange(); messageDispatcher.dispatchMessage(EventType.REPAINT); } diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasGestureListener.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasGestureListener.java index 4d79e82e..17de84e5 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasGestureListener.java +++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasGestureListener.java @@ -2,6 +2,8 @@ package org.diylc.swing.plugins.canvas; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; import org.diylc.common.IPlugInPort; @@ -21,7 +23,13 @@ class CanvasGestureListener implements DragGestureListener { @Override public void dragGestureRecognized(DragGestureEvent dge) { - presenter.dragStarted(dge.getDragOrigin(), dge.getDragAction()); + boolean forceReSelection = false; + InputEvent e = dge.getTriggerEvent(); + if (e instanceof MouseEvent) { + MouseEvent me = (MouseEvent) e; + forceReSelection = me.getButton() != MouseEvent.BUTTON1; + } + presenter.dragStarted(dge.getDragOrigin(), dge.getDragAction(), forceReSelection); dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(), new CanvasSourceListener( presenter)); } diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index aa86bf8c..0f682498 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -1764,7 +1764,7 @@ NEW_FEATURE - Ability to force components to the front or back of other components even outisde their designated layers, allowing placing components or jumpers below boards, etc. + Ability to force components to the front or back of other components even outisde their designated layers, allowing placing components or jumpers below boards, etc NEW_FEATURE @@ -1772,7 +1772,7 @@ NEW_FEATURE - Duplicate selection option in Edit menu and popup menu (Ctrl+D). + Duplicate selection option in Edit menu and popup menu (Ctrl+D) NEW_FEATURE @@ -1808,6 +1808,22 @@ https://github.com/bancika/diy-layout-creator/releases + + + + 3 + 41 + 0 + + 2017-05-08 00:00:00.000 CET + + + + NEW_FEATURE + Using right click to draw a selection rectangle doesn't move objects under the cursor (useful for selecting multiple components that have a big board below) + + + https://github.com/bancika/diy-layout-creator/releases