X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FTuiReaderStoryWindow.java;h=7eb592fd4686666a6237d4787243e2dd55ab1711;hb=f63c426775be9ab82d893c90993d46b375d115ff;hp=c942624bc4adc6de296386f9e3fd3549b6f876b6;hpb=0861d62ac01062a3cd20624cdd6a826df284695e;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java b/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java index c942624..7eb592f 100644 --- a/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java +++ b/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java @@ -9,7 +9,7 @@ import jexer.TButton; import jexer.TCommand; import jexer.TKeypress; import jexer.TLabel; -import jexer.TText2; +import jexer.TText; import jexer.TWindow; import jexer.event.TResizeEvent; import be.nikiroo.fanfix.Instance; @@ -21,7 +21,7 @@ import be.nikiroo.fanfix.data.Story; public class TuiReaderStoryWindow extends TWindow { private MetaData meta; private Story story; - private TText2 textField; + private TText textField; private int chapter = -2; private List navigationButtons; private TLabel chapterName; @@ -36,17 +36,17 @@ public class TuiReaderStoryWindow extends TWindow { // TODO: show all meta info before? - textField = new TText2(this, "", 0, 0, getWidth() - 2, getHeight() - 2); + textField = new TText(this, "", 0, 0, getWidth() - 2, getHeight() - 2); statusBar = newStatusBar(desc(meta)); statusBar.addShortcutKeypress(TKeypress.kbF10, TCommand.cmExit, "Exit"); - navigationButtons = new ArrayList(4); + navigationButtons = new ArrayList(5); // -3 because 0-based and 2 for borders int row = getHeight() - 3; - addButton(" ", 0, row, null); // for bg colour when << button is pressed + navigationButtons.add(addButton(" ", 0, row, null)); // for bg colour when << button is pressed navigationButtons.add(addButton("<< ", 0, row, new TAction() { public void DO() { setChapter(0); @@ -67,6 +67,10 @@ public class TuiReaderStoryWindow extends TWindow { setChapter(getStory().getChapters().size()); } })); + + navigationButtons.get(0).setEnabled(false); + navigationButtons.get(1).setEnabled(false); + navigationButtons.get(2).setEnabled(false); chapterName = addLabel("", 14, row); chapterName.setWidth(getWidth() - 10); @@ -109,6 +113,14 @@ public class TuiReaderStoryWindow extends TWindow { if (chapter != this.chapter) { this.chapter = chapter; + + int max = getStory().getChapters().size(); + navigationButtons.get(0).setEnabled(chapter > 0); + navigationButtons.get(1).setEnabled(chapter > 0); + navigationButtons.get(2).setEnabled(chapter > 0); + navigationButtons.get(3).setEnabled(chapter < max); + navigationButtons.get(4).setEnabled(chapter < max); + Chapter chap; String name; if (chapter == 0) { @@ -116,8 +128,7 @@ public class TuiReaderStoryWindow extends TWindow { name = String.format(" %s", chap.getName()); } else { chap = getStory().getChapters().get(chapter - 1); - name = String.format(" %d/%d: %s", chapter, getStory() - .getChapters().size(), chap.getName()); + name = String.format(" %d/%d: %s", chapter, max, chap.getName()); } while (name.length() < getWidth() - chapterName.getX()) { @@ -139,6 +150,7 @@ public class TuiReaderStoryWindow extends TWindow { } textField.setText(builder.toString()); textField.reflow(); + textField.toTop(); } }