mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Fix so buttons can be clicked while prompt magnify open
This commit is contained in:
@@ -18,17 +18,14 @@ public class FMagnifyView extends FDropDown {
|
|||||||
private String text;
|
private String text;
|
||||||
private FSkinColor foreColor, backColor;
|
private FSkinColor foreColor, backColor;
|
||||||
private FSkinFont font;
|
private FSkinFont font;
|
||||||
private float offsetX, width;
|
|
||||||
|
|
||||||
public static void show(FDisplayObject owner0, String text0, FSkinColor foreColor0, FSkinColor backColor0, FSkinFont font0, float offsetX0, float width0) {
|
public static void show(FDisplayObject owner0, String text0, FSkinColor foreColor0, FSkinColor backColor0, FSkinFont font0) {
|
||||||
FMagnifyView view = new FMagnifyView();
|
FMagnifyView view = new FMagnifyView();
|
||||||
view.owner = owner0;
|
view.owner = owner0;
|
||||||
view.text = text0;
|
view.text = text0;
|
||||||
view.foreColor = foreColor0;
|
view.foreColor = foreColor0;
|
||||||
view.backColor = backColor0;
|
view.backColor = backColor0;
|
||||||
view.font = font0;
|
view.font = font0;
|
||||||
view.offsetX = offsetX0;
|
|
||||||
view.width = width0;
|
|
||||||
view.show();
|
view.show();
|
||||||
}
|
}
|
||||||
private FMagnifyView() {
|
private FMagnifyView() {
|
||||||
@@ -36,16 +33,16 @@ public class FMagnifyView extends FDropDown {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateSizeAndPosition() {
|
protected void updateSizeAndPosition() {
|
||||||
float x = owner.getScreenPosition().x + offsetX;
|
float x = owner.getScreenPosition().x;
|
||||||
float y = owner.getScreenPosition().y + owner.getHeight();
|
float y = owner.getScreenPosition().y + owner.getHeight();
|
||||||
paneSize = updateAndGetPaneSize(width, y);
|
paneSize = updateAndGetPaneSize(owner.getWidth(), y);
|
||||||
float height = paneSize.getHeight();
|
float height = paneSize.getHeight();
|
||||||
if (height > y) {
|
if (height > y) {
|
||||||
height = y;
|
height = y;
|
||||||
}
|
}
|
||||||
y -= height;
|
y -= height;
|
||||||
|
|
||||||
setBounds(Math.round(x), Math.round(y), Math.round(width), Math.round(height));
|
setBounds(Math.round(x), Math.round(y), Math.round(owner.getWidth()), Math.round(height));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import forge.menu.FMagnifyView;
|
|||||||
import forge.toolbox.FButton;
|
import forge.toolbox.FButton;
|
||||||
import forge.toolbox.FButton.Corner;
|
import forge.toolbox.FButton.Corner;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.FContainer;
|
||||||
|
import forge.toolbox.FDisplayObject;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
@@ -26,11 +27,14 @@ public class VPrompt extends FContainer {
|
|||||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
private static final FSkinFont FONT = FSkinFont.get(14);
|
private static final FSkinFont FONT = FSkinFont.get(14);
|
||||||
|
|
||||||
private final TextRenderer renderer = new TextRenderer();
|
|
||||||
private final FButton btnOk, btnCancel;
|
private final FButton btnOk, btnCancel;
|
||||||
|
private final MessageLabel lblMessage;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public VPrompt(String okText, String cancelText, FEventHandler okCommand, FEventHandler cancelCommand) {
|
public VPrompt(String okText, String cancelText, FEventHandler okCommand, FEventHandler cancelCommand) {
|
||||||
|
lblMessage = add(new MessageLabel());
|
||||||
|
lblMessage.setLeft(BTN_WIDTH);
|
||||||
|
lblMessage.setHeight(HEIGHT);
|
||||||
btnOk = add(new FButton(okText, okCommand));
|
btnOk = add(new FButton(okText, okCommand));
|
||||||
btnCancel = add(new FButton(cancelText, cancelCommand));
|
btnCancel = add(new FButton(cancelText, cancelCommand));
|
||||||
btnOk.setSize(BTN_WIDTH, HEIGHT);
|
btnOk.setSize(BTN_WIDTH, HEIGHT);
|
||||||
@@ -59,34 +63,39 @@ public class VPrompt extends FContainer {
|
|||||||
//SDisplayUtil.remind(view);
|
//SDisplayUtil.remind(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean tap(float x, float y, int count) {
|
|
||||||
//if not enough room for prompt at given size, show magnify view
|
|
||||||
float offsetX = BTN_WIDTH + PADDING;
|
|
||||||
float maxWidth = getWidth() - 2 * offsetX;
|
|
||||||
float maxHeight = getHeight() - 2 * PADDING;
|
|
||||||
TextBounds textBounds = renderer.getWrappedBounds(message, FONT, maxWidth);
|
|
||||||
if (textBounds.height > maxHeight) {
|
|
||||||
FMagnifyView.show(this, message, FORE_COLOR, BACK_COLOR, FONT, offsetX, maxWidth);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
btnCancel.setLeft(width - BTN_WIDTH);
|
lblMessage.setWidth(width - 2 * BTN_WIDTH);
|
||||||
|
btnCancel.setLeft(lblMessage.getRight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawBackground(Graphics g) {
|
protected void drawBackground(Graphics g) {
|
||||||
float w = getWidth();
|
g.fillRect(BACK_COLOR, 0, 0, getWidth(), getHeight());
|
||||||
float h = getHeight();
|
}
|
||||||
|
|
||||||
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
private class MessageLabel extends FDisplayObject {
|
||||||
if (!StringUtils.isEmpty(message)) {
|
private final TextRenderer renderer = new TextRenderer();
|
||||||
float x = BTN_WIDTH + PADDING;
|
|
||||||
float y = PADDING;
|
@Override
|
||||||
renderer.drawText(g, message, FONT, FORE_COLOR, x, y, w - 2 * x, h - 2 * y, true, HAlignment.CENTER, true);
|
public boolean tap(float x, float y, int count) {
|
||||||
|
//if not enough room for prompt at given size, show magnify view
|
||||||
|
float maxWidth = getWidth() - 2 * PADDING;
|
||||||
|
float maxHeight = getHeight() - 2 * PADDING;
|
||||||
|
TextBounds textBounds = renderer.getWrappedBounds(message, FONT, maxWidth);
|
||||||
|
if (textBounds.height > maxHeight) {
|
||||||
|
FMagnifyView.show(this, message, FORE_COLOR, BACK_COLOR, FONT);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics g) {
|
||||||
|
if (!StringUtils.isEmpty(message)) {
|
||||||
|
float x = PADDING;
|
||||||
|
float y = PADDING;
|
||||||
|
renderer.drawText(g, message, FONT, FORE_COLOR, x, y, getWidth() - 2 * x, getHeight() - 2 * y, true, HAlignment.CENTER, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class ViewWinLose extends FOverlay {
|
|||||||
@Override
|
@Override
|
||||||
public boolean tap(float x, float y, int count) {
|
public boolean tap(float x, float y, int count) {
|
||||||
if (txtLog.getMaxScrollTop() > 0) {
|
if (txtLog.getMaxScrollTop() > 0) {
|
||||||
FMagnifyView.show(txtLog, txtLog.getText(), FTextArea.FORE_COLOR, ViewWinLose.this.getBackColor(), txtLog.getFont(), 0, txtLog.getWidth());
|
FMagnifyView.show(txtLog, txtLog.getText(), FTextArea.FORE_COLOR, ViewWinLose.this.getBackColor(), txtLog.getFont());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user