rename BLANK to EMPY, enhances separator render, fixes menu selection
This commit is contained in:
@@ -16,5 +16,5 @@ public enum WaveformColors {
|
||||
TX_BG, TX_BG_HIGHLITE, TX_BORDER,
|
||||
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNAL_CHANGE, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL, SIGNAL_NAN,
|
||||
CURSOR, CURSOR_DRAG, CURSOR_TEXT,
|
||||
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE, BLANK
|
||||
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE, SEPARATOR
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
|
||||
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
|
||||
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
|
||||
colors[WaveformColors.BLANK.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
|
||||
colors[WaveformColors.SEPARATOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
|
||||
}
|
||||
/**
|
||||
* needs redraw() afterwards
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class BlankPainter extends TrackPainter {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final WaveformCanvas waveCanvas;
|
||||
|
||||
public BlankPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
|
||||
super(trackEntry, even);
|
||||
this.waveCanvas = txDisplay;
|
||||
}
|
||||
|
||||
public void paintArea(Projection proj, Rectangle area) {
|
||||
if (trackEntry.selected)
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE));
|
||||
else
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(even ? WaveformColors.TRACK_BG_EVEN : WaveformColors.TRACK_BG_ODD));
|
||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
proj.fillRectangle(area);
|
||||
int trackHeight=trackEntry.height;
|
||||
int txBase=trackHeight*2/5;
|
||||
int txHeight=trackHeight/5;
|
||||
Rectangle bb = new Rectangle(area.x, area.y+txBase, area.width, txHeight);
|
||||
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.BLANK));
|
||||
proj.fillRectangle(bb);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* MINRES Technologies GmbH - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.ui.swt.internal;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class EmptyPainter extends TrackPainter {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final WaveformCanvas waveCanvas;
|
||||
|
||||
private static final JPanel DUMMY_PANEL = new JPanel();
|
||||
|
||||
public EmptyPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
|
||||
super(trackEntry, even);
|
||||
this.waveCanvas = txDisplay;
|
||||
}
|
||||
|
||||
public void paintArea(Projection proj, Rectangle area) {
|
||||
Color bgColor = trackEntry.selected?this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE):this.waveCanvas.styleProvider.getColor(even ? WaveformColors.TRACK_BG_EVEN : WaveformColors.TRACK_BG_ODD);
|
||||
GC gc = proj.getGC();
|
||||
proj.setBackground(bgColor);
|
||||
proj.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
proj.fillRectangle(area);
|
||||
Color drawColor = this.waveCanvas.styleProvider.getColor(WaveformColors.SEPARATOR);
|
||||
int trackHeight=trackEntry.height;
|
||||
int txBase=trackHeight*2/5;
|
||||
int txHeight=trackHeight/5;
|
||||
proj.setBackground(drawColor);
|
||||
proj.fillRectangle(new Rectangle(area.x, area.y+txBase, area.width, txHeight));
|
||||
|
||||
String label = trackEntry.waveform.getName();
|
||||
if(label.length()>0) {
|
||||
Color textColor=waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_TEXT);
|
||||
FontData fd = gc.getFont().getFontData()[0];
|
||||
int height = gc.getDevice().getDPI().y * fd.getHeight() / 72;
|
||||
java.awt.Font tmpAwtFont = new java.awt.Font(fd.getName(), fd.getStyle(), height);
|
||||
int width = DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(label);
|
||||
|
||||
int xBegin = (area.width-width)/2-5;
|
||||
xBegin = xBegin<0?0:xBegin;
|
||||
int xEnd = (area.width+width)/2+5;
|
||||
xEnd = xEnd>area.width?area.width:xEnd;
|
||||
int yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||
int yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
|
||||
int yOffsetB = 4 * this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
|
||||
int[] points = {
|
||||
xBegin, yOffsetM,
|
||||
xBegin + 1, yOffsetT,
|
||||
xEnd - 1, yOffsetT,
|
||||
xEnd, yOffsetM,
|
||||
xEnd - 1, yOffsetB,
|
||||
xBegin + 1, yOffsetB
|
||||
};
|
||||
gc.setBackground(bgColor);
|
||||
gc.fillPolygon(points);
|
||||
gc.setForeground(drawColor);
|
||||
gc.drawPolygon(points);
|
||||
Rectangle old = gc.getClipping();
|
||||
gc.setForeground(textColor);
|
||||
gc.setClipping(xBegin + 3, yOffsetT, xEnd - xBegin - 5, yOffsetB - yOffsetT);
|
||||
gc.drawText(label, xBegin + 3, yOffsetM - height / 2 - 1);
|
||||
gc.setClipping(old);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,6 +149,24 @@ public class WaveformView implements IWaveformView {
|
||||
if (entry != null)
|
||||
entry.getValue().selected = true;
|
||||
} else if (e.button == 3) {
|
||||
ISelection sel = getSelection();
|
||||
if(sel instanceof StructuredSelection) {
|
||||
if(((StructuredSelection)sel).isEmpty()) {
|
||||
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
setSelection(new StructuredSelection(entry.getValue()), false, false);
|
||||
lastClickedEntry = entry.getValue();
|
||||
} else {
|
||||
StructuredSelection structuredSelection = (StructuredSelection) sel;
|
||||
if(structuredSelection.size()== 1 && structuredSelection.getFirstElement() instanceof TrackEntry) {
|
||||
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
TrackEntry selEntry = (TrackEntry) structuredSelection.getFirstElement();
|
||||
if(!entry.getValue().equals(selEntry)) {
|
||||
setSelection(new StructuredSelection(entry.getValue()), false, false);
|
||||
lastClickedEntry = entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Menu topMenu = top.getMenu();
|
||||
if (topMenu != null)
|
||||
topMenu.setVisible(true);
|
||||
@@ -182,6 +200,7 @@ public class WaveformView implements IWaveformView {
|
||||
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
if(entry != null)
|
||||
setSelection(new StructuredSelection(entry.getValue()), false, false);
|
||||
lastClickedEntry = entry.getValue();
|
||||
for (IWaveformviewEventListener listner : eventListener) {
|
||||
listner.onTrackEntryDoubleClickEvent(entry.getValue());
|
||||
}
|
||||
@@ -613,9 +632,9 @@ public class WaveformView implements IWaveformView {
|
||||
} else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) {
|
||||
streamEntry.currentValue = "---";
|
||||
waveformCanvas.addWaveformPainter(new SignalPainter(waveformCanvas, even, streamEntry), false);
|
||||
} else if (streamEntry.waveform.getType() == WaveformType.BLANK) {
|
||||
} else if (streamEntry.waveform.getType() == WaveformType.EMPTY) {
|
||||
streamEntry.currentValue = "";
|
||||
waveformCanvas.addWaveformPainter(new BlankPainter(waveformCanvas, even, streamEntry), false);
|
||||
waveformCanvas.addWaveformPainter(new EmptyPainter(waveformCanvas, even, streamEntry), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user