mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Support zoom in image view
This commit is contained in:
@@ -62,6 +62,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private GroupDef groupBy = null;
|
||||
private ItemInfo focalItem;
|
||||
private boolean updatingLayout;
|
||||
private float totalZoomAmount;
|
||||
private final ArrayList<ItemInfo> orderedItems = new ArrayList<ItemInfo>();
|
||||
private final ArrayList<Group> groups = new ArrayList<Group>();
|
||||
|
||||
@@ -545,7 +546,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onScrollerTap(float x, float y, int count) {
|
||||
protected boolean tap(float x, float y, int count) {
|
||||
ItemInfo item = getItemAtPoint(x, y);
|
||||
if (count == 1) {
|
||||
selectItem(item);
|
||||
@@ -558,6 +559,22 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean zoom(float x, float y, float amount) {
|
||||
totalZoomAmount += amount;
|
||||
|
||||
float columnZoomAmount = Utils.AVG_FINGER_WIDTH;
|
||||
while (totalZoomAmount >= columnZoomAmount) {
|
||||
setColumnCount(getColumnCount() - 1);
|
||||
totalZoomAmount -= columnZoomAmount;
|
||||
}
|
||||
while (totalZoomAmount <= -columnZoomAmount) {
|
||||
setColumnCount(getColumnCount() + 1);
|
||||
totalZoomAmount += columnZoomAmount;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private ItemInfo getItemAtPoint(float x, float y) {
|
||||
for (int i = groups.size() - 1; i >= 0; i--) {
|
||||
Group group = groups.get(i);
|
||||
|
||||
@@ -55,7 +55,12 @@ public abstract class ItemView<T extends InventoryItem> {
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
return onScrollerTap(x, y, count);
|
||||
return ItemView.this.tap(x, y, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean zoom(float x, float y, float amount) {
|
||||
return ItemView.this.zoom(x, y, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +69,10 @@ public abstract class ItemView<T extends InventoryItem> {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean onScrollerTap(float x, float y, int count) {
|
||||
protected boolean tap(float x, float y, int count) {
|
||||
return false;
|
||||
}
|
||||
protected boolean zoom(float x, float y, float amount) {
|
||||
return false;
|
||||
}
|
||||
protected abstract float getScrollHeight();
|
||||
|
||||
Reference in New Issue
Block a user