git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move TSizeConstraint into new package
[fanfix.git]
/
src
/
be
/
nikiroo
/
fanfix
/
reader
/
tui
/
TuiReaderStoryWindow.java
diff --git
a/src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java
b/src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java
index ddf7ad13d98e35a0d47e1984881067aa44131c8b..6ab92347420ddd7ee9d80fa934e8ceed8f88b1b2 100644
(file)
--- a/
src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java
+++ b/
src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java
@@
-10,7
+10,6
@@
import java.util.List;
import jexer.TAction;
import jexer.TButton;
import jexer.TLabel;
import jexer.TAction;
import jexer.TButton;
import jexer.TLabel;
-import jexer.TTable;
import jexer.TText;
import jexer.TWindow;
import jexer.event.TCommandEvent;
import jexer.TText;
import jexer.TWindow;
import jexer.event.TCommandEvent;
@@
-20,6
+19,8
@@
import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Paragraph;
import be.nikiroo.fanfix.data.Paragraph.ParagraphType;
import be.nikiroo.fanfix.data.Story;
import be.nikiroo.fanfix.data.Paragraph;
import be.nikiroo.fanfix.data.Paragraph.ParagraphType;
import be.nikiroo.fanfix.data.Story;
+import be.nikiroo.jexer.TSizeConstraint;
+import be.nikiroo.jexer.TTable;
import be.nikiroo.utils.StringUtils;
/**
import be.nikiroo.utils.StringUtils;
/**
@@
-57,27
+58,25
@@
class TuiReaderStoryWindow extends TWindow {
navigationButtons = new ArrayList<TButton>(5);
navigationButtons = new ArrayList<TButton>(5);
- // for bg colour when << button is pressed
- navigationButtons.add(addButton(" ", 0, 0, null));
- navigationButtons.add(addButton("<< ", 0, 0, new TAction() {
+ navigationButtons.add(addButton("<<", 0, 0, new TAction() {
@Override
public void DO() {
setChapter(-1);
}
}));
@Override
public void DO() {
setChapter(-1);
}
}));
- navigationButtons.add(addButton("<
", 4, 0, new TAction() {
+ navigationButtons.add(addButton("< ", 4, 0, new TAction() {
@Override
public void DO() {
setChapter(TuiReaderStoryWindow.this.chapter - 1);
}
}));
@Override
public void DO() {
setChapter(TuiReaderStoryWindow.this.chapter - 1);
}
}));
- navigationButtons.add(addButton(">
", 7, 0, new TAction() {
+ navigationButtons.add(addButton("> ", 7, 0, new TAction() {
@Override
public void DO() {
setChapter(TuiReaderStoryWindow.this.chapter + 1);
}
}));
@Override
public void DO() {
setChapter(TuiReaderStoryWindow.this.chapter + 1);
}
}));
- navigationButtons.add(addButton(">>
", 10, 0, new TAction() {
+ navigationButtons.add(addButton(">>", 10, 0, new TAction() {
@Override
public void DO() {
setChapter(getStory().getChapters().size());
@Override
public void DO() {
setChapter(getStory().getChapters().size());
@@
-86,16
+85,17
@@
class TuiReaderStoryWindow extends TWindow {
navigationButtons.get(0).setEnabled(false);
navigationButtons.get(1).setEnabled(false);
navigationButtons.get(0).setEnabled(false);
navigationButtons.get(1).setEnabled(false);
- navigationButtons.get(2).setEnabled(false);
currentChapter = addLabel("", 0, 0);
currentChapter = addLabel("", 0, 0);
- TSizeConstraint.setSize(sizeConstraints, textField, 1, 3, -1,
0
);
- TSizeConstraint.setSize(sizeConstraints, table, 0, 3, 0,
0
);
+ TSizeConstraint.setSize(sizeConstraints, textField, 1, 3, -1,
-1
);
+ TSizeConstraint.setSize(sizeConstraints, table, 0, 3, 0,
-1
);
TSizeConstraint.setSize(sizeConstraints, currentChapter, 14, -3, -1,
null);
for (TButton navigationButton : navigationButtons) {
TSizeConstraint.setSize(sizeConstraints, currentChapter, 14, -3, -1,
null);
for (TButton navigationButton : navigationButtons) {
+ navigationButton.setShadowColor(null);
+ // navigationButton.setEmptyBorders(false);
TSizeConstraint.setSize(sizeConstraints, navigationButton, null,
-3, null, null);
}
TSizeConstraint.setSize(sizeConstraints, navigationButton, null,
-3, null, null);
}
@@
-116,14
+116,13
@@
class TuiReaderStoryWindow extends TWindow {
TSizeConstraint.resize(sizeConstraints);
TSizeConstraint.resize(sizeConstraints);
- textField.getVerticalScroller().setX(
- textField.getVerticalScroller().getX() + 1);
+ // Improve the disposition of the scrollbars
+ textField.getVerticalScroller().setX(textField.getWidth());
+ textField.getVerticalScroller().setHeight(textField.getHeight());
+ textField.getHorizontalScroller().setX(-1);
+ textField.getHorizontalScroller().setWidth(textField.getWidth() + 1);
- String name = currentChapter.getLabel();
- int size = Math.max(name.length(), currentChapter.getWidth());
- name = String.format("%" + size + "s", name);
-
- currentChapter.setLabel(name);
+ setCurrentChapterText();
}
/**
}
/**
@@
-145,9
+144,8
@@
class TuiReaderStoryWindow extends TWindow {
int max = getStory().getChapters().size();
navigationButtons.get(0).setEnabled(chapter > -1);
navigationButtons.get(1).setEnabled(chapter > -1);
int max = getStory().getChapters().size();
navigationButtons.get(0).setEnabled(chapter > -1);
navigationButtons.get(1).setEnabled(chapter > -1);
- navigationButtons.get(2).setEnabled(chapter
> -1
);
+ navigationButtons.get(2).setEnabled(chapter
< max
);
navigationButtons.get(3).setEnabled(chapter < max);
navigationButtons.get(3).setEnabled(chapter < max);
- navigationButtons.get(4).setEnabled(chapter < max);
if (chapter < 0) {
displayInfoPage();
if (chapter < 0) {
displayInfoPage();
@@
-175,11
+173,24
@@
class TuiReaderStoryWindow extends TWindow {
setCurrentTitle(meta.getTitle());
setCurrentTitle(meta.getTitle());
+ StringBuilder tags = new StringBuilder();
+ for (String tag : meta.getTags()) {
+ if (tags.length() > 0) {
+ tags.append(", ");
+ }
+ tags.append(tag);
+ }
+
table.setRowData(new String[][] { //
new String[] { " Author", meta.getAuthor() }, //
new String[] { " Publication date", formatDate(meta.getDate()) },
table.setRowData(new String[][] { //
new String[] { " Author", meta.getAuthor() }, //
new String[] { " Publication date", formatDate(meta.getDate()) },
+ new String[] { " Published on", meta.getPublisher() },
+ new String[] { " URL", meta.getUrl() },
new String[] { " Word count", format(meta.getWords()) },
new String[] { " Word count", format(meta.getWords()) },
- new String[] { " Source", meta.getSource() } //
+ new String[] { " Source", meta.getSource() },
+ new String[] { " Subject", meta.getSubject() },
+ new String[] { " Language", meta.getLang() },
+ new String[] { " Tags", tags.toString() } //
});
table.setHeaders(Arrays.asList("key", "value"), false);
table.toTop();
});
table.setHeaders(Arrays.asList("key", "value"), false);
table.toTop();
@@
-303,10
+314,7
@@
class TuiReaderStoryWindow extends TWindow {
}
int width = getWidth() - currentChapter.getX();
}
int width = getWidth() - currentChapter.getX();
- while (name.length() < width) {
- name += " ";
- }
-
+ name = String.format("%-" + width + "s", name);
if (name.length() > width) {
name = name.substring(0, width);
}
if (name.length() > width) {
name = name.substring(0, width);
}