[UI] Fixed wrong card position on d'n'd with small moves

This commit is contained in:
magenoxx 2014-07-14 13:30:02 +04:00
parent b6e0544c95
commit 43a31f6d98

View file

@ -48,7 +48,7 @@ public class MageActionCallback implements ActionCallback {
public static final int GAP_X = 5; public static final int GAP_X = 5;
public static final double COMPARE_GAP_X = 30; public static final double COMPARE_GAP_X = 30;
public static final int GO_DOWN_ON_DRAG_Y_OFFSET = 0; public static final int GO_DOWN_ON_DRAG_Y_OFFSET = 0;
public static final int MIN_X_OFFSET_REQUIRED = 25; public static final int MIN_X_OFFSET_REQUIRED = 20;
private Popup popup; private Popup popup;
private JPopupMenu jPopupMenu; private JPopupMenu jPopupMenu;
@ -219,18 +219,19 @@ public class MageActionCallback implements ActionCallback {
maxXOffset = Math.abs((int) (mouse.getX() - initialMousePos.x) - xOffset); maxXOffset = Math.abs((int) (mouse.getX() - initialMousePos.x) - xOffset);
} }
if (maxXOffset > MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements
CardPanel card = ((CardPanel)transferData.component); CardPanel card = ((CardPanel)transferData.component);
for (Component component : card.getCardArea().getComponents()) { for (Component component : card.getCardArea().getComponents()) {
if (component instanceof CardPanel) { if (component instanceof CardPanel) {
if (cardPanels.contains(component)) { if (cardPanels.contains(component)) {
component.setLocation(component.getLocation().x, component.getLocation().y - GO_DOWN_ON_DRAG_Y_OFFSET); component.setLocation(component.getLocation().x, component.getLocation().y - GO_DOWN_ON_DRAG_Y_OFFSET);
}
} }
} }
sort(card, card.getCardArea(), true); }
cardPanels.clear(); sort(card, card.getCardArea(), true);
} else { cardPanels.clear();
if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements
transferData.component.requestFocusInWindow(); transferData.component.requestFocusInWindow();
defaultCallback.mouseClicked(e, transferData.gameId, session, transferData.card); defaultCallback.mouseClicked(e, transferData.gameId, session, transferData.card);
// Closes popup & enlarged view if a card/Permanent is selected // Closes popup & enlarged view if a card/Permanent is selected