@Override public void dragDetected(DragDetectEvent arg0) { GraphDataSet dataSet = AmbushGraph.this.currentDataSet; if (arg0.button != 1 || ! zoomedIn(dataSet)) { return; } double xFactor = previewShell.getSize().x / (dataSet.naturalBounds.x * dataSet.zoomFactor); double yFactor = previewShell.getSize().y / (dataSet.naturalBounds.y * dataSet.zoomFactor); // calculate view port origin in preview window coordinates int translatedMainOriginX = (int)(dataSet.mainOrigin.x * xFactor); int translatedMainOriginY = (int)(dataSet.mainOrigin.y * yFactor); // calculate how large the view port is on the preview window int translatedMainWidth = (int)(mainShell.getSize().x * xFactor); int translatedMainHeight = (int)(mainShell.getSize().y * yFactor); if (arg0.x > translatedMainOriginX && arg0.x < translatedMainOriginX + translatedMainWidth && arg0.y > translatedMainOriginY && arg0.y < translatedMainOriginY + translatedMainHeight) { // clicked inside view port, so drag viewport dataSet.dragPoint = new Point(arg0.x, arg0.y); } }
/** * Swaps two tabs and corresponding notes when a user drags one to another. */ private void addSwapTabListener() { tabFolder.addDragDetectListener(new DragDetectListener() { @Override public void dragDetected(DragDetectEvent dragDetectedEvent) { final Rectangle viewRectangle = Geometry.toDisplay(tabFolder.getParent(), tabFolder.getBounds()); final Tracker tracker = new Tracker(tabFolder, SWT.NONE); tracker.setStippled(true); tracker.addListener(SWT.Move, new Listener() { @Override public void handleEvent(Event event) { Point location = new Point(event.x - viewRectangle.x, event.y - viewRectangle.y); CTabItem tabAtLocation = tabFolder.getItem(location); if (tabAtLocation != null) { // Move tracker to follow mouse cursor. tracker.setRectangles(new Rectangle[] { tabAtLocation.getBounds() }); } else { // Mouse cursor no longer above any tab in the action bar, hide tacker. tracker.setRectangles(new Rectangle[0]); } } }); if (tracker.open()) { Rectangle[] rectangles = tracker.getRectangles(); if (rectangles.length > 0) { CTabItem tabToSwap = tabFolder.getItem(new Point(rectangles[0].x, rectangles[0].y)); // Swap selected tab with the one situated at the mouse cursor's position. if (tabToSwap != null) { swapNoteTabs(tabFolder.indexOf(tabToSwap)); } } } tracker.close(); tracker.dispose(); } }); }
@Override public void dragDetected(DragDetectEvent dde) { if (dde.button != 1) { return; } GraphDataSet dataSet = AmbushGraph.this.currentDataSet; dataSet.movingPoint = getClosestPoint(dde.x, dde.y); if (dataSet.movingPoint == null && zoomedIn(dataSet)) { // no point selected, so record where drag started for shifting the screen dataSet.dragPoint = new Point(dde.x, dde.y); } }
@Override public void dragDetected(final DragDetectEvent e) { if (!ok()) return; // System.out.println("Mouse drag detected on " + view.getPartName()); // surface.draggedTo(e.x, e.y); surface.dispatchMouseEvent(SWT.DragDetect); }
@Override public void dragDetected( DragDetectEvent event ) { if( startingPosition != null ) { dragAction.run( startingPosition.x, startingPosition.y, event.x, event.y ); } dragDetector.dragHandled(); }
@Override public void dragDetected( final DragDetectEvent event ) { if ( targetColumn == null ) return; if ( targetColumn == column ) offset = column.header.getSize().x - event.x; else offset = -event.x; dragging = true; }
@Override public void dragDetected( DragDetectEvent e ) { isDragging = true; mouseUp = false; }