mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Improve readability for read-only fields
This commit is contained in:
@@ -524,7 +524,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
||||
protected static class OptionsPage extends DeckEditorPage {
|
||||
private static final float PADDING = Utils.scaleMin(5);
|
||||
|
||||
private final FLabel lblName = add(new FLabel.Builder().text("Name:").build());
|
||||
private final FLabel lblName = add(new FLabel.Builder().text("Name:").textColor(FLabel.INLINE_LABEL_COLOR).build());
|
||||
private final FTextField txtName = add(new FTextField());
|
||||
private final FLabel btnSave = add(new FLabel.ButtonBuilder().text("Save Deck").icon(FSkinImage.SAVE).build());
|
||||
private final FLabel btnAddLands = add(new FLabel.ButtonBuilder().text("Add Lands").icon(FSkinImage.LAND).build());
|
||||
@@ -541,7 +541,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
||||
protected void initialize() {
|
||||
txtName.setGhostText("[New Deck]");
|
||||
txtName.setText(parentScreen.getDeck().getName());
|
||||
txtName.setEnabled(false); //TODO: Allow editing for non-limited decks
|
||||
txtName.setReadOnly(true); //TODO: Allow editing for non-limited decks
|
||||
|
||||
btnSave.setCommand(new FEventHandler() {
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,6 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private static final float PILE_SPACING_Y = 0.1f;
|
||||
private static final FSkinFont LABEL_FONT = FSkinFont.get(12);
|
||||
private static final FSkinColor GROUP_HEADER_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
private static final FSkinColor OPTION_LABEL_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(0.7f);
|
||||
private static final FSkinColor GROUP_HEADER_LINE_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(0.5f);
|
||||
private static final FSkinFont GROUP_HEADER_FONT = LABEL_FONT;
|
||||
private static final float GROUP_HEADER_HEIGHT = Utils.scaleY(19);
|
||||
@@ -137,9 +136,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
}
|
||||
}
|
||||
private final ExpandCollapseButton btnExpandCollapseAll = new ExpandCollapseButton();
|
||||
private final FLabel lblGroupBy = new FLabel.Builder().text("Groups:").font(LABEL_FONT).textColor(OPTION_LABEL_COLOR).build();
|
||||
private final FLabel lblGroupBy = new FLabel.Builder().text("Groups:").font(LABEL_FONT).textColor(FLabel.INLINE_LABEL_COLOR).build();
|
||||
private final FComboBox<Object> cbGroupByOptions = new FComboBox<Object>();
|
||||
private final FLabel lblPileBy = new FLabel.Builder().text("Piles:").font(LABEL_FONT).textColor(OPTION_LABEL_COLOR).build();
|
||||
private final FLabel lblPileBy = new FLabel.Builder().text("Piles:").font(LABEL_FONT).textColor(FLabel.INLINE_LABEL_COLOR).build();
|
||||
private final FComboBox<Object> cbPileByOptions = new FComboBox<Object>();
|
||||
|
||||
public ImageView(ItemManager<T> itemManager0, ItemManagerModel<T> model0) {
|
||||
|
||||
@@ -70,7 +70,8 @@ public class FLabel extends FDisplayObject implements IButton {
|
||||
}
|
||||
}
|
||||
|
||||
private static final FSkinColor DEFAULT_TEXT_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
public static final FSkinColor DEFAULT_TEXT_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
public static final FSkinColor INLINE_LABEL_COLOR = DEFAULT_TEXT_COLOR.alphaColor(0.7f);
|
||||
private static final FSkinColor clrMain = FSkinColor.get(Colors.CLR_INACTIVE);
|
||||
private static final FSkinColor d50 = clrMain.stepColor(-50);
|
||||
private static final FSkinColor d30 = clrMain.stepColor(-30);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class FTextField extends FDisplayObject implements ITextField {
|
||||
protected FSkinFont font, renderedFont;
|
||||
private HAlignment alignment;
|
||||
private int selStart, selLength;
|
||||
private boolean isEditing;
|
||||
private boolean isEditing, readOnly;
|
||||
|
||||
public FTextField() {
|
||||
this("");
|
||||
@@ -111,6 +111,13 @@ public class FTextField extends FDisplayObject implements ITextField {
|
||||
setHeight(getDefaultHeight(font));
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
public void setReadOnly(boolean readOnly0) {
|
||||
readOnly = readOnly0;
|
||||
}
|
||||
|
||||
public FEventHandler getChangedHandler() {
|
||||
return changedHandler;
|
||||
}
|
||||
@@ -163,6 +170,7 @@ public class FTextField extends FDisplayObject implements ITextField {
|
||||
}
|
||||
|
||||
public boolean startEdit() {
|
||||
if (readOnly) { return false; }
|
||||
if (isEditing) { return true; } //do nothing if already editing
|
||||
|
||||
selStart = 0; //select all before starting input
|
||||
@@ -290,7 +298,11 @@ public class FTextField extends FDisplayObject implements ITextField {
|
||||
public void draw(Graphics g) {
|
||||
float w = getWidth();
|
||||
float h = getHeight();
|
||||
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
||||
boolean drawBackground = !readOnly; //don't draw background or border if read-only
|
||||
|
||||
if (drawBackground) {
|
||||
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
||||
}
|
||||
|
||||
//determine actual rendered font so selection logic is accurate
|
||||
renderedFont = font;
|
||||
@@ -328,7 +340,9 @@ public class FTextField extends FDisplayObject implements ITextField {
|
||||
drawText(g, w, h);
|
||||
}
|
||||
|
||||
g.drawRect(BORDER_THICKNESS, FORE_COLOR, BORDER_THICKNESS, BORDER_THICKNESS, w - 2 * BORDER_THICKNESS, h - 2 * BORDER_THICKNESS); //allow smooth border to fully display within bounds
|
||||
if (drawBackground) {
|
||||
g.drawRect(BORDER_THICKNESS, FORE_COLOR, BORDER_THICKNESS, BORDER_THICKNESS, w - 2 * BORDER_THICKNESS, h - 2 * BORDER_THICKNESS); //allow smooth border to fully display within bounds
|
||||
}
|
||||
}
|
||||
|
||||
private void drawText(Graphics g, float w, float h) {
|
||||
|
||||
Reference in New Issue
Block a user