Fixed cursor dragging
This commit is contained in:
parent
cd8c9195c1
commit
93f147555b
|
@ -31,9 +31,11 @@ import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.CLabel;
|
import org.eclipse.swt.custom.CLabel;
|
||||||
import org.eclipse.swt.custom.SashForm;
|
import org.eclipse.swt.custom.SashForm;
|
||||||
import org.eclipse.swt.custom.ScrolledComposite;
|
import org.eclipse.swt.custom.ScrolledComposite;
|
||||||
|
import org.eclipse.swt.custom.StyledText;
|
||||||
import org.eclipse.swt.dnd.DND;
|
import org.eclipse.swt.dnd.DND;
|
||||||
import org.eclipse.swt.dnd.DragSource;
|
import org.eclipse.swt.dnd.DragSource;
|
||||||
import org.eclipse.swt.dnd.DragSourceAdapter;
|
import org.eclipse.swt.dnd.DragSourceAdapter;
|
||||||
|
import org.eclipse.swt.dnd.DragSourceEffect;
|
||||||
import org.eclipse.swt.dnd.DragSourceEvent;
|
import org.eclipse.swt.dnd.DragSourceEvent;
|
||||||
import org.eclipse.swt.dnd.DropTarget;
|
import org.eclipse.swt.dnd.DropTarget;
|
||||||
import org.eclipse.swt.dnd.DropTargetAdapter;
|
import org.eclipse.swt.dnd.DropTargetAdapter;
|
||||||
|
@ -56,6 +58,7 @@ import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
import org.eclipse.swt.widgets.Canvas;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
@ -515,8 +518,12 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
Entry<Integer, IWaveform<? extends IWaveformEvent>> entry = trackVerticalOffset.floorEntry(e.y);
|
Entry<Integer, IWaveform<? extends IWaveformEvent>> entry = trackVerticalOffset.floorEntry(e.y);
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
setSelection(new StructuredSelection(entry.getValue()));
|
setSelection(new StructuredSelection(entry.getValue()));
|
||||||
}
|
} else if (e.button == 1&& e.widget == trackList) {
|
||||||
if (e.button == 3) {
|
Object o = trackList.getClicked(new Point(e.x, e.y));
|
||||||
|
if (o != null && o instanceof CursorPainter)
|
||||||
|
setSelection(new StructuredSelection(o));
|
||||||
|
|
||||||
|
} else if (e.button == 3) {
|
||||||
top.getMenu().setVisible(true);
|
top.getMenu().setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -697,9 +704,16 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTrackDragSource(final Canvas canvas) {
|
private void createTrackDragSource(final Canvas canvas) {
|
||||||
|
final Display display = canvas.getDisplay();
|
||||||
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
|
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
|
||||||
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);
|
||||||
dragSource.setTransfer(types);
|
dragSource.setTransfer(types);
|
||||||
|
dragSource.setDragSourceEffect(new DragSourceEffect(canvas) {
|
||||||
|
@Override
|
||||||
|
public void dragStart(DragSourceEvent event) {
|
||||||
|
// event.image = display.getSystemImage(SWT.ICON_INFORMATION);
|
||||||
|
}
|
||||||
|
});
|
||||||
dragSource.addDragListener(new DragSourceAdapter() {
|
dragSource.addDragListener(new DragSourceAdapter() {
|
||||||
public void dragStart(DragSourceEvent event) {
|
public void dragStart(DragSourceEvent event) {
|
||||||
// System.out.println("dragStart");
|
// System.out.println("dragStart");
|
||||||
|
@ -751,6 +765,19 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
|
||||||
}
|
}
|
||||||
if(currentCursorSelection!=null) currentCursorSelection.setDragging(false);
|
if(currentCursorSelection!=null) currentCursorSelection.setDragging(false);
|
||||||
}
|
}
|
||||||
|
public void dragOver(DropTargetEvent event){
|
||||||
|
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||||
|
if(sel!=null && sel instanceof IStructuredSelection){
|
||||||
|
Object selObject = ((IStructuredSelection)sel).getFirstElement();
|
||||||
|
if(selObject instanceof CursorPainter){
|
||||||
|
DropTarget tgt = (DropTarget) event.widget;
|
||||||
|
Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y);
|
||||||
|
// painter.setTime(trackList.getTimeForOffset(dropPoint.x));
|
||||||
|
setCursorTime(trackList.getTimeForOffset(dropPoint.x));
|
||||||
|
((Canvas) tgt.getControl()).redraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue