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