mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Added "transform on click" capability to card picture and detail.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 579 KiB After Width: | Height: | Size: 585 KiB |
@@ -51,7 +51,7 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
||||
// private JLabel label;
|
||||
// private ImageIcon icon;
|
||||
private final ScaledImagePanel panel;
|
||||
private Image currentImange;
|
||||
private Image currentImage;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -82,6 +82,8 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
this.setCard(c);
|
||||
}
|
||||
|
||||
@@ -118,7 +120,8 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
||||
this.setImage();
|
||||
}
|
||||
|
||||
private void setImage() {
|
||||
/** */
|
||||
public void setImage() {
|
||||
final Insets i = this.getInsets();
|
||||
Image image = null;
|
||||
if (this.inventoryItem != null) {
|
||||
@@ -130,8 +133,8 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
||||
- i.bottom - 2);
|
||||
}
|
||||
|
||||
if (image != this.currentImange) {
|
||||
this.currentImange = image;
|
||||
if (image != this.currentImage) {
|
||||
this.currentImage = image;
|
||||
this.panel.setImage(image, null);
|
||||
this.panel.repaint();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
package forge.gui.match.controllers;
|
||||
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Command;
|
||||
import forge.gui.framework.ICDoc;
|
||||
@@ -41,7 +44,9 @@ public enum CDetail implements ICDoc {
|
||||
*/
|
||||
public void showCard(final Card c) {
|
||||
this.currentCard = c;
|
||||
VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(c.isDoubleFaced() ? true : false);
|
||||
VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(c);
|
||||
VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,6 +71,14 @@ public enum CDetail implements ICDoc {
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
VDetail.SINGLETON_INSTANCE.getPnlDetail().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(final MouseEvent e) {
|
||||
if (VDetail.SINGLETON_INSTANCE.getPnlDetail().getCard().isDoubleFaced()) {
|
||||
CPicture.SINGLETON_INSTANCE.flipCard();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -16,7 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.gui.match.controllers;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardCharactersticName;
|
||||
import forge.Command;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.match.views.VPicture;
|
||||
@@ -31,6 +35,7 @@ public enum CPicture implements ICDoc {
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private Card currentCard = null;
|
||||
private boolean flipped = false;
|
||||
|
||||
/**
|
||||
* Shows card details and/or picture in sidebar cardview tabber.
|
||||
@@ -40,6 +45,7 @@ public enum CPicture implements ICDoc {
|
||||
*/
|
||||
public void showCard(final Card c) {
|
||||
this.currentCard = c;
|
||||
VPicture.SINGLETON_INSTANCE.getLblFlipcard().setVisible(c.isDoubleFaced() ? true : false);
|
||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(c);
|
||||
}
|
||||
|
||||
@@ -65,6 +71,14 @@ public enum CPicture implements ICDoc {
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(final MouseEvent e) {
|
||||
if (VPicture.SINGLETON_INSTANCE.getPnlPicture().getCard().isDoubleFaced()) {
|
||||
flipCard();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -73,4 +87,19 @@ public enum CPicture implements ICDoc {
|
||||
@Override
|
||||
public void update() {
|
||||
}
|
||||
|
||||
/** */
|
||||
public void flipCard() {
|
||||
if (flipped) {
|
||||
flipped = false;
|
||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().getCard().setState(CardCharactersticName.Original);
|
||||
CDetail.SINGLETON_INSTANCE.showCard(this.currentCard);
|
||||
}
|
||||
else {
|
||||
flipped = true;
|
||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().getCard().setState(CardCharactersticName.Transformed);
|
||||
CDetail.SINGLETON_INSTANCE.showCard(this.currentCard);
|
||||
}
|
||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().setImage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package forge.gui.match.views;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.framework.DragCell;
|
||||
@@ -25,6 +27,7 @@ import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.gui.match.controllers.CDetail;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of card detail area.
|
||||
@@ -41,6 +44,8 @@ public enum VDetail implements IVDoc {
|
||||
|
||||
// Top-level containers
|
||||
private final CardDetailPanel pnlDetail = new CardDetailPanel(null);
|
||||
private final JLabel lblFlipcard = new JLabel(
|
||||
FSkin.getIcon(FSkin.InterfaceIcons.ICO_FLIPCARD));
|
||||
|
||||
//========= Overridden methods
|
||||
/* (non-Javadoc)
|
||||
@@ -48,7 +53,8 @@ public enum VDetail implements IVDoc {
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
parentCell.getBody().setLayout(new MigLayout("insets 0, gap 0"));
|
||||
parentCell.getBody().setLayout(new MigLayout("insets 0, gap 0, center"));
|
||||
parentCell.getBody().add(lblFlipcard, "pos (50% - 40px) (50% - 60px)");
|
||||
parentCell.getBody().add(pnlDetail, "w 100%!, h 100%!");
|
||||
}
|
||||
|
||||
@@ -98,4 +104,9 @@ public enum VDetail implements IVDoc {
|
||||
public CardDetailPanel getPnlDetail() {
|
||||
return pnlDetail;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JLabel} */
|
||||
public JLabel getLblFlipcard() {
|
||||
return lblFlipcard;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package forge.gui.match.views;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.gui.framework.DragCell;
|
||||
@@ -25,6 +27,7 @@ import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.gui.match.controllers.CPicture;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of card picture area.
|
||||
@@ -41,10 +44,13 @@ public enum VPicture implements IVDoc {
|
||||
|
||||
// Top-level containers
|
||||
private final CardPicturePanel pnlPicture = new CardPicturePanel(null);
|
||||
private final JLabel lblFlipcard = new JLabel(
|
||||
FSkin.getIcon(FSkin.InterfaceIcons.ICO_FLIPCARD));
|
||||
|
||||
//========= Constructor
|
||||
private VPicture() {
|
||||
pnlPicture.setOpaque(false);
|
||||
lblFlipcard.setVisible(false);
|
||||
}
|
||||
|
||||
//========== Overridden methods
|
||||
@@ -55,6 +61,7 @@ public enum VPicture implements IVDoc {
|
||||
@Override
|
||||
public void populate() {
|
||||
parentCell.getBody().setLayout(new MigLayout("insets 0, gap 0, center"));
|
||||
parentCell.getBody().add(lblFlipcard, "pos (50% - 40px) (50% - 60px)");
|
||||
parentCell.getBody().add(pnlPicture, "w 100%!, h 100%!");
|
||||
}
|
||||
|
||||
@@ -104,4 +111,9 @@ public enum VPicture implements IVDoc {
|
||||
public CardPicturePanel getPnlPicture() {
|
||||
return pnlPicture;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JLabel} */
|
||||
public JLabel getLblFlipcard() {
|
||||
return lblFlipcard;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,6 +273,7 @@ public enum FSkin {
|
||||
ICO_SAVEAS (new int[] {660, 580, 20, 20}), /** */
|
||||
ICO_UNKNOWN (new int[] {0, 720, 80, 80}), /** */
|
||||
ICO_LOGO (new int[] {480, 0, 200, 200}), /** */
|
||||
ICO_FLIPCARD (new int[] {400, 0, 80, 120}), /** */
|
||||
ICO_FAVICON (new int[] {0, 640, 80, 80});
|
||||
|
||||
private int[] coords;
|
||||
|
||||
Reference in New Issue
Block a user