From bddfff41f2c58ae9a2247194fde18d4a3bd0716d Mon Sep 17 00:00:00 2001 From: drdev Date: Sat, 3 May 2014 15:36:56 +0000 Subject: [PATCH] Auto-focus ListChooser search field on desktop Increase width of buttons on DualListBox Make border on ListChooser show up on certain themes --- forge-gui-mobile/src/forge/toolbox/DualListBox.java | 2 +- forge-gui-mobile/src/forge/toolbox/FTextField.java | 8 ++++++-- forge-gui-mobile/src/forge/toolbox/ListChooser.java | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/forge-gui-mobile/src/forge/toolbox/DualListBox.java b/forge-gui-mobile/src/forge/toolbox/DualListBox.java index 6ec565edca0..a34537fa620 100644 --- a/forge-gui-mobile/src/forge/toolbox/DualListBox.java +++ b/forge-gui-mobile/src/forge/toolbox/DualListBox.java @@ -151,7 +151,7 @@ public class DualListBox extends FDialog { float buttonHeight = FOptionPane.BUTTON_HEIGHT; float labelHeight = selectOrder.getAutoSizeBounds().height; float listHeight = (maxHeight - 2 * labelHeight - buttonHeight - FOptionPane.PADDING - 2 * FDialog.INSETS) / 2; - float addButtonWidth = addAllButton.getAutoSizeBounds().width; + float addButtonWidth = addAllButton.getAutoSizeBounds().width * 1.2f; float addButtonHeight = listHeight / 2 - gapBetweenButtons; float listWidth = width - addButtonWidth - gapBetweenButtons; diff --git a/forge-gui-mobile/src/forge/toolbox/FTextField.java b/forge-gui-mobile/src/forge/toolbox/FTextField.java index 248afe68888..468cc6ed1de 100644 --- a/forge-gui-mobile/src/forge/toolbox/FTextField.java +++ b/forge-gui-mobile/src/forge/toolbox/FTextField.java @@ -145,7 +145,12 @@ public class FTextField extends FDisplayObject { @Override public boolean tap(float x, float y, int count) { - if (keyInputActive) { return true; } //do nothing if key input already active + startEdit(); + return true; + } + + public void startEdit() { + if (keyInputActive) { return; } //do nothing if key input already active selStart = 0; //select all before starting input selLength = text.length(); @@ -224,7 +229,6 @@ public class FTextField extends FDisplayObject { } }); keyInputActive = true; - return true; } @Override diff --git a/forge-gui-mobile/src/forge/toolbox/ListChooser.java b/forge-gui-mobile/src/forge/toolbox/ListChooser.java index 445fd337a9e..910aa418ea8 100644 --- a/forge-gui-mobile/src/forge/toolbox/ListChooser.java +++ b/forge-gui-mobile/src/forge/toolbox/ListChooser.java @@ -18,6 +18,8 @@ package forge.toolbox; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Application.ApplicationType; import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.google.common.base.Function; @@ -65,7 +67,7 @@ public class ListChooser extends FContainer { public static final FSkinColor ITEM_COLOR = FSkinColor.get(Colors.CLR_ZEBRA); public static final FSkinColor ALT_ITEM_COLOR = ITEM_COLOR.getContrastColor(-20); public static final FSkinColor SEL_COLOR = FSkinColor.get(Colors.CLR_ACTIVE); - public static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS); + public static final FSkinColor BORDER_COLOR = FList.FORE_COLOR; public static final float ITEM_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.75f; // Data and number of choices for the list @@ -181,6 +183,9 @@ public class ListChooser extends FContainer { } onSelectionChange(); optionPane.show(); + if (txtSearch != null && Gdx.app.getType() == ApplicationType.Desktop) { + txtSearch.startEdit(); //automatically focus search textbox for edit if on desktop + } } private void onSelectionChange() {