Merge branch 'master' into 'master'

[Mobile] Fix auto close for Add Basic Lands Dialog and Deck Chooser

See merge request core-developers/forge!6193
This commit is contained in:
Anthony Calosa
2022-02-09 03:06:01 +00:00
3 changed files with 21 additions and 1 deletions

View File

@@ -128,6 +128,7 @@ public class AddBasicLandsDialog extends FDialog {
lblDeckInfo.setFont(FSkinFont.get(12)); lblDeckInfo.setFont(FSkinFont.get(12));
cbLandSet.setFont(lblLandSet.getFont()); cbLandSet.setFont(lblLandSet.getFont());
cbLandSet.setAutoClose(false);
cbLandSet.setChangedHandler(new FEventHandler() { cbLandSet.setChangedHandler(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
@@ -251,7 +252,8 @@ public class AddBasicLandsDialog extends FDialog {
//layout land set combo box //layout land set combo box
float comboBoxHeight = cbLandSet.getHeight(); float comboBoxHeight = cbLandSet.getHeight();
lblLandSet.setBounds(x, y, lblLandSet.getAutoSizeBounds().width, comboBoxHeight); lblLandSet.setBounds(x, y, lblLandSet.getAutoSizeBounds().width, comboBoxHeight);
cbLandSet.setBounds(x + lblLandSet.getWidth(), y, w - lblLandSet.getWidth(), comboBoxHeight); y+= comboBoxHeight;
cbLandSet.setBounds(x, y, w, comboBoxHeight);
//layout card panel scroller //layout card panel scroller
y += comboBoxHeight + padding; y += comboBoxHeight + padding;

View File

@@ -520,6 +520,7 @@ public class FDeckChooser extends FScreen {
if (cmbDeckTypes == null) { //initialize components with delayed initialization the first time this is populated if (cmbDeckTypes == null) { //initialize components with delayed initialization the first time this is populated
cmbDeckTypes = new FComboBox<>(); cmbDeckTypes = new FComboBox<>();
cmbDeckTypes.setAutoClose(false);
switch (lstDecks.getGameType()) { switch (lstDecks.getGameType()) {
case Constructed: case Constructed:
case Gauntlet: case Gauntlet:

View File

@@ -19,6 +19,7 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
private String label = ""; private String label = "";
private final DropDown dropDown = new DropDown(); private final DropDown dropDown = new DropDown();
private FEventHandler dropDownItemTap, dropDownChangeHandler; private FEventHandler dropDownItemTap, dropDownChangeHandler;
private boolean autoClose = true;
public FComboBox() { public FComboBox() {
initialize(); initialize();
@@ -38,6 +39,10 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
initialize(); initialize();
} }
public void setAutoClose(boolean autoClose) {
this.autoClose = autoClose;
}
private void initialize() { private void initialize() {
if (!items.isEmpty()) { if (!items.isEmpty()) {
setSelectedItem(items.get(0)); //select first item by default setSelectedItem(items.get(0)); //select first item by default
@@ -233,6 +238,18 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
} }
private class DropDown extends FDropDownMenu { private class DropDown extends FDropDownMenu {
@Override
protected boolean autoHide() {
return autoClose;
}
@Override
public boolean tap(float x, float y, int count) {
if (!autoClose)
hide();
return super.tap(x, y, count);
}
@Override @Override
protected void buildMenu() { protected void buildMenu() {
for (final T item : FComboBox.this.items) { for (final T item : FComboBox.this.items) {