tmf: Add lower bound on vertical zoom adjustment
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 19 Jan 2017 16:30:32 +0000 (11:30 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Wed, 25 Jan 2017 17:42:50 +0000 (12:42 -0500)
This prevents to zoom-out further when all items have the minimum
height, so that subsequent zoom-in has an immediate effect.

Change-Id: I2c8d2707862a9b7a45390b6d36b5897046e0b545
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/89129
Reviewed-by: Hudson CI
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java

index 59ee111f75e5eebacf888b7aa5cf51c8165d5ae2..1696f658b88de3c2c555a1cfae9b0748e8f7afe4 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2007, 2016 Intel Corporation and others
+ * Copyright (c) 2007, 2017 Intel Corporation and others
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -164,6 +164,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private boolean fMouseOverSplitLine = false;
     private int fGlobalItemHeight = CUSTOM_ITEM_HEIGHT;
     private int fHeightAdjustment = 0;
+    private int fMaxItemHeight = 0;
     private Map<Integer, Font> fFonts = new HashMap<>();
     private boolean fBlendSubPixelEvents = false;
     private int fMinimumItemWidth = 0;
@@ -1243,6 +1244,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
             fHeightAdjustment++;
         } else {
             fHeightAdjustment--;
+            fHeightAdjustment = Math.max(fHeightAdjustment, 1 - fMaxItemHeight);
         }
         fItemData.refreshData();
         redraw();
@@ -3371,6 +3373,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
         public void refreshData() {
             ITimeGraphEntry selection = getSelectedTrace();
             Map<ITimeGraphEntry, Item> itemMap = new LinkedHashMap<>();
+            fMaxItemHeight = 0;
             for (int i = 0; i < fRootEntries.length; i++) {
                 ITimeGraphEntry entry = fRootEntries[i];
                 refreshData(itemMap, null, 0, entry);
@@ -3398,6 +3401,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
             } else {
                 item.fItemHeight = fGlobalItemHeight;
             }
+            fMaxItemHeight = Math.max(fMaxItemHeight, item.fItemHeight);
             item.fItemHeight = Math.max(1, item.fItemHeight + fHeightAdjustment);
             itemMap.put(entry, item);
             if (entry.hasChildren()) {
This page took 0.026443 seconds and 5 git commands to generate.