mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Fix some scaling issues
This commit is contained in:
@@ -61,6 +61,7 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
|||||||
private FEventHandler selectionChangedHandler, itemActivateHandler;
|
private FEventHandler selectionChangedHandler, itemActivateHandler;
|
||||||
private final Class<T> genericType;
|
private final Class<T> genericType;
|
||||||
private ItemManagerConfig config;
|
private ItemManagerConfig config;
|
||||||
|
private String caption, ratio;
|
||||||
|
|
||||||
private final ItemFilter<? extends T> mainSearchFilter;
|
private final ItemFilter<? extends T> mainSearchFilter;
|
||||||
|
|
||||||
@@ -73,11 +74,6 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
|||||||
.fontSize(12)
|
.fontSize(12)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final FLabel lblRatio = new FLabel.Builder()
|
|
||||||
.align(HAlignment.LEFT)
|
|
||||||
.fontSize(12)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
private static final FSkinImage VIEW_OPTIONS_ICON = FSkinImage.SETTINGS;
|
private static final FSkinImage VIEW_OPTIONS_ICON = FSkinImage.SETTINGS;
|
||||||
private final FLabel btnViewOptions = new FLabel.Builder()
|
private final FLabel btnViewOptions = new FLabel.Builder()
|
||||||
.selectable(true).align(HAlignment.CENTER)
|
.selectable(true).align(HAlignment.CENTER)
|
||||||
@@ -121,7 +117,6 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
|||||||
add(mainSearchFilter.getPanel());
|
add(mainSearchFilter.getPanel());
|
||||||
add(btnFilters);
|
add(btnFilters);
|
||||||
add(lblCaption);
|
add(lblCaption);
|
||||||
add(lblRatio);
|
|
||||||
for (ItemView<T> view : views) {
|
for (ItemView<T> view : views) {
|
||||||
add(view.getButton());
|
add(view.getButton());
|
||||||
view.getButton().setSelected(view == currentView);
|
view.getButton().setSelected(view == currentView);
|
||||||
@@ -283,19 +278,9 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
|||||||
helper.newLine(ItemFilter.PADDING);
|
helper.newLine(ItemFilter.PADDING);
|
||||||
float fieldHeight = mainSearchFilter.getMainComponent().getHeight();
|
float fieldHeight = mainSearchFilter.getMainComponent().getHeight();
|
||||||
helper.include(btnFilters, btnFilters.getAutoSizeBounds().width * 1.2f, fieldHeight);
|
helper.include(btnFilters, btnFilters.getAutoSizeBounds().width * 1.2f, fieldHeight);
|
||||||
float captionWidth = lblCaption.getAutoSizeBounds().width;
|
|
||||||
float ratioWidth = lblRatio.getAutoSizeBounds().width;
|
|
||||||
float viewButtonWidth = fieldHeight;
|
float viewButtonWidth = fieldHeight;
|
||||||
float viewButtonCount = views.size() + Utils.scaleX(1);
|
float viewButtonCount = views.size() + Utils.scaleX(1);
|
||||||
float availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 1) * helper.getGapX();
|
helper.fillLine(lblCaption, fieldHeight, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + 1); //leave room for view buttons
|
||||||
if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it
|
|
||||||
captionWidth = availableCaptionWidth;
|
|
||||||
}
|
|
||||||
helper.offset(0, Utils.scaleY(1)); //shift caption downward
|
|
||||||
helper.include(lblCaption, captionWidth, fieldHeight);
|
|
||||||
helper.offset(-helper.getGapX(), 0);
|
|
||||||
helper.fillLine(lblRatio, fieldHeight, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + 1); //leave room for view buttons
|
|
||||||
helper.offset(0, Utils.scaleY(1)); //shift buttons upward
|
|
||||||
for (ItemView<T> view : views) {
|
for (ItemView<T> view : views) {
|
||||||
helper.include(view.getButton(), viewButtonWidth, fieldHeight);
|
helper.include(view.getButton(), viewButtonWidth, fieldHeight);
|
||||||
helper.offset(Utils.scaleX(-1), 0);
|
helper.offset(Utils.scaleX(-1), 0);
|
||||||
@@ -326,7 +311,7 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
|||||||
* @return caption to display before ratio
|
* @return caption to display before ratio
|
||||||
*/
|
*/
|
||||||
public String getCaption() {
|
public String getCaption() {
|
||||||
return lblCaption.getText();
|
return caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -335,8 +320,13 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
|||||||
*
|
*
|
||||||
* @param caption - caption to display before ratio
|
* @param caption - caption to display before ratio
|
||||||
*/
|
*/
|
||||||
public void setCaption(String caption) {
|
public void setCaption(String caption0) {
|
||||||
lblCaption.setText(caption);
|
caption = caption0;
|
||||||
|
updateCaptionLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCaptionLabel() {
|
||||||
|
lblCaption.setText(caption + " " + ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -916,7 +906,8 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
|
|||||||
else {
|
else {
|
||||||
total = pool.countAll();
|
total = pool.countAll();
|
||||||
}
|
}
|
||||||
lblRatio.setText("(" + getFilteredItems().countAll() + " / " + total + ")");
|
ratio = "(" + getFilteredItems().countAll() + " / " + total + ")";
|
||||||
|
updateCaptionLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -68,19 +68,18 @@ public class CardSearchFilter extends TextSearchFilter<PaperCard> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doWidgetLayout(LayoutHelper helper) {
|
protected void doWidgetLayout(LayoutHelper helper) {
|
||||||
final float comboBoxWidth = 61;
|
final float buttonWidth = Math.max(Math.max(btnName.getAutoSizeBounds().width, btnType.getAutoSizeBounds().width), btnText.getAutoSizeBounds().width);
|
||||||
final float buttonWidth = 51;
|
|
||||||
final float height = helper.getParentHeight();
|
final float height = helper.getParentHeight();
|
||||||
|
|
||||||
helper.fillLine(txtSearch, height, comboBoxWidth + buttonWidth * 3 + helper.getGapX() * 4); //leave space for combo box and buttons
|
helper.fillLine(txtSearch, height, (buttonWidth + helper.getGapX()) * 4); //leave space for combo box and buttons
|
||||||
helper.include(cbSearchMode, comboBoxWidth, height);
|
helper.include(cbSearchMode, buttonWidth, height); //use button width for combo box too
|
||||||
helper.include(btnName, buttonWidth, height);
|
helper.include(btnName, buttonWidth, height);
|
||||||
helper.include(btnType, buttonWidth, height);
|
helper.include(btnType, buttonWidth, height);
|
||||||
helper.include(btnText, buttonWidth, height);
|
helper.include(btnText, buttonWidth, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FLabel addButton(Widget widget, String text) {
|
private FLabel addButton(Widget widget, String text) {
|
||||||
FLabel button = new FLabel.Builder().text(text).align(HAlignment.CENTER)
|
FLabel button = new FLabel.Builder().text(text).fontSize(txtSearch.getFontSize()).align(HAlignment.CENTER)
|
||||||
.selectable().selected().command(new FEventHandler() {
|
.selectable().selected().command(new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
|
|||||||
@@ -101,27 +101,36 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawContent(Graphics g, float w, float h, final boolean pressed) {
|
protected void drawContent(Graphics g, float w, float h, final boolean pressed) {
|
||||||
float squareSize = w / 2 - 2;
|
float lineThickness = Utils.scaleMin(1);
|
||||||
float offset = 2;
|
float offset = 2 * lineThickness;
|
||||||
float x = (w - squareSize) / 2 - offset;
|
float squareSize = Math.round(w / 2 - offset);
|
||||||
float y = (h - squareSize) / 2 - offset;
|
if (squareSize % 2 == 1) {
|
||||||
if (!pressed) {
|
squareSize++; //needs to be even number for this to look right
|
||||||
x--;
|
}
|
||||||
y--;
|
float x = Math.round((w - squareSize) / 2 - offset);
|
||||||
|
float y = Math.round((h - squareSize) / 2 - offset);
|
||||||
|
if (pressed) {
|
||||||
|
y += lineThickness;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x -= lineThickness;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
g.drawLine(1, GROUP_HEADER_FORE_COLOR, x, y, x + squareSize, y);
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x, y, x + squareSize, y);
|
||||||
g.drawLine(1, GROUP_HEADER_FORE_COLOR, x + squareSize, y, x + squareSize, y + offset);
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x + squareSize, y, x + squareSize, y + offset);
|
||||||
g.drawLine(1, GROUP_HEADER_FORE_COLOR, x, y, x, y + squareSize);
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x, y, x, y + squareSize);
|
||||||
g.drawLine(1, GROUP_HEADER_FORE_COLOR, x, y + squareSize, x + offset, y + squareSize);
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x, y + squareSize, x + offset, y + squareSize);
|
||||||
x += offset;
|
x += offset;
|
||||||
y += offset;
|
y += offset;
|
||||||
}
|
}
|
||||||
g.drawRect(1, GROUP_HEADER_FORE_COLOR, x, y, squareSize, squareSize);
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x, y, x + squareSize, y);
|
||||||
g.drawLine(1, GROUP_HEADER_FORE_COLOR, x + offset + 1, y + squareSize / 2, x + squareSize - 2 * offset + 1, y + squareSize / 2);
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x + squareSize, y, x + squareSize, y + squareSize);
|
||||||
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x, y, x, y + squareSize);
|
||||||
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x, y + squareSize, x + squareSize, y + squareSize);
|
||||||
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x + offset + 1, y + squareSize / 2, x + squareSize - offset, y + squareSize / 2);
|
||||||
if (isAllCollapsed) {
|
if (isAllCollapsed) {
|
||||||
g.drawLine(1, GROUP_HEADER_FORE_COLOR, x + squareSize / 2, y + offset + 1, x + squareSize / 2, y + squareSize - 2 * offset + 1);
|
g.drawLine(lineThickness, GROUP_HEADER_FORE_COLOR, x + squareSize / 2, y + offset, x + squareSize / 2, y + squareSize - offset - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,8 +253,8 @@ public class FLabel extends FDisplayObject implements IButton {
|
|||||||
w -= 2 * x;
|
w -= 2 * x;
|
||||||
h -= 2 * x;
|
h -= 2 * x;
|
||||||
if (pressed) { //while pressed, translate graphics so icon and text appear shifted down and to the right
|
if (pressed) { //while pressed, translate graphics so icon and text appear shifted down and to the right
|
||||||
x++;
|
x += Utils.scaleX(1);
|
||||||
y++;
|
y += Utils.scaleY(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user