Remove preferred size and default button size

Replace alignment data in horizontal and vertical layout with double value
Add convenient size(GuiElement, ReadableDimension) method to custom layout
This commit is contained in:
johni0702
2015-07-11 15:23:17 +02:00
parent 219277f623
commit 35bc9f7fae
15 changed files with 94 additions and 99 deletions

View File

@@ -16,9 +16,9 @@ public class GuiLoginPrompt extends AbstractGuiScreen<GuiLoginPrompt> {
private GuiLabel passwordLabel = new GuiLabel(this).setI18nText("replaymod.gui.password");
private GuiLabel noAccountLabel = new GuiLabel(this).setI18nText("replaymod.gui.login.noacc");
private GuiLabel statusLabel = new GuiLabel(this);
private GuiButton loginButton = new GuiButton(this).setI18nLabel("replaymod.gui.login").setWidth(150).setEnabled(false);
private GuiButton cancelButton = new GuiButton(this).setI18nLabel("replaymod.gui.cancel").setWidth(150);
private GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setWidth(150);
private GuiButton loginButton = new GuiButton(this).setI18nLabel("replaymod.gui.login").setSize(150, 20).setEnabled(false);
private GuiButton cancelButton = new GuiButton(this).setI18nLabel("replaymod.gui.cancel").setSize(150, 20);
private GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setSize(150, 20);
private GuiTextField username = new GuiTextField(this).setSize(145, 20).setMaxLength(16).setFocused(true);
private GuiPasswordField password = new GuiPasswordField(this).setSize(145, 20).setNext(username).setPrevious(username);
@@ -95,7 +95,7 @@ public class GuiLoginPrompt extends AbstractGuiScreen<GuiLoginPrompt> {
pos(statusLabel, width / 2 - statusLabel.getMinSize().getWidth() / 2, 92);
int labelWidth = noAccountLabel.getMinSize().getWidth();
int buttonWidth = registerButton.getPreferredSize().getWidth();
int buttonWidth = registerButton.getMaxSize().getWidth();
int lineWidth = labelWidth + 5 + buttonWidth;
int lineStart = width / 2 - lineWidth / 2;
pos(noAccountLabel, lineStart, height - 22);

View File

@@ -16,14 +16,14 @@ public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
private final GuiPanel inputs;
private final GuiTextField usernameInput, mailInput;
private final GuiPasswordField passwordInput, passwordConfirmation;
private final GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setWidth(150).setDisabled();
private final GuiButton cancelButton = new GuiButton(this).setI18nLabel("replaymod.gui.cancel").setWidth(150);
private final GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setSize(150, 20).setDisabled();
private final GuiButton cancelButton = new GuiButton(this).setI18nLabel("replaymod.gui.cancel").setSize(150, 20);
private final GuiLabel statusLabel = new GuiLabel(this).setColor(ReadableColor.RED);
{
inputs = new GuiPanel(this).setLayout(new VerticalLayout().setSpacing(10));
HorizontalLayout.Data data = new HorizontalLayout.Data(0, VerticalLayout.Alignment.CENTER);
inputs.addElements(new VerticalLayout.Data(0, HorizontalLayout.Alignment.RIGHT),
HorizontalLayout.Data data = new HorizontalLayout.Data(0.5);
inputs.addElements(new VerticalLayout.Data(1),
new GuiPanel().setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(10))
.addElements(data, new GuiLabel().setI18nText("replaymod.gui.username"))
.addElements(data, usernameInput = new GuiTextField().setMaxLength(16).setSize(145, 20)),