icons + fix init zoom of image viewer
authorNiki Roo <niki@nikiroo.be>
Mon, 4 May 2020 19:32:38 +0000 (21:32 +0200)
committerNiki Roo <niki@nikiroo.be>
Mon, 4 May 2020 19:32:38 +0000 (21:32 +0200)
src/be/nikiroo/fanfix_swing/gui/utils/WaitingDialogMeta.java
src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java
src/be/nikiroo/fanfix_swing/gui/viewer/ViewerNonImages.java

index afda56845d6b0f31a26c19fdb02a4ae8efa31a74..2d7f5ee793b5320156964dd562cde72d0fafd362 100644 (file)
@@ -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);
        }
 }
index 04a9e764e4ca217bff812c3121b348969b803015..5834c86a11e633309066c641e716d6237d024881 100644 (file)
@@ -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() {
index 9f128fe374df0ad9c49f8525fc6fb2d9bc4d030d..56015abca5ce1a462e93163c4deb42468c91578e 100644 (file)
@@ -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());
        }
 
        /**