Disable function when pinned
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 27 Oct 2016 19:44:02 +0000 (15:44 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 11 Nov 2016 15:36:07 +0000 (10:36 -0500)
The following actions can now be enabled/disabled on demand:

Previous/Next event
Grab and pan navigation
Zoom on selection
Horizontal zoom
Horizontal scroll
Time range selection

Those are disabled when pinned since they either change the visible time range
or the current time stamp selection.

On pin change the selection limit bar to grey.

Row oriented/vertical actions are still available (e.g up/down/home key,
vertical zoom, vertical scrolling).

Change-Id: Ibf941d068fb173818c500506cba43c1a13af90f7
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java

index f4e0ec7f5ebd397bef4c674be0ae1950c2643cf4..b3e544e0c4dffd756982a51ef329973359bc79d3 100644 (file)
@@ -145,6 +145,12 @@ public class TimeGraphColorScheme {
     public static final int TI_INTERRUPT = RED;
     public static final int TI_WAIT_EXCEEDED = BLUE;
 
+    /**
+     * Color for the selection line when in a pinned state.
+     * @since 2.2
+     */
+    public static final int SELECTED_TIME_PINNED = DARK_GRAY;
+
     interface IColorProvider {
         Color get();
     }
index 8e062d5a58852c951c226f772d411cf1c2f97bbd..d786315adfb79ac788ccf253270ce353b2622c0b 100644 (file)
@@ -192,6 +192,18 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private int fBorderWidth = 0;
     private int fHeaderHeight = 0;
 
+    /** Feature toggle switch */
+    private boolean fPrevEventEnabled = true;
+    private boolean fNextEventEnabled = true;
+    private boolean fGrabAndPanEnabled = true;
+    private boolean fSelectionZoomEnabled = true;
+    private boolean fHorizontalZoomEnabled = true;
+    private boolean fHorizontalScrollEnabled = true;
+    private boolean fTimeRangeSelectionEnabled = true;
+
+    /** Toggle switch for pinned behavior */
+    private boolean fUsePinnedSelectionColor = false;
+
     /**
      * Standard constructor
      *
@@ -996,6 +1008,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @since 1.0
      */
     public void selectNextEvent(boolean extend) {
+        if (!fNextEventEnabled) {
+            return;
+        }
         selectEvent(1, extend);
         // Notify if visible time window has been adjusted
         fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
@@ -1009,6 +1024,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @since 1.0
      */
     public void selectPrevEvent(boolean extend) {
+        if (!fPrevEventEnabled) {
+            return;
+        }
         selectEvent(-1, extend);
         // Notify if visible time window has been adjusted
         fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
@@ -1035,6 +1053,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *            true to scroll left, false to scroll right
      */
     public void horizontalScroll(boolean left) {
+        if (fHorizontalScrollEnabled) {
+            return;
+        }
         long time0 = fTimeProvider.getTime0();
         long time1 = fTimeProvider.getTime1();
         long timeMin = fTimeProvider.getMinTime();
@@ -1060,6 +1081,10 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @param zoomIn true to zoom in, false to zoom out
      */
     public void zoom(boolean zoomIn) {
+        if (!fHorizontalZoomEnabled) {
+            return;
+        }
+
         int globalX = getDisplay().getCursorLocation().x;
         Point p = toControl(globalX, 0);
         int nameSpace = fTimeProvider.getNameSpace();
@@ -1679,7 +1704,14 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
         // draw selection lines
         if (fDragState != DRAG_SELECTION) {
-            gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
+            int color = TimeGraphColorScheme.SELECTED_TIME;
+
+            if (fUsePinnedSelectionColor) {
+                color = TimeGraphColorScheme.SELECTED_TIME_PINNED;
+            }
+
+            gc.setForeground(getColorScheme().getColor(color));
+
             if (x0 >= nameSpace && x0 < bounds.x + bounds.width) {
                 gc.drawLine(x0, bounds.y, x0, bounds.y + bounds.height);
             }
@@ -2731,6 +2763,12 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 selectItem(idx, false); // clear selection
                 fireSelectionChanged();
             }
+
+            if (!fTimeRangeSelectionEnabled) {
+                return;
+            }
+
+            /* Time range Selection */
             long hitTime = getTimeAtX(e.x);
             if (hitTime >= 0) {
                 setCapture(true);
@@ -2774,7 +2812,8 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 updateCursor(e.x, e.stateMask);
                 fTimeGraphScale.setDragRange(fDragX0, fDragX);
             }
-        } else if (2 == e.button || (1 == e.button && (e.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL)) {
+
+        } else if ((2 == e.button || (1 == e.button && (e.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL)) && fGrabAndPanEnabled) {
             long hitTime = getTimeAtX(e.x);
             if (hitTime > 0) {
                 setCapture(true);
@@ -2786,7 +2825,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 fTime1bak = fTimeProvider.getTime1();
                 updateCursor(e.x, e.stateMask);
             }
-        } else if (3 == e.button) {
+        } else if (3 == e.button && fSelectionZoomEnabled) {
             if (e.x >= fTimeProvider.getNameSpace()) {
                 setCapture(true);
                 fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), getSize().x - RIGHT_MARGIN);
@@ -3456,4 +3495,28 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private boolean isInDragZoomMargin() {
         return (Math.abs(fDragX - fDragX0) < DRAG_MARGIN);
     }
+
+    /**
+     * Set the pin state
+     *
+     * @param pined
+     *            The pin state
+     * @since 2.2
+     */
+    @Override
+    public synchronized void setPinned(boolean pined) {
+        super.setPinned(pined);
+
+        fUsePinnedSelectionColor = pined;
+
+        boolean enabled = !pined;
+
+        fPrevEventEnabled = enabled;
+        fNextEventEnabled = enabled;
+        fGrabAndPanEnabled = enabled;
+        fSelectionZoomEnabled = enabled;
+        fHorizontalZoomEnabled = enabled;
+        fHorizontalScrollEnabled = enabled;
+        fTimeRangeSelectionEnabled = enabled;
+    }
 }
This page took 0.027938 seconds and 5 git commands to generate.