aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.gldebugger
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-08-16 10:02:13 -0700
committerSiva Velusamy <vsiva@google.com>2012-08-16 10:02:13 -0700
commit09fb93ea18a77f0db755cb15f54294ac29f21321 (patch)
tree4a0edd2068ea740a71002b68c3f5fb5dcce9235e /eclipse/plugins/com.android.ide.eclipse.gldebugger
parenta92f979128de0e9e76e41b6a52357156377d9b43 (diff)
downloadsdk-09fb93ea18a77f0db755cb15f54294ac29f21321.zip
sdk-09fb93ea18a77f0db755cb15f54294ac29f21321.tar.gz
sdk-09fb93ea18a77f0db755cb15f54294ac29f21321.tar.bz2
gltrace: Improve font width detection.
Set a floor value for font width when used to determine how wide widgets should be. Change-Id: I3b7f1e75051032e9e234c92360903c161d233832
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.gldebugger')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/SwtUtils.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java2
2 files changed, 7 insertions, 3 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/SwtUtils.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/SwtUtils.java
index 750d36a..a7c960d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/SwtUtils.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/SwtUtils.java
@@ -20,10 +20,14 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Control;
public class SwtUtils {
- public static int getFontWidth(Control c) {
+ /** Minimum Character width in pixels. */
+ private static final int MIN_CHAR_WIDTH = 10;
+
+ /** Returns the font width if it is greater than {@link #MIN_CHAR_WIDTH}. */
+ public static int getApproximateFontWidth(Control c) {
GC gc = new GC(c);
int avgCharWidth = gc.getFontMetrics().getAverageCharWidth();
gc.dispose();
- return avgCharWidth;
+ return Math.max(avgCharWidth, MIN_CHAR_WIDTH);
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java
index db69ffe..3364c5b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java
@@ -268,7 +268,7 @@ public class GLFunctionTraceViewer extends EditorPart implements ISelectionProvi
mFrameSelectionSpinner = new Spinner(c, SWT.BORDER);
gd = new GridData();
// width to hold atleast 6 digits
- gd.widthHint = SwtUtils.getFontWidth(mFrameSelectionSpinner) * 6;
+ gd.widthHint = SwtUtils.getApproximateFontWidth(mFrameSelectionSpinner) * 6;
mFrameSelectionSpinner.setLayoutData(gd);
mFrameSelectionSpinner.setMinimum(1);