DroidFish: Made the large buttons a little smaller when all three custom buttons are visible.

This commit is contained in:
Peter Osterlund 2012-06-10 14:11:09 +00:00
parent 789c734337
commit 10c80e802c
2 changed files with 24 additions and 2 deletions

View File

@ -49,6 +49,15 @@ public class ButtonActions {
this.menuTitle = menuTitle; this.menuTitle = menuTitle;
} }
public boolean isEnabled() {
if (mainAction != null)
return true;
for (UIAction a : menuActions)
if (a != null)
return true;
return false;
}
/** Connect GUI button. */ /** Connect GUI button. */
public void setImageButton(ImageButton button, final Activity activity) { public void setImageButton(ImageButton button, final Activity activity) {
this.button = button; this.button = button;

View File

@ -802,8 +802,21 @@ public class DroidFish extends Activity implements GUIInterface {
int bWidth = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, r.getDisplayMetrics())); int bWidth = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, r.getDisplayMetrics()));
int bHeight = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics())); int bHeight = (int)Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics()));
if (largeButtons) { if (largeButtons) {
bWidth = bWidth * 3 / 2; if (custom1ButtonActions.isEnabled() &&
bHeight = bHeight * 3 / 2; custom2ButtonActions.isEnabled() &&
custom3ButtonActions.isEnabled()) {
Configuration config = getResources().getConfiguration();
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
bWidth = bWidth * 6 / 5;
bHeight = bHeight * 6 / 5;
} else {
bWidth = bWidth * 5 / 4;
bHeight = bHeight * 5 / 4;
}
} else {
bWidth = bWidth * 3 / 2;
bHeight = bHeight * 3 / 2;
}
} }
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.touch); SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.touch);
setButtonData(custom1Button, bWidth, bHeight, custom1ButtonActions.getIcon(), svg); setButtonData(custom1Button, bWidth, bHeight, custom1ButtonActions.getIcon(), svg);