From b02c7819a6dcc0d62a0e9135d439f9352f5c80ce Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Tue, 16 Apr 2019 19:12:50 +0200 Subject: [PATCH] GUI: fix keyboard up/down in lib --- .../reader/ui/GuiReaderCoverImager.java | 23 ++++++++++++++++--- .../fanfix/reader/ui/GuiReaderGroup.java | 11 +++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java index 0bbf82eb..f46ec1bb 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderCoverImager.java @@ -129,6 +129,24 @@ class GuiReaderCoverImager { return generateCoverIcon(lib, GuiReaderBookInfo.fromMeta(meta)); } + /** + * The width of a cover image. + * + * @return the width + */ + static public int getCoverWidth() { + return SPINE_WIDTH + COVER_WIDTH; + } + + /** + * The height of a cover image. + * + * @return the height + */ + static public int getCoverHeight() { + return COVER_HEIGHT + HOFFSET; + } + /** * Generate a cover icon based upon the given {@link GuiReaderBookInfo}. * @@ -158,9 +176,8 @@ class GuiReaderCoverImager { if (resizedImage == null) { try { Image cover = info.getBaseImage(lib); - resizedImage = new BufferedImage(SPINE_WIDTH + COVER_WIDTH, - SPINE_HEIGHT + COVER_HEIGHT + HOFFSET, - BufferedImage.TYPE_4BYTE_ABGR); + resizedImage = new BufferedImage(getCoverWidth(), + getCoverHeight(), BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g = resizedImage.createGraphics(); try { diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java index 7b154256..17bf43cb 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java @@ -179,8 +179,13 @@ public class GuiReaderGroup extends JPanel { * up/down one line at a time. */ private void computeItemsPerLine() { - // TODO - itemsPerLine = 5; + itemsPerLine = 1; + + if (books != null && books.size() > 0) { + // this.pane holds all the books with a hgap of 5 px + int wbook = books.get(0).getWidth() + 5; + itemsPerLine = pane.getWidth() / wbook; + } } /** @@ -270,6 +275,8 @@ public class GuiReaderGroup extends JPanel { pane.repaint(); validate(); repaint(); + + computeItemsPerLine(); } /** -- 2.27.0