fix: Pressing F5 in the carousel preview will reload the content.
Small bugfix for showing the border for the selected game properly when the dialog is opened.
This commit is contained in:
parent
bbc4d2fbb3
commit
1690fa3c55
|
@ -1,13 +1,17 @@
|
||||||
package se.lantz.gui.carousel;
|
package se.lantz.gui.carousel;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Frame;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.beans.Beans;
|
import java.beans.Beans;
|
||||||
|
|
||||||
|
import javax.swing.AbstractAction;
|
||||||
|
import javax.swing.Action;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import se.lantz.gui.BaseDialog;
|
import se.lantz.gui.BaseDialog;
|
||||||
import se.lantz.gui.MainWindow;
|
import se.lantz.gui.MainWindow;
|
||||||
|
@ -16,12 +20,24 @@ import se.lantz.model.carousel.CarouselPreviewModel;
|
||||||
|
|
||||||
public class CarouselPreviewDialog extends BaseDialog
|
public class CarouselPreviewDialog extends BaseDialog
|
||||||
{
|
{
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CarouselPreviewDialog.class);
|
||||||
|
|
||||||
private BackgroundPanel panel;
|
private BackgroundPanel panel;
|
||||||
private MainViewModel uiModel;
|
private MainViewModel uiModel;
|
||||||
private MainWindow mainWindow;
|
private MainWindow mainWindow;
|
||||||
private CarouselPreviewModel model;
|
private CarouselPreviewModel model;
|
||||||
private JButton runGameButton;
|
private JButton runGameButton;
|
||||||
|
|
||||||
|
private Action reloadAction = new AbstractAction()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
logger.debug("Reloading carousel");
|
||||||
|
model.reloadCarousel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public CarouselPreviewDialog(final MainWindow owner, final MainViewModel uiModel)
|
public CarouselPreviewDialog(final MainWindow owner, final MainViewModel uiModel)
|
||||||
{
|
{
|
||||||
super(owner);
|
super(owner);
|
||||||
|
@ -34,6 +50,9 @@ public class CarouselPreviewDialog extends BaseDialog
|
||||||
addContent(getBackgroundPanel());
|
addContent(getBackgroundPanel());
|
||||||
getButtonPanel().setVisible(false);
|
getButtonPanel().setVisible(false);
|
||||||
|
|
||||||
|
getBackgroundPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F5"), "reload");
|
||||||
|
getBackgroundPanel().getActionMap().put("reload", reloadAction);
|
||||||
|
|
||||||
if (!Beans.isDesignTime())
|
if (!Beans.isDesignTime())
|
||||||
{
|
{
|
||||||
uiModel.addPropertyChangeListener("selectedGamelistView", e -> modelChanged());
|
uiModel.addPropertyChangeListener("selectedGamelistView", e -> modelChanged());
|
||||||
|
|
|
@ -72,7 +72,6 @@ public class CoverPanel extends JPanel
|
||||||
{
|
{
|
||||||
model.addPropertyChangeListener(CarouselPreviewModel.SELECTED_GAME, e -> {
|
model.addPropertyChangeListener(CarouselPreviewModel.SELECTED_GAME, e -> {
|
||||||
reloadScreens();
|
reloadScreens();
|
||||||
updateSelectedBorder();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
model.addPropertyChangeListener(CarouselPreviewModel.CLEAR_SELECTION, e -> {
|
model.addPropertyChangeListener(CarouselPreviewModel.CLEAR_SELECTION, e -> {
|
||||||
|
@ -246,6 +245,7 @@ public class CoverPanel extends JPanel
|
||||||
}
|
}
|
||||||
scrollToPosition();
|
scrollToPosition();
|
||||||
panel.setVisible(true);
|
panel.setVisible(true);
|
||||||
|
updateSelectedBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSelectedBorder()
|
private void updateSelectedBorder()
|
||||||
|
@ -301,8 +301,7 @@ public class CoverPanel extends JPanel
|
||||||
{
|
{
|
||||||
BufferedImage image = ImageIO.read(imagefile);
|
BufferedImage image = ImageIO.read(imagefile);
|
||||||
Image newImage = image.getScaledInstance(125, 175, Image.SCALE_SMOOTH);
|
Image newImage = image.getScaledInstance(125, 175, Image.SCALE_SMOOTH);
|
||||||
BufferedImage copyOfImage =
|
BufferedImage copyOfImage = new BufferedImage(125, 175, BufferedImage.TYPE_INT_ARGB);
|
||||||
new BufferedImage(125, 175, BufferedImage.TYPE_INT_ARGB);
|
|
||||||
Graphics g = copyOfImage.createGraphics();
|
Graphics g = copyOfImage.createGraphics();
|
||||||
g.drawImage(newImage, 0, 0, null);
|
g.drawImage(newImage, 0, 0, null);
|
||||||
label.setIcon(new ImageIcon(copyOfImage.getSubimage(5, 5, 115, 165)));
|
label.setIcon(new ImageIcon(copyOfImage.getSubimage(5, 5, 115, 165)));
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class CarouselPreviewModel extends AbstractModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadCarousel()
|
public void reloadCarousel()
|
||||||
{
|
{
|
||||||
logger.debug("RELOAD carousel in preview");
|
logger.debug("RELOAD carousel in preview");
|
||||||
if (mainModel.getCurrentGameViewGameCount() < 10)
|
if (mainModel.getCurrentGameViewGameCount() < 10)
|
||||||
|
|
Loading…
Reference in New Issue