add drag area to wavefrom view
This commit is contained in:
parent
18f2a110f0
commit
2b7c9a240f
|
@ -40,6 +40,7 @@ import org.eclipse.swt.dnd.DND;
|
|||
import org.eclipse.swt.dnd.DragSource;
|
||||
import org.eclipse.swt.dnd.DragSourceAdapter;
|
||||
import org.eclipse.swt.dnd.DragSourceEvent;
|
||||
import org.eclipse.swt.dnd.DragSourceListener;
|
||||
import org.eclipse.swt.dnd.DropTarget;
|
||||
import org.eclipse.swt.dnd.DropTargetAdapter;
|
||||
import org.eclipse.swt.dnd.DropTargetEvent;
|
||||
|
@ -50,6 +51,9 @@ import org.eclipse.swt.events.DisposeListener;
|
|||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
import org.eclipse.swt.events.MouseMoveListener;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
|
@ -139,14 +143,21 @@ public class WaveformViewer implements IWaveformViewer {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected MouseListener waveformMouseListener = new MouseAdapter(){
|
||||
Point start;
|
||||
|
||||
class WaveformMouseListener implements MouseMoveListener, MouseListener, PaintListener {
|
||||
Point start, end;
|
||||
List<Object> initialSelected;
|
||||
boolean down=false;
|
||||
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
start=new Point(e.x, e.y);
|
||||
end=new Point(e.x, e.y);
|
||||
down=true;
|
||||
if((e.stateMask&SWT.MODIFIER_MASK)!=0) return; //don't react on modifier
|
||||
if (e.button == 1) {
|
||||
initialSelected = waveformCanvas.getClicked(start);
|
||||
|
@ -156,11 +167,35 @@ public class WaveformViewer implements IWaveformViewer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMove(MouseEvent e) {
|
||||
if(down) {
|
||||
end=new Point(e.x, e.y);
|
||||
asyncUpdate(e.widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintControl(PaintEvent e) {
|
||||
if(down) {
|
||||
GC gc = e.gc;
|
||||
gc.setAlpha(128);
|
||||
int minX = Math.min(start.x, end.x);
|
||||
int maxX = Math.max(start.x, end.x);
|
||||
int width = maxX - minX;
|
||||
gc.fillRectangle(minX, 0, width, e.height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
down=false;
|
||||
if(start==null) return;
|
||||
if((e.stateMask&SWT.MODIFIER_MASK&~SWT.SHIFT)!=0) return; //don't react on modifier
|
||||
if (e.button == 1 && ((e.stateMask&SWT.SHIFT)==0)) {
|
||||
if((e.stateMask&SWT.MODIFIER_MASK&~SWT.SHIFT)!=0) return; //don't react on modifier except shift
|
||||
if(!start.equals(end)){
|
||||
asyncUpdate(e.widget);
|
||||
} else if (e.button == 1 && ((e.stateMask&SWT.SHIFT)==0)) {
|
||||
// set cursor (button 1 and no shift)
|
||||
if(Math.abs(e.x-start.x)<3 && Math.abs(e.y-start.y)<3){
|
||||
// first set cursor time
|
||||
setCursorTime(snapOffsetToEvent(e));
|
||||
|
@ -169,11 +204,12 @@ public class WaveformViewer implements IWaveformViewer {
|
|||
asyncUpdate(e.widget);
|
||||
}
|
||||
}else if (e.button == 2 ||(e.button==1 && (e.stateMask&SWT.SHIFT)!=0)) {
|
||||
// set marker (button 1 and shift)
|
||||
setMarkerTime(snapOffsetToEvent(e), selectedMarker);
|
||||
asyncUpdate(e.widget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected long snapOffsetToEvent(MouseEvent e) {
|
||||
long time= waveformCanvas.getTimeForOffset(e.x);
|
||||
long scaling=5*waveformCanvas.getScaleFactor();
|
||||
|
@ -209,7 +245,9 @@ public class WaveformViewer implements IWaveformViewer {
|
|||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
};
|
||||
protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener();
|
||||
|
||||
public WaveformViewer(Composite parent) {
|
||||
pcs=new PropertyChangeSupport(this);
|
||||
|
@ -309,6 +347,8 @@ public class WaveformViewer implements IWaveformViewer {
|
|||
|
||||
waveformCanvas.setMaxTime(1);
|
||||
waveformCanvas.addMouseListener(waveformMouseListener);
|
||||
waveformCanvas.addMouseMoveListener(waveformMouseListener);
|
||||
waveformCanvas.addPaintListener(waveformMouseListener);
|
||||
|
||||
nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
|
|
@ -65,16 +65,12 @@ import org.eclipse.jface.viewers.StructuredSelection;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseTrackListener;
|
||||
import org.eclipse.swt.events.MouseWheelListener;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
|
@ -281,38 +277,30 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
waveformPane.getWaveformControl().addMouseTrackListener(new MouseTrackListener() {
|
||||
|
||||
@Override
|
||||
public void mouseHover(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExit(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEnter(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
waveformPane.getWaveformControl().addMouseWheelListener(new MouseWheelListener() {
|
||||
|
||||
@Override
|
||||
public void mouseScrolled(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
*/
|
||||
waveformPane.getWaveformControl().addListener(SWT.KeyDown, new Listener() {
|
||||
|
||||
@SuppressWarnings("null")
|
||||
@Override
|
||||
public void handleEvent(Event e) {
|
||||
|
@ -616,8 +604,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
}
|
||||
|
||||
public void saveState(String fileName){
|
||||
|
||||
|
||||
Map<String, String> persistedState = new HashMap<>();
|
||||
persistedState.put(DATABASE_FILE + "S", Integer.toString(filesToLoad.size())); //$NON-NLS-1$
|
||||
Integer index = 0;
|
||||
|
@ -634,8 +620,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
FileOutputStream out = new FileOutputStream(fileName);
|
||||
props.store(out, "Written by SCViewer"); //$NON-NLS-1$
|
||||
out.close();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1043,7 +1027,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
* Sets the zoom fit.
|
||||
*/
|
||||
public void setZoomFit() {
|
||||
|
||||
//actual max time of signal
|
||||
long maxTime = waveformPane.getMaxTime();
|
||||
|
||||
|
|
Loading…
Reference in New Issue