From bd0629301b8df62c731f9f2e8ef319ceb5806e92 Mon Sep 17 00:00:00 2001
From: Eyck Jentzsch
Date: Thu, 6 Jan 2022 17:48:40 +0100
Subject: [PATCH] add next increment - basically working
---
.../ui/swt/internal/WaveformCanvas.java | 50 +-
.../ui/swt/internal/WaveformView.java | 19 +-
.../ui/swt/internal/slider/ImageButton.java | 49 +-
.../ui/swt/internal/slider/RangeSlider.java | 1305 +++--------------
.../internal/slider/TimeZoomScrollbar.java | 20 +-
.../ui/swt/internal/slider/h-slider-drag.png | Bin 1057 -> 0 bytes
.../ui/swt/internal/slider/h-slider-hover.png | Bin 1057 -> 0 bytes
.../swt/internal/slider/h-slider-normal.png | Bin 1055 -> 0 bytes
.../swt/internal/slider/h-slider-selected.png | Bin 1041 -> 0 bytes
.../ui/swt/internal/slider/marker_l.png | Bin 374 -> 350 bytes
.../ui/swt/internal/slider/marker_l_bl.png | Bin 353 -> 0 bytes
.../ui/swt/internal/slider/marker_l_bl_lt.png | Bin 343 -> 0 bytes
.../ui/swt/internal/slider/marker_l_hover.png | Bin 0 -> 336 bytes
.../ui/swt/internal/slider/marker_l_lt.png | Bin 385 -> 0 bytes
.../swt/internal/slider/marker_l_pressed.png | Bin 0 -> 352 bytes
.../ui/swt/internal/slider/marker_r.png | Bin 358 -> 329 bytes
.../ui/swt/internal/slider/marker_r_bl.png | Bin 386 -> 0 bytes
.../ui/swt/internal/slider/marker_r_bl_lt.png | Bin 366 -> 0 bytes
.../ui/swt/internal/slider/marker_r_hover.png | Bin 0 -> 326 bytes
.../ui/swt/internal/slider/marker_r_lt.png | Bin 345 -> 0 bytes
.../swt/internal/slider/marker_r_pressed.png | Bin 0 -> 349 bytes
.../ui/swt/internal/slider/slider-drag.png | Bin 1085 -> 0 bytes
.../ui/swt/internal/slider/slider-hover.png | Bin 1083 -> 0 bytes
.../ui/swt/internal/slider/slider-normal.png | Bin 1072 -> 0 bytes
.../swt/internal/slider/slider-selected.png | Bin 430 -> 0 bytes
.../e4/application/parts/WaveformViewer.java | 11 +-
26 files changed, 330 insertions(+), 1124 deletions(-)
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/h-slider-drag.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/h-slider-hover.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/h-slider-normal.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/h-slider-selected.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_l_bl.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_l_bl_lt.png
create mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_l_hover.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_l_lt.png
create mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_l_pressed.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_bl.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_bl_lt.png
create mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_hover.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_lt.png
create mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_pressed.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-drag.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-hover.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-normal.png
delete mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-selected.png
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java
index e2e3712..5f7cde9 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java
@@ -84,6 +84,8 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
private TimeZoomScrollbar horizontal;
+ private int[] lastHorSelection;
+
private ScrollBar vertical;
HashMap wave2painterMap;
@@ -156,10 +158,10 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
public void setOrigin(int x, int y) {
checkWidget();
- if(x<=0) horizontal.setSelection(-x);
- x = -horizontal.getSelection()[0];
- if(y<=0) vertical.setSelection(-y);
- y = -vertical.getSelection();
+// if(x<=0) horizontal.setSelection(-x);
+// x = -horizontal.getSelection()[0];
+// if(y<=0) vertical.setSelection(-y);
+// y = -vertical.getSelection();
origin.x = x;
origin.y = y;
syncSb();
@@ -300,18 +302,24 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
public void widgetSelected(SelectionEvent event) {
if (!painterList.isEmpty()) {
int[] sel = horizontal.getSelection();
- //long width = maxTime / getScale();
- int currentThumbWidth = getClientArea().width;
- int newThumbWidth = sel[1]-sel[0];
- if(currentThumbWidth!=newThumbWidth) {
- long newScaleFactor =getScale()*newThumbWidth/currentThumbWidth;
- updateScaleFactor(Math.max(1, newScaleFactor));
+ long lowerTime = sel[0]*maxTime/horizontal.getMaximum();
+ long upperTime = sel[1]*maxTime/horizontal.getMaximum();
+ if(sel[1]-sel[0] != lastHorSelection[1]-lastHorSelection[0]) {
+ long time_diff = upperTime-lowerTime;
+ long factor = time_diff/getClientArea().width;
+ setScalingFactor(factor, lowerTime+time_diff/2);
+ } else {
+ origin.x = -(int) (lowerTime / getScale());
+ event.widget.getDisplay().asyncExec(() -> {redraw();});
}
- origin.x=-sel[0];
- syncSb();
+ lastHorSelection=sel;
}
}
});
+ horizontal.setMinimum(0);
+ horizontal.setMaximum(10000);
+ lastHorSelection = horizontal.getSelection();
+
vertical.setEnabled(false);
vertical.setVisible(true);
vertical.addSelectionListener(new SelectionAdapter() {
@@ -319,7 +327,8 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
public void widgetSelected(SelectionEvent event) {
if (!painterList.isEmpty()) {
origin.y=-vertical.getSelection();
- syncSb();
+ fireSelectionEvent();
+ event.widget.getDisplay().asyncExec(() -> {redraw();});
}
}
});
@@ -363,16 +372,15 @@ public class WaveformCanvas extends Canvas implements IWaveformZoom{
private void syncHSb() {
horizontal.setEnabled(wave2painterMap.size()>0);
Rectangle clientArea=getClientArea();
- long width = maxTime / getScale();
int clientWidth = clientArea.width;
- horizontal.setIncrement(clientWidth / 100);
- horizontal.setPageIncrement(clientWidth/2);
- horizontal.setMinimum(0);
- horizontal.setMaximum((int)width);
- if (width>0 && -origin.x > horizontal.getMaximum() - clientWidth) {
- origin.x = -horizontal.getMaximum() + clientWidth;
+ if(maxTime>0) {
+ int lower = (int) ( -origin.x * getScale() * horizontal.getMaximum() / maxTime);
+ int upper = (int) ((clientWidth-origin.x) * getScale() * horizontal.getMaximum() / maxTime);
+ int[] curSel = horizontal.getSelection();
+ lastHorSelection = new int[] {Math.max(lower,0), Math.min(upper, horizontal.getMaximum())};
+ horizontal.setSelection(lastHorSelection);
}
- horizontal.setSelection(new int[] {Math.max(-origin.x,0), Math.min(clientWidth-origin.x, horizontal.getMaximum())});
+ long width = maxTime / getScale();
horizontal.setButtonsEnabled(width > clientWidth);
}
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
index 80f92a4..755af81 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java
@@ -267,11 +267,24 @@ public class WaveformView implements IWaveformView {
switch (e.type) {
case SWT.MouseWheel:
if((e.stateMask & SWT.CTRL) != 0) {
- if(e.count<0)
+ if(e.count<0) // up scroll
waveformCanvas.setScale(waveformCanvas.getScale()*11/10);
- else
+ else // down scroll
waveformCanvas.setScale(waveformCanvas.getScale()*10/11);
- }
+ e.doit=false;
+ } else if((e.stateMask & SWT.SHIFT) != 0) {
+ long upper = waveformCanvas.getMaxVisibleTime();
+ long lower = waveformCanvas.getMinVisibleTime();
+ long duration = upper-lower;
+ if(e.count<0) { // up scroll
+ long newLower = Math.min(waveformCanvas.getMaxTime()-duration, lower+duration/10);
+ waveformCanvas.setMinVisibleTime(newLower);
+ } else {// down scroll
+ long newLower = Math.max(0, lower-duration/10);
+ waveformCanvas.setMinVisibleTime(newLower);
+ }
+ e.doit=false;
+ }
break;
case SWT.MouseDown:
start = new Point(e.x, e.y);
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/ImageButton.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/ImageButton.java
index cc4a667..91841fb 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/ImageButton.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/ImageButton.java
@@ -2,6 +2,9 @@ package com.minres.scviewer.database.ui.swt.internal.slider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@@ -46,24 +49,36 @@ public class ImageButton extends Composite
addListener(SWT.Paint, event -> {
paintControl(event);
});
- addListener(SWT.MouseDown, event -> {
- if(!isEnabled()) return;
- pressed=true;
- notifyListeners();
- if(autoFire) actionTimer.activate();
- redraw();
+ addMouseTrackListener(new MouseTrackAdapter() {
+ public void mouseEnter(MouseEvent arg0) {
+ if(isEnabled()) {
+ hover=true;
+ redraw();
+ }
+ }
+ public void mouseExit(MouseEvent arg0) {
+ if(isEnabled()) {
+ hover=false;
+ redraw();
+ }
+ }
});
- addListener(SWT.MouseUp, event -> {
- pressed=false;
- redraw();
- });
- addListener(SWT.MouseMove, event -> {
- if(!isEnabled()) return;
- Point sz = ((ImageButton)event.widget).getSize();
- final boolean within_x = event.x>0 && event.x0 && event.y
- *
- * - Styles:
- * - BORDER
- * - HORIZONTAL
- * - VERTICAL
- * - CONTROL - Allow key and mouse manipulation to control both lower and
- * upper value thumbs simultaneously
- * - ON - Indicates that selection listeners are notified continuously during
- * thumb drag events. Otherwise, notification occurs only after the drag event
- * terminates.
- * - HIGH - Indicates high quality tick marks are generated dynamically to a
- * factor of the pageIncrement or increment. Otherwise, tick marks divide the
- * scale evenly into ten parts.
- * - SMOOTH - Indicates mouse manipulation of upper and lower values are
- * computed smoothly from the exact mouse cursor position disregarding the
- * increment value. Otherwise, values are constrained to an incremental
- * value.
- * - Events:
- * - Selection
- *
- *
- *
- * Note: Styles HORIZONTAL and VERTICAL are mutually exclusive.
- *
- */
public class RangeSlider extends Canvas {
- private static final byte NONE = 0;
- private static final byte UPPER = 1 << 0;
- private static final byte LOWER = 1 << 1;
- private static final byte BOTH = UPPER | LOWER;
+ private static final int NONE = 0;
+ private static final int UPPER = 1 << 0;
+ private static final int LOWER = 1 << 1;
+ private static final int BOTH = UPPER | LOWER;
- private static int minWidth = 18;
- private static int minHeight = 18;
- private static int imgWidth = 8;
- private static int minThumbWidth = 5;
+ private final int minHeight;
+ private final int markerWidth;
+ private final int thumbWidth = 0;
+ private final Image[] slider, sliderHover, sliderDrag;
+
private int minimum;
private int maximum;
private int lowerValue;
private int upperValue;
- private final Image[] slider, sliderHover, sliderDrag, sliderSelected;
- private final Image vSlider, vSliderHover, vSliderDrag, vSliderSelected;
- private int orientation;
+
private int increment;
private int pageIncrement;
- private byte selectedElement, priorSelectedElement;
- private boolean dragInProgress;
+ private int selectedElement;
private boolean upperHover, lowerHover;
private int previousUpperValue, previousLowerValue;
private int startDragUpperValue, startDragLowerValue;
private Point startDragPoint;
- private boolean hasFocus;
private final boolean isSmooth;
- private final boolean isFullSelection;
+ private final boolean isFullSelection=false;
private final boolean isHighQuality;
private final boolean isOn;
private Format toolTipFormatter;
private String clientToolTipText;
+ private StringBuffer toolTip;
+ private Point coordUpper;
+ private Point coordLower;
- /**
- * Constructs a new instance of this class given its parent and a style value
- * describing its behavior and appearance.
- *
- * The style value is either one of the style constants defined in class
- * SWT
which is applicable to instances of this class, or must be
- * built by bitwise OR'ing together (that is, using the
- * int
"|" operator) two or more of those SWT
style
- * constants. The class description lists the style constants that are
- * applicable to the class. Style bits are also inherited from superclasses.
- *
- *
- * @param parent a composite control which will be the parent of the new
- * instance (cannot be null)
- * @param style the style of control to construct. Default style is HORIZONTAL
- *
- * @exception IllegalArgumentException
- *
- * - ERROR_NULL_ARGUMENT - if the parent is null
- *
- * @exception SWTException
- *
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the parent
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see Widget#getStyle
- *
- */
public RangeSlider(final Composite parent, final int style) {
super(parent, SWT.DOUBLE_BUFFERED | ((style & SWT.BORDER) == SWT.BORDER ? SWT.BORDER : SWT.NONE));
- minimum = lowerValue = 0;
- maximum = upperValue = 100;
- increment = 1;
- pageIncrement = 10;
slider = new Image[] {
SWTResourceManager.getImage(this.getClass(), "marker_l.png"),
SWTResourceManager.getImage(this.getClass(), "marker_r.png")};
sliderHover = new Image[] {
- SWTResourceManager.getImage(this.getClass(), "marker_l_lt.png"),
- SWTResourceManager.getImage(this.getClass(), "marker_r_lt.png")};
+ SWTResourceManager.getImage(this.getClass(), "marker_l_hover.png"),
+ SWTResourceManager.getImage(this.getClass(), "marker_r_hover.png")};
sliderDrag = new Image[] {
- SWTResourceManager.getImage(this.getClass(), "marker_l_bl.png"),
- SWTResourceManager.getImage(this.getClass(), "marker_r_bl.png")};
- sliderSelected = new Image[] {
- SWTResourceManager.getImage(this.getClass(), "marker_l_bl_lt.png"),
- SWTResourceManager.getImage(this.getClass(), "marker_r_bl_lt.png")};
-
- vSlider = SWTResourceManager.getImage(this.getClass(), "h-slider-normal.png");
- vSliderHover = SWTResourceManager.getImage(this.getClass(), "h-slider-hover.png");
- vSliderDrag = SWTResourceManager.getImage(this.getClass(), "h-slider-drag.png");
- vSliderSelected = SWTResourceManager.getImage(this.getClass(), "h-slider-selected.png");
-
- if ((style & SWT.VERTICAL) == SWT.VERTICAL) {
- orientation = SWT.VERTICAL;
- } else {
- orientation = SWT.HORIZONTAL;
- }
+ SWTResourceManager.getImage(this.getClass(), "marker_l_pressed.png"),
+ SWTResourceManager.getImage(this.getClass(), "marker_r_pressed.png")};
+ Rectangle imgSize = slider[0].getBounds();
+ minHeight =imgSize.height+2;
+ markerWidth = imgSize.width;
+ minimum = lowerValue = 0;
+ maximum = upperValue = 100;
+ increment = 1;
+ pageIncrement = 10;
isSmooth = (style & SWT.SMOOTH) == SWT.SMOOTH;
- isFullSelection = (style & SWT.CONTROL) == SWT.CONTROL;
isHighQuality = (style & SWT.HIGH) == SWT.HIGH;
isOn = (style & SWT.ON) == SWT.ON;
- selectedElement = isFullSelection ? BOTH : LOWER;
+ selectedElement = NONE;
addMouseListeners();
addListener(SWT.Resize, event -> {
});
- addListener(SWT.FocusIn, e -> {
- hasFocus = true;
- redraw();
- });
- addListener(SWT.FocusOut, e -> {
- hasFocus = false;
- redraw();
- });
addListener(SWT.KeyDown, event -> {
handleKeyDown(event);
});
@@ -165,22 +86,37 @@ public class RangeSlider extends Canvas {
@Override
public int getStyle() {
- return super.getStyle() | orientation | (isSmooth ? SWT.SMOOTH : SWT.NONE) | //
+ return super.getStyle() | (isSmooth ? SWT.SMOOTH : SWT.NONE) | //
(isOn ? SWT.ON : SWT.NONE) | //
(isFullSelection ? SWT.CONTROL : SWT.NONE) | //
(isHighQuality ? SWT.HIGH : SWT.NONE);
}
- /**
- * Add the mouse listeners (mouse up, mouse down, mouse move, mouse wheel)
- */
private void addMouseListeners() {
- addListener(SWT.MouseDown, event -> {
- handleMouseDown(event);
+ addListener(SWT.MouseDown, e -> {
+ if (e.button == 1) {
+ selectKnobs(e);
+ if (upperHover || lowerHover) {
+ selectedElement = (lowerHover ? LOWER : NONE) + (upperHover ? UPPER : NONE);
+ startDragLowerValue = previousLowerValue = lowerValue;
+ startDragUpperValue = previousUpperValue = upperValue;
+ startDragPoint = new Point(e.x, e.y);
+ }
+ }
});
- addListener(SWT.MouseUp, event -> {
- handleMouseUp(event);
+ addListener(SWT.MouseUp, e -> {
+ if (selectedElement!=NONE) {
+ startDragPoint = null;
+ validateNewValues(e);
+ super.setToolTipText(clientToolTipText);
+ selectedElement=NONE;
+ redraw();
+ }
+ });
+
+ addListener(SWT.MouseDoubleClick, event -> {
+ handleMouseDoubleClick(event);
});
addListener(SWT.MouseMove, event -> {
@@ -195,51 +131,15 @@ public class RangeSlider extends Canvas {
handleMouseHover(event);
});
- addListener(SWT.MouseDoubleClick, event -> {
- handleMouseDoubleClick(event);
+ addMouseTrackListener(new MouseTrackAdapter() {
+ public void mouseExit(MouseEvent event) {
+ lowerHover = upperHover = false;
+ redraw();
+ }
});
+
}
- /**
- * Code executed when the mouse is down
- *
- * @param e event
- */
- private void handleMouseDown(final Event e) {
- selectKnobs(e);
- if (e.count == 1) {
- priorSelectedElement = selectedElement;
- }
- if (upperHover || lowerHover) {
- selectedElement = isFullSelection && lowerHover && upperHover ? BOTH : lowerHover ? LOWER : upperHover ? UPPER : selectedElement;
- dragInProgress = true;
- startDragLowerValue = previousLowerValue = lowerValue;
- startDragUpperValue = previousUpperValue = upperValue;
- startDragPoint = new Point(e.x, e.y);
- }
- }
-
- /**
- * Code executed when the mouse is up
- *
- * @param e event
- */
- private void handleMouseUp(final Event e) {
- if (dragInProgress) {
- startDragPoint = null;
- validateNewValues(e);
- dragInProgress = false;
- super.setToolTipText(clientToolTipText);
- }
- }
-
- /**
- * invoke selection listeners if either upper or lower value has changed. if
- * listeners reject the change, restore the previous values. redraw if either
- * upper or lower value has changed.
- *
- * @param e event
- */
private void validateNewValues(final Event e) {
if (upperValue != previousUpperValue || lowerValue != previousLowerValue) {
if (!SelectionListenerUtil.fireSelectionListeners(this,e)) {
@@ -248,18 +148,15 @@ public class RangeSlider extends Canvas {
}
previousUpperValue = upperValue;
previousLowerValue = lowerValue;
+ increment = Math.max(1, (upperValue-lowerValue)/100);
+ pageIncrement = Math.max(1, (upperValue-lowerValue)/2);
redraw();
}
}
- /**
- * Code executed when the mouse pointer is moving
- *
- * @param e event
- */
private void handleMouseMove(final Event e) {
- if (!dragInProgress) {
+ if (selectedElement==NONE) {
final boolean wasUpper = upperHover;
final boolean wasLower = lowerHover;
selectKnobs(e);
@@ -267,75 +164,39 @@ public class RangeSlider extends Canvas {
redraw();
}
} else { // dragInProgress
- final int x = e.x, y = e.y;
- if (orientation == SWT.HORIZONTAL) {
- if (selectedElement == BOTH) {
- final int diff = (int) ((startDragPoint.x - x) / computePixelSizeForHorizontalSlider()) + minimum;
- int newUpper = startDragUpperValue - diff;
- int newLower = startDragLowerValue - diff;
- if (newUpper > maximum) {
- newUpper = maximum;
- newLower = maximum - (startDragUpperValue - startDragLowerValue);
- } else if (newLower < minimum) {
- newLower = minimum;
- newUpper = minimum + startDragUpperValue - startDragLowerValue;
- }
- upperValue = newUpper;
- lowerValue = newLower;
- if (!isSmooth) {
- lowerValue = (int) (Math.ceil(lowerValue / increment) * increment) - increment;
- upperValue = (int) (Math.ceil(upperValue / increment) * increment) - increment;
- }
- handleToolTip(lowerValue, upperValue);
- } else if ((selectedElement & UPPER) != 0) {
- upperValue = (int) Math.round((x - 9d) / computePixelSizeForHorizontalSlider()) + minimum;
- if (!isSmooth) {
- upperValue = Math.min(lowerValue, (int) (Math.ceil(upperValue / increment) * increment) - increment);
- }
- checkUpperValue();
- handleToolTip(upperValue);
- } else {
- lowerValue = (int) Math.round((x - 9d) / computePixelSizeForHorizontalSlider()) + minimum;
- if (!isSmooth) {
- lowerValue = Math.max(upperValue, (int) (Math.ceil(lowerValue / increment) * increment) - increment);
- }
- checkLowerValue();
- handleToolTip(lowerValue);
+ final int x = e.x;
+ if (selectedElement == BOTH) {
+ final int diff = (int) ((startDragPoint.x - x) / computePixelSizeForSlider()) + minimum;
+ int newUpper = startDragUpperValue - diff;
+ int newLower = startDragLowerValue - diff;
+ if (newUpper > maximum) {
+ newUpper = maximum;
+ newLower = maximum - (startDragUpperValue - startDragLowerValue);
+ } else if (newLower < minimum) {
+ newLower = minimum;
+ newUpper = minimum + startDragUpperValue - startDragLowerValue;
}
- } else {
- if (selectedElement == BOTH) {
- final int diff = (int) ((startDragPoint.y - y) / computePixelSizeForVerticalSlider()) + minimum;
- int newUpper = startDragUpperValue - diff;
- int newLower = startDragLowerValue - diff;
- if (newUpper > maximum) {
- newUpper = maximum;
- newLower = maximum - (startDragUpperValue - startDragLowerValue);
- } else if (newLower < minimum) {
- newLower = minimum;
- newUpper = minimum + startDragUpperValue - startDragLowerValue;
- }
- upperValue = newUpper;
- lowerValue = newLower;
- if (!isSmooth) {
- lowerValue = (int) (Math.ceil(lowerValue / increment) * increment) - increment;
- upperValue = (int) (Math.ceil(upperValue / increment) * increment) - increment;
- }
- handleToolTip(lowerValue, upperValue);
- } else if ((selectedElement & UPPER) != 0) {
- upperValue = (int) Math.round((y - 9d) / computePixelSizeForVerticalSlider()) + minimum;
- if (!isSmooth) {
- upperValue = (int) (Math.ceil(upperValue / increment) * increment) - increment;
- }
- checkUpperValue();
- handleToolTip(upperValue);
- } else {
- lowerValue = (int) Math.round((y - 9d) / computePixelSizeForVerticalSlider()) + minimum;
- if (!isSmooth) {
- lowerValue = (int) (Math.ceil(lowerValue / increment) * increment) - increment;
- }
- checkLowerValue();
- handleToolTip(lowerValue);
+ upperValue = newUpper;
+ lowerValue = newLower;
+ if (!isSmooth) {
+ lowerValue = (int) (Math.ceil(lowerValue / increment) * increment) - increment;
+ upperValue = (int) (Math.ceil(upperValue / increment) * increment) - increment;
}
+ handleToolTip(lowerValue, upperValue);
+ } else if (selectedElement == UPPER) {
+ upperValue = (int) Math.round((x - 9d) / computePixelSizeForSlider()) + minimum;
+ if (!isSmooth) {
+ upperValue = Math.min(lowerValue, (int) (Math.ceil(upperValue / increment) * increment) - increment);
+ }
+ checkUpperValue();
+ handleToolTip(upperValue);
+ } else if (selectedElement == LOWER){
+ lowerValue = (int) Math.round((x - 9d) / computePixelSizeForSlider()) + minimum;
+ if (!isSmooth) {
+ lowerValue = Math.max(upperValue, (int) (Math.ceil(lowerValue / increment) * increment) - increment);
+ }
+ checkLowerValue();
+ handleToolTip(lowerValue);
}
if (isOn) {
validateNewValues(e);
@@ -345,126 +206,48 @@ public class RangeSlider extends Canvas {
}
}
- /**
- * determine whether the input coordinate is within the scale bounds and between
- * the current upper and lower values.
- *
- * @param x
- * @param y
- * @return
- */
private boolean isBetweenKnobs(int x, int y) {
- return orientation == SWT.HORIZONTAL ? x < coordUpper.x && x > coordLower.x && y >= minHeight/3 && y <= minHeight/3 + getClientArea().height - 2*minHeight/3 : //
- y < coordUpper.y && y > coordLower.y && x >= minWidth/3 && x <= minWidth/3 + getClientArea().width - 2*minWidth/3;
+ return x < coordUpper.x && x > coordLower.x && y >= minHeight/3 && y <= minHeight/3 + getClientArea().height - 2*minHeight/3;
}
- /**
- * set the upperHover and lowerHover values according to the coordinates of the
- * input event, the key modifier state, and whether the style allows selection
- * of both knobs.
- *
- * @param e
- */
private void selectKnobs(final Event e) {
if (coordLower == null) {
return;
}
- final Image img = orientation == SWT.HORIZONTAL ? slider[0] : vSlider;
+ final Image img = slider[0];
final Rectangle imgBounds = img.getBounds();
final int x = e.x, y = e.y;
lowerHover = x >= coordLower.x && x <= coordLower.x + imgBounds.width && y >= coordLower.y && y <= coordLower.y + imgBounds.height;
upperHover = ((e.stateMask & (SWT.CTRL | SWT.SHIFT)) != 0 || !lowerHover) && //
x >= coordUpper.x && x <= coordUpper.x + imgBounds.width && //
y >= coordUpper.y && y <= coordUpper.y + imgBounds.height;
- lowerHover &= (e.stateMask & SWT.CTRL) != 0 || !upperHover;
- if (!lowerHover && !upperHover && isFullSelection && isBetweenKnobs(x, y)) {
- lowerHover = upperHover = true;
- }
+ lowerHover &= (e.stateMask & SWT.CTRL) != 0 || !upperHover;
+ if (!lowerHover && !upperHover && isBetweenKnobs(x, y)) {
+ lowerHover = upperHover = true;
+ }
}
- /**
- * if the input coordinate is within the scale bounds, return the corresponding
- * scale value of the coordinate. otherwise return -1.
- *
- * @param x x coordinate value
- * @param y y coordinate value
- * @return
- */
private int getCursorValue(int x, int y) {
int value = -1;
final Rectangle clientArea = getClientArea();
- if (orientation == SWT.HORIZONTAL) {
- if (x < clientArea.width - 2*imgWidth && x >= imgWidth && y >= minHeight/3 && y <= clientArea.height - minHeight/3) {
- value = (int) Math.round((x - 9d) / computePixelSizeForHorizontalSlider()) + minimum;
- }
- } else if (y < 9 + clientArea.height - 20 && y >= 9 && x >= 9 && x <= 9 + clientArea.width - 20) {
- value = (int) Math.round((y - 9d) / computePixelSizeForVerticalSlider()) + minimum;
+ if (x < clientArea.width - 2*markerWidth && x >= markerWidth && y >= minHeight/3 && y <= clientArea.height - minHeight/3) {
+ value = (int) Math.round((x - 9d) / computePixelSizeForSlider()) + minimum;
}
return value;
}
- /**
- * Code executed when the mouse double click
- *
- * @param e event
- */
private void handleMouseDoubleClick(final Event e) {
final int value = getCursorValue(e.x, e.y);
if (value >= 0) {
- selectedElement = priorSelectedElement;
if (value > upperValue) {
- if (selectedElement == BOTH) {
- lowerValue += value - upperValue;
- upperValue = value;
- } else if ((selectedElement & UPPER) != 0) {
- upperValue = value;
- } else if ((selectedElement & LOWER) != 0) {
- final int diff = upperValue - lowerValue;
- if (value + diff > maximum) {
- upperValue = maximum;
- lowerValue = maximum - diff;
- } else {
- upperValue = value + diff;
- lowerValue = value;
- }
- }
+ translateValues(value-upperValue);
} else if (value < lowerValue) {
- if (selectedElement == BOTH) {
- upperValue += value - lowerValue;
- lowerValue = value;
- } else if ((selectedElement & LOWER) != 0) {
- lowerValue = value;
- } else if ((selectedElement & UPPER) != 0) {
- final int diff = upperValue - lowerValue;
- if (value - diff < minimum) {
- lowerValue = minimum;
- upperValue = minimum + diff;
- } else {
- upperValue = value;
- lowerValue = value - diff;
- }
- }
- } else if (value > lowerValue && value < upperValue && selectedElement != BOTH) {
- if ((selectedElement & LOWER) != 0) {
- lowerValue = value;
- } else if ((selectedElement & UPPER) != 0) {
- upperValue = value;
- }
+ translateValues(value-lowerValue);
}
validateNewValues(e);
}
}
- private StringBuffer toolTip;
- private Point coordUpper;
- private Point coordLower;
-
- /**
- * set the tooltip if a toolTipFormatter is present. either one or two values
- * are accepted.
- *
- * @param values
- */
private void handleToolTip(int... values) {
if (toolTipFormatter != null) {
try {
@@ -485,13 +268,8 @@ public class RangeSlider extends Canvas {
}
}
- /**
- * Code executed on mouse hover
- *
- * @param e event
- */
private void handleMouseHover(final Event e) {
- if (!dragInProgress && toolTipFormatter != null) {
+ if (selectedElement!=NONE && toolTipFormatter != null) {
final int value = getCursorValue(e.x, e.y);
if (value >= 0) {
try {
@@ -507,16 +285,6 @@ public class RangeSlider extends Canvas {
}
}
- /**
- * a formatter for displaying a tool tip when hovering over the scale and during
- * thumb modification events. The
- * {@link Format#format(Object, StringBuffer, java.text.FieldPosition)} method
- * is invoked to retrieve the text for the tooltip where the input
- * {@code Object} is an {@code Integer} with a value within the minimum and
- * maximum.
- *
- * @param formatter
- */
public void setToolTipFormatter(Format formatter) {
toolTip = formatter != null ? new StringBuffer() : null;
toolTipFormatter = formatter;
@@ -527,13 +295,8 @@ public class RangeSlider extends Canvas {
super.setToolTipText(clientToolTipText = string);
}
- /**
- * Code executed when the mouse wheel is activated
- *
- * @param e event
- */
private void handleMouseWheel(final Event e) {
- if (selectedElement == NONE || dragInProgress) {
+ if (selectedElement == NONE) {
e.doit = false; // we are consuming this event
return;
}
@@ -563,41 +326,26 @@ public class RangeSlider extends Canvas {
e.doit = false; // we are consuming this event
}
- /**
- * Check if the lower value is in ranges
- */
private void checkLowerValue() {
if (lowerValue < minimum) {
lowerValue = minimum;
- }
- if (lowerValue > (maximum-minThumbWidth)) {
- lowerValue = (maximum-minThumbWidth);
- }
- if (lowerValue > (upperValue-minThumbWidth)) {
- lowerValue = (upperValue-minThumbWidth);
+ } else if (lowerValue > (upperValue-thumbWidth)) {
+ lowerValue = (upperValue-thumbWidth);
}
}
- /**
- * Check if the upper value is in ranges
- */
private void checkUpperValue() {
- if (upperValue < (minimum+minThumbWidth)) {
- upperValue = minimum+minThumbWidth;
- }
if (upperValue > maximum) {
upperValue = maximum;
- }
- if (upperValue < (lowerValue+minThumbWidth)) {
- upperValue = lowerValue+minThumbWidth;
+ } else if (upperValue < (lowerValue+thumbWidth)) {
+ upperValue = lowerValue+thumbWidth;
}
}
- /**
- * Draws the widget
- *
- * @param e paint event
- */
+ private float computePixelSizeForSlider() {
+ return (getClientArea().width - 2.0f*markerWidth) / (maximum - minimum);
+ }
+
private void drawWidget(final PaintEvent e) {
final Rectangle rect = getClientArea();
if (rect.width == 0 || rect.height == 0) {
@@ -605,50 +353,28 @@ public class RangeSlider extends Canvas {
}
e.gc.setAdvanced(true);
e.gc.setAntialias(SWT.ON);
- if (orientation == SWT.HORIZONTAL) {
- drawHorizontalRangeSlider(e.gc);
- } else {
- drawVerticalRangeSlider(e.gc);
- }
-
- }
-
- /**
- * Draw the range slider (horizontal)
- *
- * @param gc graphic context
- */
- private void drawHorizontalRangeSlider(final GC gc) {
- drawBackgroundHorizontal(gc);
+ drawBackground(e.gc);
if (lowerHover || (selectedElement & LOWER) != 0) {
- coordUpper = drawHorizontalKnob(gc, upperValue, true);
- coordLower = drawHorizontalKnob(gc, lowerValue, false);
+ coordUpper = drawMarker(e.gc, upperValue, true);
+ coordLower = drawMarker(e.gc, lowerValue, false);
} else {
- coordLower = drawHorizontalKnob(gc, lowerValue, false);
- coordUpper = drawHorizontalKnob(gc, upperValue, true);
+ coordLower = drawMarker(e.gc, lowerValue, false);
+ coordUpper = drawMarker(e.gc, upperValue, true);
}
}
- /**
- * Draw the background
- *
- * @param gc graphic context
- */
- private void drawBackgroundHorizontal(final GC gc) {
+ private void drawBackground(final GC gc) {
final Rectangle clientArea = getClientArea();
-
gc.setBackground(getBackground());
- //gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLUE));//getBackground());
gc.fillRectangle(clientArea);
-
if (isEnabled()) {
gc.setForeground(getForeground());
} else {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
}
- gc.drawRoundRectangle(imgWidth, minHeight/3, clientArea.width - 2*imgWidth, clientArea.height - 2*minHeight/3, 3, 3);
+ gc.drawRoundRectangle(markerWidth, minHeight/3, clientArea.width - 2*markerWidth, clientArea.height - 2*minHeight/3, 3, 3);
- final float pixelSize = computePixelSizeForHorizontalSlider();
+ final float pixelSize = computePixelSizeForSlider();
final int startX = (int) (pixelSize * lowerValue);
final int endX = (int) (pixelSize * upperValue);
if (isEnabled()) {
@@ -656,44 +382,24 @@ public class RangeSlider extends Canvas {
} else {
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
}
- gc.fillRectangle(imgWidth+startX, minHeight/3, endX - startX, clientArea.height - 2*minHeight/3);
+ gc.fillRectangle(markerWidth+startX, minHeight/3, endX - startX, clientArea.height - 2*minHeight/3);
}
- /**
- * @return how many pixels corresponds to 1 point of value
- */
- private float computePixelSizeForHorizontalSlider() {
- return (getClientArea().width - 2.0f*imgWidth) / (maximum - minimum);
- }
-
- /**
- * Draws an horizontal knob
- *
- * @param gc graphic context
- * @param value corresponding value
- * @param upper if true
, draws the upper knob. If
- * false
, draws the lower knob
- * @return the coordinate of the upper left corner of the knob
- */
- private Point drawHorizontalKnob(final GC gc, final int value, final boolean upper) {
- final float pixelSize = computePixelSizeForHorizontalSlider();
+ private Point drawMarker(final GC gc, final int value, final boolean upper) {
+ final float pixelSize = computePixelSizeForSlider();
int x = (int) (pixelSize * value);
final int idx = upper?1:0;
Image image;
if (upper) {
if (upperHover) {
- image = dragInProgress || (selectedElement & UPPER) != 0 ? sliderDrag[idx] : sliderHover[idx];
- } else if ((selectedElement & UPPER) != 0 && !lowerHover) {
- image = hasFocus ? sliderSelected[idx] : sliderHover[idx];
+ image = (selectedElement & UPPER) != 0 ? sliderDrag[idx] : sliderHover[idx];
} else {
image = slider[idx];
}
} else {
if (lowerHover) {
- image = dragInProgress || (selectedElement & LOWER) != 0 ? sliderDrag[idx] : sliderHover[idx];
- } else if ((selectedElement & LOWER) != 0 && !upperHover) {
- image = hasFocus ? sliderSelected[idx] : sliderHover[idx];
+ image = (selectedElement & LOWER) != 0 ? sliderDrag[idx] : sliderHover[idx];
} else {
image = slider[idx];
}
@@ -710,120 +416,6 @@ public class RangeSlider extends Canvas {
return new Point(x, getClientArea().height / 2 - slider[idx].getBounds().height / 2);
}
- /**
- * Draw the range slider (vertical)
- *
- * @param gc graphic context
- */
- private void drawVerticalRangeSlider(final GC gc) {
- drawBackgroundVertical(gc);
- drawBarsVertical(gc);
- if (lowerHover || (selectedElement & LOWER) != 0) {
- coordUpper = drawVerticalKnob(gc, upperValue, true);
- coordLower = drawVerticalKnob(gc, lowerValue, false);
- } else {
- coordLower = drawVerticalKnob(gc, lowerValue, false);
- coordUpper = drawVerticalKnob(gc, upperValue, true);
- }
- }
-
- /**
- * Draws the background
- *
- * @param gc graphic context
- */
- private void drawBackgroundVertical(final GC gc) {
- final Rectangle clientArea = getClientArea();
- gc.setBackground(getBackground());
- gc.fillRectangle(clientArea);
-
- if (isEnabled()) {
- gc.setForeground(getForeground());
- } else {
- gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
- }
- gc.drawRoundRectangle(9, 9, clientArea.width - 20, clientArea.height - 20, 3, 3);
-
- final float pixelSize = computePixelSizeForVerticalSlider();
- final int startY = (int) (pixelSize * lowerValue);
- final int endY = (int) (pixelSize * upperValue);
- if (isEnabled()) {
- gc.setBackground(getForeground());
- } else {
- gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
- }
- gc.fillRectangle(9, 12 + startY, clientArea.width - 20, endY - startY - 6);
-
- }
-
- /**
- * @return how many pixels corresponds to 1 point of value
- */
- private float computePixelSizeForVerticalSlider() {
- return (getClientArea().height - 20f) / (maximum - minimum);
- }
-
- /**
- * Draws the bars
- *
- * @param gc graphic context
- */
- private void drawBarsVertical(final GC gc) {
- if (isEnabled()) {
- gc.setForeground(getForeground());
- } else {
- gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
- }
- }
-
- /**
- * Draws a vertical knob
- *
- * @param gc graphic context
- * @param value corresponding value
- * @param upper if true
, draws the upper knob. If
- * false
, draws the lower knob
- * @return the coordinate of the upper left corner of the knob
- */
- private Point drawVerticalKnob(final GC gc, final int value, final boolean upper) {
- final float pixelSize = computePixelSizeForVerticalSlider();
- final int y = (int) (pixelSize * value);
-
- Image image;
- if (upper) {
- if (upperHover) {
- image = dragInProgress || (selectedElement & UPPER) != 0 ? vSliderDrag : vSliderHover;
- } else if ((selectedElement & UPPER) != 0 && !lowerHover) {
- image = hasFocus ? vSliderSelected : vSliderHover;
- } else {
- image = vSlider;
- }
- } else {
- if (lowerHover) {
- image = dragInProgress || (selectedElement & LOWER) != 0 ? vSliderDrag : vSliderHover;
- } else if ((selectedElement & LOWER) != 0 && !upperHover) {
- image = hasFocus ? vSliderSelected : vSliderHover;
- } else {
- image = vSlider;
- }
- }
-
- if (isEnabled()) {
- gc.drawImage(image, getClientArea().width / 2 - 8, y + 4);
- } else {
- final Image temp = new Image(getDisplay(), image, SWT.IMAGE_DISABLE);
- gc.drawImage(temp, getClientArea().width / 2 - 8, y + 4);
- temp.dispose();
- }
- return new Point(getClientArea().width / 2 - 8, y + 4);
- }
-
- /**
- * move the cursor location by the input delta values.
- *
- * @param xDelta
- * @param yDelta
- */
private void moveCursorPosition(int xDelta, int yDelta) {
final Point cursorPosition = getDisplay().getCursorLocation();
cursorPosition.x += xDelta;
@@ -831,162 +423,74 @@ public class RangeSlider extends Canvas {
getDisplay().setCursorLocation(cursorPosition);
}
- /**
- * Code executed when a key is typed
- *
- * @param event event
- */
private void handleKeyDown(final Event event) {
- // TODO consider API for setting accelerator values
int accelerator = (event.stateMask & SWT.SHIFT) != 0 ? 10 : (event.stateMask & SWT.CTRL) != 0 ? 2 : 1;
- if (dragInProgress) {
+ if (selectedElement != NONE) {
switch (event.keyCode) {
- case SWT.ESC:
- startDragPoint = null;
- upperValue = startDragUpperValue;
- lowerValue = startDragLowerValue;
- validateNewValues(event);
- dragInProgress = false;
- if (!isOn) {
- redraw();
- }
- event.doit = false;
- break;
- case SWT.ARROW_UP:
- accelerator = orientation == SWT.HORIZONTAL ? -accelerator : accelerator;
- case SWT.ARROW_LEFT:
- if (orientation == SWT.VERTICAL) {
- moveCursorPosition(0, -accelerator);
- } else {
- moveCursorPosition(-accelerator, 0);
- }
- event.doit = false;
- break;
- case SWT.ARROW_DOWN:
- accelerator = orientation == SWT.HORIZONTAL ? -accelerator : accelerator;
- case SWT.ARROW_RIGHT:
- if (orientation == SWT.VERTICAL) {
- moveCursorPosition(0, accelerator);
- } else {
- moveCursorPosition(accelerator, 0);
- }
- event.doit = false;
- break;
+ case SWT.ESC:
+ startDragPoint = null;
+ upperValue = startDragUpperValue;
+ lowerValue = startDragLowerValue;
+ validateNewValues(event);
+ selectedElement = NONE;
+ if (!isOn) {
+ redraw();
+ }
+ event.doit = false;
+ break;
+ case SWT.ARROW_UP:
+ accelerator = -accelerator;
+ case SWT.ARROW_LEFT:
+ moveCursorPosition(-accelerator, 0);
+ event.doit = false;
+ break;
+ case SWT.ARROW_DOWN:
+ accelerator = -accelerator;
+ case SWT.ARROW_RIGHT:
+ moveCursorPosition(accelerator, 0);
+ event.doit = false;
+ break;
}
return;
}
previousLowerValue = lowerValue;
previousUpperValue = upperValue;
- if (selectedElement == NONE) {
- selectedElement = LOWER;
- }
switch (event.keyCode) {
- case SWT.HOME:
- if (selectedElement == BOTH) {
- if ((event.stateMask & SWT.SHIFT) != 0) {
- lowerValue = maximum - (upperValue - lowerValue);
- upperValue = maximum;
- } else {
- upperValue = minimum + upperValue - lowerValue;
- lowerValue = minimum;
- }
- } else if ((selectedElement & UPPER) != 0) {
- upperValue = maximum;
- } else {
- lowerValue = minimum;
- }
- break;
- case SWT.END:
- if (selectedElement == BOTH) {
- if ((event.stateMask & SWT.SHIFT) != 0) {
- upperValue = minimum + upperValue - lowerValue;
- lowerValue = minimum;
- } else {
- lowerValue = maximum - (upperValue - lowerValue);
- upperValue = maximum;
- }
- } else if ((selectedElement & UPPER) != 0) {
- upperValue = lowerValue;
- } else {
- lowerValue = upperValue;
- }
- break;
- case SWT.PAGE_UP:
- accelerator = orientation == SWT.HORIZONTAL ? -accelerator : accelerator;
- if (selectedElement == BOTH) {
- translateValues(pageIncrement * -accelerator);
- } else if ((selectedElement & UPPER) != 0) {
- upperValue -= pageIncrement * accelerator;
- } else {
- lowerValue -= pageIncrement * accelerator;
- }
- break;
- case SWT.PAGE_DOWN:
- accelerator = orientation == SWT.HORIZONTAL ? -accelerator : accelerator;
- if (selectedElement == BOTH) {
- translateValues(pageIncrement * accelerator);
- } else if ((selectedElement & UPPER) != 0) {
- upperValue += pageIncrement * accelerator;
- } else {
- lowerValue += pageIncrement * accelerator;
- }
- break;
- case SWT.ARROW_DOWN:
- accelerator = orientation == SWT.HORIZONTAL ? -accelerator : accelerator;
- case SWT.ARROW_RIGHT:
- if (selectedElement == BOTH) {
- translateValues(accelerator * increment);
- } else if ((selectedElement & UPPER) != 0) {
- upperValue += accelerator * increment;
- } else {
- lowerValue += accelerator * increment;
- }
- break;
- case SWT.ARROW_UP:
- accelerator = orientation == SWT.HORIZONTAL ? -accelerator : accelerator;
- case SWT.ARROW_LEFT:
- if (selectedElement == BOTH) {
- translateValues(-accelerator * increment);
- } else if ((selectedElement & UPPER) != 0) {
- upperValue -= accelerator * increment;
- } else {
- lowerValue -= accelerator * increment;
- }
- break;
- case SWT.TAB:
- final boolean next = (event.stateMask & SWT.SHIFT) == 0;
- if (next && (selectedElement & LOWER) != 0) {
- selectedElement = isFullSelection && selectedElement == LOWER ? BOTH : UPPER;
- redraw();
- } else if (!next && (selectedElement & UPPER) != 0) {
- selectedElement = isFullSelection && selectedElement == UPPER ? BOTH : LOWER;
- redraw();
- } else {
- traverse(next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS);
- }
- return;
+ case SWT.HOME:
+ if ((event.stateMask & (SWT.SHIFT| SWT.CTRL)) == 0) {
+ upperValue = minimum + upperValue - lowerValue;
+ lowerValue = minimum;
+ }
+ break;
+ case SWT.END:
+ if ((event.stateMask & (SWT.SHIFT| SWT.CTRL)) == 0) {
+ lowerValue = maximum - (upperValue - lowerValue);
+ upperValue = maximum;
+ }
+ break;
+ case SWT.PAGE_UP:
+ translateValues(-accelerator * pageIncrement);
+ break;
+ case SWT.PAGE_DOWN:
+ translateValues( accelerator * pageIncrement);
+ break;
+ case SWT.ARROW_DOWN:
+ case SWT.ARROW_RIGHT:
+ translateValues( accelerator * increment);
+ break;
+ case SWT.ARROW_UP:
+ case SWT.ARROW_LEFT:
+ translateValues(-accelerator * increment);
+ break;
}
if (previousLowerValue != lowerValue || previousUpperValue != upperValue) {
- if (selectedElement == BOTH) {
- checkLowerValue();
- checkUpperValue();
- } else if ((selectedElement & UPPER) != 0) {
- checkUpperValue();
- } else {
- checkLowerValue();
- }
+ checkLowerValue();
+ checkUpperValue();
validateNewValues(event);
}
}
- /**
- * translate both the upper and lower values by the input amount. The updated
- * values are constrained to be within the minimum and maximum. The difference
- * between upper and lower values is retained.
- *
- * @param amount
- */
private void translateValues(int amount) {
int newLower = lowerValue + amount;
int newUpper = upperValue + amount;
@@ -1001,336 +505,64 @@ public class RangeSlider extends Canvas {
lowerValue = newLower;
}
- /**
- * Adds the listener to the collection of listeners who will be notified when
- * the user changes the receiver's value, by sending it one of the messages
- * defined in the SelectionListener
interface.
- *
- * widgetSelected
is called when the user changes the receiver's
- * value. widgetDefaultSelected
is not called.
- *
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException
- *
- * - ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- */
public void addSelectionListener(final SelectionListener listener) {
checkWidget();
SelectionListenerUtil.addSelectionListener(this, listener);
}
- /**
- * @see org.eclipse.swt.widgets.Composite#computeSize(int, int, boolean)
- */
- @Override
- public Point computeSize(final int wHint, final int hHint, final boolean changed) {
- final int width, height;
- checkWidget();
- if (orientation == SWT.HORIZONTAL) {
- if (wHint < 100) {
- width = 100;
- } else {
- width = wHint;
- }
-
- if (hHint < minHeight) {
- height = minHeight;
- } else {
- height = hHint;
- }
- } else {
- if (wHint < minWidth) {
- width = minWidth;
- } else {
- width = wHint;
- }
-
- if (hHint < 100) {
- height = 100;
- } else {
- height = hHint;
- }
- }
-
- return new Point(width, height);
- }
-
- /**
- * Returns the amount that the selected receiver's value will be modified by
- * when the up/down (or right/left) arrows are pressed.
- *
- * @return the increment
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public int getIncrement() {
- checkWidget();
- return increment;
- }
-
- /**
- * Returns the 'lower selection', which is the lower receiver's position.
- *
- * @return the selection
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public int getLowerValue() {
- checkWidget();
- return lowerValue;
- }
-
- /**
- * Returns the maximum value which the receiver will allow.
- *
- * @return the maximum
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public int getMaximum() {
- checkWidget();
- return maximum;
- }
-
- /**
- * Returns the minimum value which the receiver will allow.
- *
- * @return the minimum
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public int getMinimum() {
- checkWidget();
- return minimum;
- }
-
- /**
- * Returns the amount that the selected receiver's value will be modified by
- * when the page increment/decrement areas are selected.
- *
- * @return the page increment
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public int getPageIncrement() {
- checkWidget();
- return pageIncrement;
- }
-
- /**
- * Returns the 'selection', which is an array where the first element is the
- * lower selection, and the second element is the upper selection
- *
- * @return the selection
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public int[] getSelection() {
- checkWidget();
- final int[] selection = new int[2];
- selection[0] = lowerValue;
- selection[1] = upperValue;
- return selection;
- }
-
- /**
- * Returns the 'upper selection', which is the upper receiver's position.
- *
- * @return the selection
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public int getUpperValue() {
- checkWidget();
- return upperValue;
- }
-
- /**
- * Removes the listener from the collection of listeners who will be notified
- * when the user changes the receiver's value.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException
- *
- * - ERROR_NULL_ARGUMENT - if the listener is null
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
public void removeSelectionListener(final SelectionListener listener) {
checkWidget();
SelectionListenerUtil.removeSelectionListener(this, listener);
}
- /**
- * Sets the amount that the selected receiver's value will be modified by when
- * the up/down (or right/left) arrows are pressed to the argument, which must be
- * at least one.
- *
- * @param increment the new increment (must be greater than zero)
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setIncrement(final int increment) {
+ @Override
+ public Point computeSize(final int wHint, final int hHint, final boolean changed) {
checkWidget();
- this.increment = increment;
- redraw();
+ final int width = Math.max(2*markerWidth+100, wHint);
+ final int height = Math.max(minHeight, hHint);
+ return new Point(width, height);
}
- /**
- * Sets the 'lower selection', which is the receiver's lower value, to the input
- * argument which must be less than or equal to the current 'upper selection'
- * and greater or equal to the minimum. If either condition fails, no action is
- * taken.
- *
- * @param value the new lower selection
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- * @see #getUpperValue()
- * @see #getMinimum()
- * @see #setSelection(int, int)
- */
- public void setLowerValue(final int value) {
- setSelection(value, upperValue);
+ public int[] getSelection() {
+ checkWidget();
+ return new int[] {lowerValue, upperValue};
}
- /**
- * Sets the maximum value that the receiver will allow. This new value will be
- * ignored if it is not greater than the receiver's current minimum value. If
- * the new maximum is applied then the receiver's selection value will be
- * adjusted if necessary to fall within its new range.
- *
- * @param value the new maximum, which must be greater than the current minimum
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- * @see #setExtrema(int, int)
- */
+ public int getIncrement() {
+ checkWidget();
+ return increment;
+ }
+
+ public int getMaximum() {
+ checkWidget();
+ return maximum;
+ }
+
+ public int getMinimum() {
+ checkWidget();
+ return minimum;
+ }
+
+ public int getPageIncrement() {
+ checkWidget();
+ return pageIncrement;
+ }
+
+// public void setIncrement(final int increment) {
+// checkWidget();
+// this.increment = increment;
+// redraw();
+// }
+
public void setMaximum(final int value) {
- setExtrema(minimum, value);
+ setLimits(minimum, value);
}
- /**
- * Sets the minimum value that the receiver will allow. This new value will be
- * ignored if it is negative or is not less than the receiver's current maximum
- * value. If the new minimum is applied then the receiver's selection value will
- * be adjusted if necessary to fall within its new range.
- *
- * @param value the new minimum, which must be nonnegative and less than the
- * current maximum
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- * @see #setExtrema(int, int)
- */
public void setMinimum(final int value) {
- setExtrema(value, maximum);
+ setLimits(value, maximum);
}
- /**
- * Sets the minimum and maximum values that the receiver will allow. The new
- * values will be ignored if either are negative or the min value is not less
- * than the max. The receiver's selection values will be adjusted if necessary
- * to fall within the new range.
- *
- * @param min the new minimum, which must be nonnegative and less than the max
- * @param max the new maximum, which must be greater than the min
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setExtrema(final int min, final int max) {
+ public void setLimits(final int min, final int max) {
checkWidget();
if (min >= 0 && min < max && (min != minimum || max != maximum)) {
minimum = min;
@@ -1349,73 +581,41 @@ public class RangeSlider extends Canvas {
}
}
- /**
- * Sets the amount that the receiver's value will be modified by when the page
- * increment/decrement areas are selected to the argument, which must be at
- * least one.
- *
- * @param pageIncrement the page increment (must be greater than zero)
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setPageIncrement(final int pageIncrement) {
+ public int getUpperValue() {
checkWidget();
- this.pageIncrement = pageIncrement;
- redraw();
+ return upperValue;
}
- /**
- * Sets the 'selection', which is the receiver's value. The lower value must be
- * less than or equal to the upper value. Additionally, both values must be
- * inclusively between the slider minimum and maximum. If either condition
- * fails, no action is taken.
- *
- * @param value the new selection (first value is lower value, second value is
- * upper value)
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- */
- public void setSelection(final int[] values) {
+ public void setUpperValue(final int value) {
+ setValues(lowerValue, value);
+ }
+
+ public int getLowerValue() {
+ checkWidget();
+ return lowerValue;
+ }
+
+ public void setLowerValue(final int value) {
+ setValues(value, upperValue);
+ }
+
+// public void setPageIncrement(final int pageIncrement) {
+// checkWidget();
+// this.pageIncrement = pageIncrement;
+// redraw();
+// }
+
+ public void setValues(final int[] values) {
if (values.length == 2) {
- setSelection(values[0], values[1]);
+ setValues(values[0], values[1]);
}
}
- /**
- * Sets the 'selection', which is the receiver's value. The lower value must be
- * less than or equal to the upper value. Additionally, both values must be
- * inclusively between the slider minimum and maximum. If either condition
- * fails, no action is taken.
- *
- * @param lowerValue the new lower selection
- * @param upperValue the new upper selection
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- * @see #getMinimum()
- * @see #getMaximum()
- */
- public void setSelection(final int lowerValue, final int upperValue) {
- setSelection(lowerValue, upperValue, false);
+ public void setValues(final int lowerValue, final int upperValue) {
+ setValues(lowerValue, upperValue, false);
}
- public void setSelection(final int lowerValue, final int upperValue, boolean update) {
+
+ public void setValues(final int lowerValue, final int upperValue, boolean update) {
checkWidget();
if (lowerValue <= upperValue && lowerValue >= minimum && upperValue <= maximum && (this.lowerValue != lowerValue || this.upperValue != upperValue)) {
this.lowerValue = lowerValue;
@@ -1429,27 +629,4 @@ public class RangeSlider extends Canvas {
redraw();
}
}
-
- /**
- * Sets the 'upper selection', which is the upper receiver's value, to the input
- * argument which must be greater than or equal to the current 'lower selection'
- * and less or equal to the maximum. If either condition fails, no action is
- * taken.
- *
- * @param value the new upper selection
- *
- * @exception SWTException
- *
- * - ERROR_WIDGET_DISPOSED - if the receiver has been
- * disposed
- * - ERROR_THREAD_INVALID_ACCESS - if not called from the
- * thread that created the receiver
- *
- * @see #getLowerValue()
- * @see #getMaximum()
- * @see #setSelection(int, int)
- */
- public void setUpperValue(final int value) {
- setSelection(lowerValue, value);
- }
}
\ No newline at end of file
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/TimeZoomScrollbar.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/TimeZoomScrollbar.java
index ecca946..3bac523 100644
--- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/TimeZoomScrollbar.java
+++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/TimeZoomScrollbar.java
@@ -64,18 +64,18 @@ public class TimeZoomScrollbar extends Composite {
@Override
public void widgetSelected(SelectionEvent e) {
int[] value = timeSlider.getSelection();
- int diff = value[1]-value[0];
- int newLow = Math.max(0, value[0]-Math.max(1, diff/10));
- timeSlider.setSelection(newLow, newLow+diff, true);
+ int incr=timeSlider.getIncrement();
+ int lower = Math.max(timeSlider.getMinimum(), value[0]-incr);
+ timeSlider.setValues(lower, lower + (value[1]-value[0]), true);
}
});
rightButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int[] value = timeSlider.getSelection();
- int diff = value[1]-value[0];
- int newHigh = Math.min(timeSlider.getMaximum(), value[1] + diff/10);
- timeSlider.setSelection(newHigh-diff, newHigh, true);
+ int incr=timeSlider.getIncrement();
+ int upper = Math.min(timeSlider.getMaximum(), value[1]+incr);
+ timeSlider.setValues(upper - (value[1]-value[0]), upper, true);
}
});
@@ -104,7 +104,7 @@ public class TimeZoomScrollbar extends Composite {
}
public void setSelection(int[] sel) {
assert(sel.length==2);
- timeSlider.setSelection(sel[0], sel[1]);
+ timeSlider.setValues(sel[0], sel[1]);
}
public int[] getSelection() {
return timeSlider.getSelection();
@@ -112,12 +112,6 @@ public class TimeZoomScrollbar extends Composite {
public void addSelectionListener(SelectionListener selectionListener) {
timeSlider.addSelectionListener(selectionListener);
}
- public void setIncrement(int value) {
- timeSlider.setIncrement(value);
- }
- public void setPageIncrement(int value) {
- timeSlider.setPageIncrement(value);
- }
public void setMinimum(int value) {
timeSlider.setMinimum(value);
}
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/h-slider-drag.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/h-slider-drag.png
deleted file mode 100644
index 2011d9b40b5cafb987a58f3af01a9333f3905fce..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1057
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
AjQ{`u
delta 331
zcmV-R0kr
z)b|qM^g=!s3mJ_@PkW(oaxU-lxlE^184ib&T_}+tXsxj!(0}Xou0u&+{$d*J+F)j$@L|k%jjdW3~osEsaKll_ASm?o=3K
zXti1^Kr4lE?nIBFEX#F8mXZAcHd&VC>XRzV_*`#o^v*e|sv;qZNZV}=MeyF^y(ff#
dbB<=S$u~>H`|M})O$`75002ovPDHLkV1g8Xo0k9p
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_bl.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_bl.png
deleted file mode 100644
index 558f9bd8c979be89c1625127ce3c88847c45428f..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 386
zcmV-|0e$|7P)4f26vgrXz4OLqBLrMTNU@MMm93-=1QJ3NY^*IqAR(}wsQ5XoB?JU3KZC7>ogW|s
z=IuD^%;ep7pG7tSC7$LqzjMekvu`|J<3CZEtyf>?uRj9yy}~!2mLK1Lmihe6`F%)B
zE{vnHzyIpx+1cAq|02bqX$HCuwzr?ZI6Zy$*OTIf*d$^!77Jl(Ywz&ns8srfDiRHg*q=k3W0{>Oh7?bbcG8R4{|<>x#99J9|e*`X%6nc2QVbAtfOtNJ%hz
zz;ya-H{j4lq0352U?wXlOeRVwE_AKZW?e0XWP&AS7?gm+uePG~KuSW+f|+7T==&Au
zmx0a#W`boUo09$Zp+Mi&EInYRxZeOT$}m<0Tp0VBKG$Tw0bZ0+lyRsCRGBBUOD3fv
gyWm;w`qA`?KQM~Ctzq%VNdN!<07*qoM6N<$f*$CpmjD0&
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_bl_lt.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_bl_lt.png
deleted file mode 100644
index e37e735e502b7acb6e1d625a46287de40c4b4d20..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 366
zcmV-!0g?WRP)j!H;O&wemz9dZ^@hMa_yU~KfAPw6
M07*qoM6N<$f{SaUu>b%7
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_hover.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_hover.png
new file mode 100644
index 0000000000000000000000000000000000000000..8b3696e2d53ae3c289fb1fd31d71daeb750c2052
GIT binary patch
literal 326
zcmV-M0lEH(P)PHzF`^ZDHXAclaNp{l4VB62{z
zBA1oDzdR9hMpeoCJ{%4ijYjkUM1&9mAq1RrIOnMAnxZI<8A3{^DltZK&cqn`3F&q_
z!hV=iBF6X!I7i%vJe*1?9f61-UH5D0y+4A_wq>XKv+&*{BHzG#iG~f_AQAk{u*_uvWL=5?n#b6ay&&HjeY-yYF3#
ziNk>L!r>O@I~UHyo1wgOcFaE$nc->tmOefKM+b>;d8OMd)5T)(d=Ls3BmLOzbhFv$
zd_I5q1BLUEZnI3YEYtORt!bLRb|H%@bzS3uIF6akW_PM;mdoV>;4BJtRUtqK0b>l)
z>GW1r&1$u}x4OR|fcL)DWHPw{B8w_jRpC_e-V;J-q49WpZBZ!85&=Y{HAMsw!Gcni
zCEu!u2qA>lG{!V7ilS(NZaPU4ECGt5pzb7p6-7~V;VaLnLclqPh_t)c>oq|BnN#@2
r=xQ(+UopbyE9pCRGGRBm-00000NkvXXu0mjf^cIxB
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_pressed.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/marker_r_pressed.png
new file mode 100644
index 0000000000000000000000000000000000000000..e602b5660e84fd1b4a3d095fad9fbd405d3d716c
GIT binary patch
literal 349
zcmV-j0iyniP)dR^>1onXQy|fTaEq)wd{f|n
zP{>HreVTKI?_lut&RvIpCJY8y>+SjJ1&FVTdN}swcI&6p>FZTg566C56n?+oUq|(D
z?C(b-Kby^bS(blL1mJo-7K;VWIVO`y4ltk3AA!#ZAaRawYgsOrq-lDAB7p4XmfC2H
zF|1ZAoO2XKkpp1_&`A>lYca+kB5XDrk|ZI|^M_-HEF-iQt@UYlyB+<0|5!40jzAwH
zwALu4P)eP@NSz~UBH}p47;_1-ZkJFgMC249B4=RRZKUZSA}FQMT5~uYnhRM*+
literal 0
HcmV?d00001
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-drag.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-drag.png
deleted file mode 100644
index 2d88c1afbd14dea934b22941e9beda11fe12abb4..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1085
zcmeAS@N?(olHy`uVBq!ia0vp^AhsX}GmyOe_w02brB~t_QQ};bnpl#VpQjL#nVZT`
zoS3VpU}&U}mtUr*U}Ruus9#HaCxutg6yO
z_60y8&H|6fVg?4jLmgEw{G3~`Sa(Km+wlZtf^hJ$2Fy9;`BKUOZT0B{MI?S`q|r$l`}UsF57?c>4%ub
zC!G?jrp;aW?Af#C#k*Tp9J>7cQ|g*a0SnLg=C)qFdQ~T>``W87S(|P~t-5;t{P`Pi
zz9(z`#ezr6nbcf-AJ?|%H<{pkD0pMQ@(|M}(Dze{g^ef$0I
z&d1-EE?xTZ=ik#We;zz|5Z$`;%&jNC{{9Q8oA>S8w@t^c0=+W|Mniz|5C~6wZUQug
zu_VYZn8D%MjWi&q($mE;q~ezBvD-pU0TK-t_h0Jd3lYvTtG?hd$z;~rW54ag_g%X>
z>7K@nxFaR{w)Tp;6L8^A*PJx*6cf*h7c{O#9lv;C
zv3$#NgAeDGX0Lty)~38(VB*a?k(SxFC;b=qzC9~QvRC~L`~4fjKHbZ!3_#boFyt
I=akR{064h$AOHXW
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-hover.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-hover.png
deleted file mode 100644
index e8ac5adb2fbfc7ad17e51e23169058aad73f237b..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1083
zcmeAS@N?(olHy`uVBq!ia0vp^AhsX}GmyOe_w02brB~t_QQ};bnpl#VpQjL#nVZT`
zoS3VpU}&U}mtUr*U}Ruus9#HaCxutoSRl
zFa@9xXMsm#F#`kNArNL1)$nQn3bLd-`Z_W&Z0zU$lgP@zz|0Wf6XN>+|Nj^7K6kG@
zx_H%wTeoig{Q2|gn@@F14^7^E-LGu&u)wjP}AAI*N
zo;YK{vS-hp^=!E~bN|iP-~aA-^mE<4A7OQ~uU@@sQ@`=e_rJRy|JwB6=lS#J-~RZw
z?a}XdKmP4{^5^W?vtNJzyYc?dx8MJ6fBf_P&%b-0{`~m!@6qQ!Prv;A`RCvBuYWIH
zy7cq!zn9oVw+6e2tfeOw;3CY_U_V
zu!Pw!{o&7f9C{4ftP2I)uebfYSNN8fJA3Q1f0MF=mMru=Zv*n1r>mdKI;Vst00{B;
A;s5{u
diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-normal.png b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/slider/slider-normal.png
deleted file mode 100644
index 4c5098ca95cb10882ccfe36902fac9a8de247103..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1072
zcmeAS@N?(olHy`uVBq!ia0vp^AhsX}GmyOe_w02brB~t_QQ};bnpl#VpQjL#nVZT`
zoS3VpU}&U}mtUr*U}Ruus9PU}#{lVd@EapicG@PhVH|+uS@tvK;Al
z(N}>&oCO|{#S9F5hd`K7RKu$QD9DoT=wtDsIZQHipym|A=l`EyCrB|C>lyjvNJ}AwbU%
zIJY9m7HA)1NswPKgTu2MX+Tbnr;B4q#Vyri(R@t?BCH3L!veY@RDwJ+4><<~^ZbsV
zH|O?GsW%q`?=ysN;i+?XWdL(wZ7v`&G9Yemb}k??FflP8F*!OgHaamgAS*C2FfbqQ{ks4F00(qQ
zO+^RW3k(tqC(w7(TL1t632;bRa{vGi!vFvd!vV){sAK>D00d`2O+f$vv5yP`8-0VU3{kYKMw+mZv00001bW%=J06^y0W&i*HY)M2x
zRCwAg#?cl+KmbM2TP7hij3h~tM*jZ?bFB8$*5WPvBKi4?*-Li%V6tn+H%2 state) {
Integer waves = state.containsKey(SHOWN_WAVEFORM+"S") ? Integer.parseInt(state.get(SHOWN_WAVEFORM + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$
List trackEntries = new LinkedList<>();
+ List selectedTrackEntries = new LinkedList<>();
for (int i = 0; i < waves; i++) {
IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
if (waveform != null) {
TrackEntry trackEntry = waveformPane.addWaveform(waveform, -1);
//check if t is selected
- boolean isSelected = Boolean.parseBoolean(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED));
- if(isSelected) {
- trackEntry.selected = true;
- } else {
- trackEntry.selected = false;
- }
trackEntries.add(trackEntry);
+ if(Boolean.parseBoolean(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED)))
+ selectedTrackEntries.add(trackEntry);
String v = state.get(SHOWN_WAVEFORM + i + VALUE_DISPLAY);
if(v!=null)
trackEntry.valueDisplay=ValueDisplay.valueOf(v);
@@ -856,6 +853,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
} catch (NumberFormatException e) {
}
}
+ ISelection sel = new StructuredSelection(selectedTrackEntries);
+ waveformPane.setSelection(sel);
updateAll();
}