right click rectangle selection

This commit is contained in:
bancika
2017-05-10 15:25:43 +02:00
parent a8665271b0
commit d1a7227f4c
4 changed files with 33 additions and 8 deletions
@@ -37,8 +37,9 @@ public interface IMouseProcessor {
* *
* @param point * @param point
* @param dragAction * @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. * Checks if it's possible to drop over the specified point.
@@ -899,7 +899,7 @@ public class Presenter implements IPlugInPort {
} }
@Override @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)); LOG.debug(String.format("dragStarted(%s, %s)", point, dragAction));
if (instantiationManager.getComponentTypeSlot() != null) { if (instantiationManager.getComponentTypeSlot() != null) {
LOG.debug("Cannot start drag because a new component is being created."); 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(); this.preDragProject = currentProject.clone();
Point scaledPoint = scalePoint(point); Point scaledPoint = scalePoint(point);
this.previousDragPoint = scaledPoint; this.previousDragPoint = scaledPoint;
List<IDIYComponent<?>> components = findComponentsAtScaled(scaledPoint); List<IDIYComponent<?>> components = forceSelectionRect ? null : findComponentsAtScaled(scaledPoint);
if (!this.controlPointMap.isEmpty()) { if (!this.controlPointMap.isEmpty()) {
// If we're dragging control points reset selection. // If we're dragging control points reset selection.
updateSelection(new ArrayList<IDIYComponent<?>>(this.controlPointMap.keySet())); updateSelection(new ArrayList<IDIYComponent<?>>(this.controlPointMap.keySet()));
@@ -921,7 +921,7 @@ public class Presenter implements IPlugInPort {
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED, // messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
// calculateSelectionDimension()); // calculateSelectionDimension());
messageDispatcher.dispatchMessage(EventType.REPAINT); 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. // If there are no components are under the cursor, reset selection.
updateSelection(EMPTY_SELECTION); updateSelection(EMPTY_SELECTION);
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, // messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
@@ -1442,7 +1442,7 @@ public class Presenter implements IPlugInPort {
updateSelection(newSelection); updateSelection(newSelection);
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), "Duplicate"); messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), "Duplicate");
projectFileManager.notifyFileChange(); projectFileManager.notifyFileChange();
messageDispatcher.dispatchMessage(EventType.REPAINT); messageDispatcher.dispatchMessage(EventType.REPAINT);
} }
@@ -2,6 +2,8 @@ package org.diylc.swing.plugins.canvas;
import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragGestureListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
@@ -21,7 +23,13 @@ class CanvasGestureListener implements DragGestureListener {
@Override @Override
public void dragGestureRecognized(DragGestureEvent dge) { 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( dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(), new CanvasSourceListener(
presenter)); presenter));
} }
+18 -2
View File
@@ -1764,7 +1764,7 @@
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>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.</description> <description>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</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
@@ -1772,7 +1772,7 @@
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Duplicate selection option in Edit menu and popup menu (Ctrl+D).</description> <description>Duplicate selection option in Edit menu and popup menu (Ctrl+D)</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
@@ -1808,6 +1808,22 @@
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>3</major>
<minor>41</minor>
<build>0</build>
</versionNumber>
<releaseDate>2017-05-08 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>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)</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>
</a> </a>
</java.util.Arrays_-ArrayList> </java.util.Arrays_-ArrayList>