mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Don't show back button on settings screen in Landscape mode
This commit is contained in:
@@ -30,13 +30,17 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
|
|||||||
this(tabPages0, true);
|
this(tabPages0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public TabPageScreen(TabPage<T>[] tabPages0, boolean showBackButton) {
|
public TabPageScreen(TabPage<T>[] tabPages0, boolean showBackButton) {
|
||||||
super(new TabHeader<T>(tabPages0, showBackButton));
|
this(new TabHeader<T>(tabPages0, showBackButton));
|
||||||
tabHeader = (TabHeader<T>)getHeader(); //cache reference to tab header with proper type
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public TabPageScreen(TabHeader<T> tabHeader0) {
|
||||||
|
super(tabHeader0);
|
||||||
|
tabHeader = tabHeader0; //cache reference to tab header with proper type
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
tabPages = tabPages0;
|
tabPages = tabHeader.tabPages;
|
||||||
for (TabPage<T> tabPage : tabPages) {
|
for (TabPage<T> tabPage : tabPages) {
|
||||||
tabPage.index = index++;
|
tabPage.index = index++;
|
||||||
tabPage.parentScreen = (T)this;
|
tabPage.parentScreen = (T)this;
|
||||||
@@ -91,12 +95,13 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TabHeader<T extends TabPageScreen<T>> extends Header {
|
protected static class TabHeader<T extends TabPageScreen<T>> extends Header {
|
||||||
private static final float HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 1.4f);
|
private static final float HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 1.4f);
|
||||||
private static final float COMPACT_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
|
private static final float COMPACT_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
|
||||||
private static final float BACK_BUTTON_WIDTH = Math.round(HEIGHT / 2);
|
private static final float BACK_BUTTON_WIDTH = Math.round(HEIGHT / 2);
|
||||||
private static final FSkinColor SEPARATOR_COLOR = BACK_COLOR.stepColor(-40);
|
private static final FSkinColor SEPARATOR_COLOR = BACK_COLOR.stepColor(-40);
|
||||||
|
|
||||||
|
private final TabPage<T>[] tabPages;
|
||||||
private final FLabel btnBack;
|
private final FLabel btnBack;
|
||||||
private boolean isScrollable;
|
private boolean isScrollable;
|
||||||
private FDisplayObject finalVisibleTab;
|
private FDisplayObject finalVisibleTab;
|
||||||
@@ -143,7 +148,8 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public TabHeader(TabPage<T>[] tabPages, boolean showBackButton) {
|
public TabHeader(TabPage<T>[] tabPages0, boolean showBackButton) {
|
||||||
|
tabPages = tabPages0;
|
||||||
if (showBackButton) {
|
if (showBackButton) {
|
||||||
btnBack = add(new FLabel.Builder().icon(new BackIcon(BACK_BUTTON_WIDTH, BACK_BUTTON_WIDTH)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() {
|
btnBack = add(new FLabel.Builder().icon(new BackIcon(BACK_BUTTON_WIDTH, BACK_BUTTON_WIDTH)).pressedColor(BTN_PRESSED_COLOR).align(HAlignment.CENTER).command(new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
@@ -161,6 +167,10 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean showBackButtonInLandscapeMode() {
|
||||||
|
return btnBack != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getPreferredHeight() {
|
public float getPreferredHeight() {
|
||||||
return COMPACT_TABS ? COMPACT_HEIGHT : HEIGHT;
|
return COMPACT_TABS ? COMPACT_HEIGHT : HEIGHT;
|
||||||
@@ -176,7 +186,7 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
|
|||||||
if (Forge.isLandscapeMode()) {
|
if (Forge.isLandscapeMode()) {
|
||||||
//in landscape mode, draw left border for header
|
//in landscape mode, draw left border for header
|
||||||
g.drawLine(LINE_THICKNESS, LINE_COLOR, 0, 0, 0, getHeight());
|
g.drawLine(LINE_THICKNESS, LINE_COLOR, 0, 0, 0, getHeight());
|
||||||
if (btnBack != null) { //draw top border for back button
|
if (showBackButtonInLandscapeMode()) { //draw top border for back button
|
||||||
float y = btnBack.getTop() - LINE_THICKNESS / 2;
|
float y = btnBack.getTop() - LINE_THICKNESS / 2;
|
||||||
g.drawLine(LINE_THICKNESS, SEPARATOR_COLOR, 0, y, getWidth(), y);
|
g.drawLine(LINE_THICKNESS, SEPARATOR_COLOR, 0, y, getWidth(), y);
|
||||||
}
|
}
|
||||||
@@ -199,9 +209,11 @@ public class TabPageScreen<T extends TabPageScreen<T>> extends FScreen {
|
|||||||
float x = 0;
|
float x = 0;
|
||||||
if (btnBack != null) {
|
if (btnBack != null) {
|
||||||
if (Forge.isLandscapeMode()) { //show back button at bottom for landscape mode
|
if (Forge.isLandscapeMode()) { //show back button at bottom for landscape mode
|
||||||
float backButtonHeight = HEIGHT * 0.75f;
|
if (showBackButtonInLandscapeMode()) {
|
||||||
btnBack.setBounds(0, height - backButtonHeight, width, backButtonHeight);
|
float backButtonHeight = HEIGHT * 0.75f;
|
||||||
height -= backButtonHeight;
|
btnBack.setBounds(0, height - backButtonHeight, width, backButtonHeight);
|
||||||
|
height -= backButtonHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
btnBack.setIconScaleAuto(COMPACT_TABS);
|
btnBack.setIconScaleAuto(COMPACT_TABS);
|
||||||
|
|||||||
@@ -34,9 +34,14 @@ public class SettingsScreen extends TabPageScreen<SettingsScreen> {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private SettingsScreen() {
|
private SettingsScreen() {
|
||||||
super(new TabPage[] {
|
super(new TabHeader<SettingsScreen>(new TabPage[] {
|
||||||
new SettingsPage(),
|
new SettingsPage(),
|
||||||
new FilesPage()
|
new FilesPage()
|
||||||
|
}, true) {
|
||||||
|
@Override
|
||||||
|
protected boolean showBackButtonInLandscapeMode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user