X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderGroup.java;h=7275498ff3d9c6079907886c07d092ae80adad1e;hb=67837328c9ded45b23691e2a3ebdb29c75f157f2;hp=7b15425682b96e363df67c66d7a87ac7be35da9d;hpb=ed8cda22e3c10ae5a9de890547d39bb143f44983;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java index 7b15425..7275498 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; + } } /** @@ -192,6 +197,33 @@ public class GuiReaderGroup extends JPanel { */ public void setActionListener(BookActionListener action) { this.action = action; + refreshBooks(); + } + + /** + * Clear all the books in this {@link GuiReaderGroup}. + */ + public void clear() { + refreshBooks(new ArrayList()); + } + + /** + * Refresh the list of {@link GuiReaderBook}s displayed in the control. + * + * @param infos + * the new list of infos + */ + public void refreshBooks() { + refreshBooks(infos, words); + } + + /** + * Refresh the list of {@link GuiReaderBook}s displayed in the control. + * + * @param infos + * the new list of infos + */ + public void refreshBooks(List infos) { refreshBooks(infos, words); } @@ -270,6 +302,8 @@ public class GuiReaderGroup extends JPanel { pane.repaint(); validate(); repaint(); + + computeItemsPerLine(); } /** @@ -328,7 +362,7 @@ public class GuiReaderGroup extends JPanel { * @param index * the index of the book to select, can be outside the bounds * (either all the items will be unselected or the first or last - * book will then be selected, see forceRange>/tt>) + * book will then be selected, see forceRange>) * @param forceRange * TRUE to constraint the index to the first/last element, FALSE * to unselect when outside the range