From: Niki Roo Date: Mon, 4 May 2020 19:32:38 +0000 (+0200) Subject: icons + fix init zoom of image viewer X-Git-Tag: fanfix-swing-1.2.0~12 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=3cac410aae3b7a10cbfcd6c620c3d1a7abfa02aa;p=fanfix-swing.git icons + fix init zoom of image viewer --- diff --git a/src/be/nikiroo/fanfix_swing/gui/utils/WaitingDialogMeta.java b/src/be/nikiroo/fanfix_swing/gui/utils/WaitingDialogMeta.java index afda5684..2d7f5ee7 100644 --- a/src/be/nikiroo/fanfix_swing/gui/utils/WaitingDialogMeta.java +++ b/src/be/nikiroo/fanfix_swing/gui/utils/WaitingDialogMeta.java @@ -7,6 +7,7 @@ import java.awt.Window; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.SwingWorker; +import javax.swing.border.EmptyBorder; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.library.BasicLibrary; @@ -61,11 +62,14 @@ public class WaitingDialogMeta extends WaitingDialog { this.setLayout(new BorderLayout()); this.setTitle(meta.getTitle()); - this.add(new JLabel("Waiting for " + meta.getTitle() + "..."), - BorderLayout.NORTH); + JLabel waitingTextLabel = new JLabel("Waiting for " + meta.getTitle() + "..."); + waitingTextLabel.setHorizontalAlignment(JLabel.CENTER); + waitingTextLabel.setBorder(new EmptyBorder(30, 10, 10, 10)); + this.add(waitingTextLabel, BorderLayout.NORTH); imgLabel = new JLabel(); imgLabel.setPreferredSize(new Dimension(CoverImager.getCoverWidth(), CoverImager.getCoverHeight())); + imgLabel.setHorizontalAlignment(JLabel.CENTER); this.add(imgLabel, BorderLayout.CENTER); // Image @@ -85,6 +89,7 @@ public class WaitingDialogMeta extends WaitingDialog { } }.execute(); + UiHelper.setFrameIcon(this, lib, meta); this.setSize(400, 300); } } diff --git a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java index 04a9e764..5834c86a 100644 --- a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java +++ b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java @@ -30,6 +30,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JToolBar; +import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import be.nikiroo.fanfix.Instance; @@ -154,11 +155,17 @@ public class ViewerImages extends JFrame { worker.start(); initGui(); - display(index, Rotation.NONE, true); - if (!images.isEmpty()) { - UiHelper.setFrameIcon(this, images.get(0)); - } + // The first part of display() needs the scroll to be positioned + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // ...now it is + display(index, Rotation.NONE, true); + } + }); + + UiHelper.setFrameIcon(this, images.isEmpty() ? null : images.get(0)); } private void initGui() { diff --git a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerNonImages.java b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerNonImages.java index 9f128fe3..56015abc 100644 --- a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerNonImages.java +++ b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerNonImages.java @@ -2,7 +2,6 @@ package be.nikiroo.fanfix_swing.gui.viewer; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Dimension; import java.awt.Font; import java.awt.Rectangle; import java.awt.event.ActionEvent; @@ -51,7 +50,6 @@ public class ViewerNonImages extends JFrame { private NavBar navbar; private JLabel title; private JScrollPane scroll; - private JPanel mainPane; private JEditorPane area; private JPanel descPane; @@ -82,7 +80,7 @@ public class ViewerNonImages extends JFrame { initGui(lib); setChapter(0); - UiHelper.setFrameIcon(this); + UiHelper.setFrameIcon(this, lib, story.getMeta()); } /**