SDK Manager > AVD > Start: print computed scale. DO NOT MERGE.

This displays the scale computed by AVD Start.
I find it more intuitive to use if I see what the
emulator will be called with.

Change-Id: I6b97fee06bd4e6dc36c977ffef3c25315469b766
This commit is contained in:
Raphael
2009-10-29 13:00:11 -07:00
parent 275de810e9
commit 93ead92dbb

View File

@@ -83,6 +83,7 @@ final class AvdStartDialog extends GridDialog {
private int mSize2 = -1; private int mSize2 = -1;
private String mSkinDisplay; private String mSkinDisplay;
private boolean mEnableScaling = true; private boolean mEnableScaling = true;
private Label mScaleField;
AvdStartDialog(Shell parentShell, AvdInfo avd, String sdkLocation, AvdStartDialog(Shell parentShell, AvdInfo avd, String sdkLocation,
SettingsController settingsController) { SettingsController settingsController) {
@@ -162,6 +163,7 @@ final class AvdStartDialog extends GridDialog {
onScaleChange(); onScaleChange();
} }
}); });
// empty composite, only 2 widgets on this line. // empty composite, only 2 widgets on this line.
new Composite(scaleGroup, SWT.NONE).setLayoutData(gd = new GridData()); new Composite(scaleGroup, SWT.NONE).setLayoutData(gd = new GridData());
gd.widthHint = gd.heightHint = 0; gd.widthHint = gd.heightHint = 0;
@@ -203,6 +205,16 @@ final class AvdStartDialog extends GridDialog {
} }
}); });
l = new Label(scaleGroup, SWT.NONE);
l.setText("Scale:");
mScaleField = new Label(scaleGroup, SWT.NONE);
mScaleField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
true /*grabExcessHorizontalSpace*/,
true /*grabExcessVerticalSpace*/,
2 /*horizontalSpan*/,
1 /*verticalSpan*/));
setScale(mScale); // set initial text value
enableGroup(scaleGroup, defaultState); enableGroup(scaleGroup, defaultState);
mScaleButton.addSelectionListener(new SelectionAdapter() { mScaleButton.addSelectionListener(new SelectionAdapter() {
@@ -213,7 +225,7 @@ final class AvdStartDialog extends GridDialog {
if (enabled) { if (enabled) {
onScaleChange(); onScaleChange();
} else { } else {
mScale = 0.f; setScale(0);
} }
} }
}); });
@@ -308,13 +320,13 @@ final class AvdStartDialog extends GridDialog {
private void onScaleChange() { private void onScaleChange() {
String sizeStr = mScreenSize.getText(); String sizeStr = mScreenSize.getText();
if (sizeStr.length() == 0) { if (sizeStr.length() == 0) {
mScale = 0.f; setScale(0);
return; return;
} }
String dpiStr = mMonitorDpi.getText(); String dpiStr = mMonitorDpi.getText();
if (dpiStr.length() == 0) { if (dpiStr.length() == 0) {
mScale = 0.f; setScale(0);
return; return;
} }
@@ -334,7 +346,21 @@ final class AvdStartDialog extends GridDialog {
// the scale factor is a mix of adapting to the new density and to the new size. // the scale factor is a mix of adapting to the new density and to the new size.
// (size/diagonalIn) * (dpi/mDensity) // (size/diagonalIn) * (dpi/mDensity)
// this can be simplified to: // this can be simplified to:
mScale = (size * dpi) / diagonalPx; setScale((size * dpi) / diagonalPx);
}
private void setScale(float scale) {
mScale = scale;
// Do the rounding exactly like AvdSelector will do.
scale = Math.round(scale * 100);
scale /= 100.f;
if (scale == 0.f) {
mScaleField.setText("default"); //$NON-NLS-1$
} else {
mScaleField.setText(String.format("%.2f", scale)); //$NON-NLS-1$
}
} }
/** /**