1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 01:39:18 +02:00

2-column view: fixed end-of-section processing, fixed backward scrolling

This commit is contained in:
Nikolay Pultsin 2013-04-29 02:27:19 +02:00
parent 669bb2f64e
commit e768973294
2 changed files with 26 additions and 19 deletions

View file

@ -1,8 +1,3 @@
* FIRST RELEASE
** fix end-of-section processing
** backward scrolling
* OPTIONAL
** 3d animation ** 3d animation
** "half page turning" ** "half page turning"
** footer/header ** footer/header

View file

@ -846,7 +846,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
int textAreaHeight = getTextAreaHeight(); int textAreaHeight = getTextAreaHeight();
page.LineInfos.clear(); page.LineInfos.clear();
page.Column0Height = 0; page.Column0Height = 0;
int columnCounter = 0; boolean nextParagraph;
do { do {
resetTextStyle(); resetTextStyle();
final ZLTextParagraphCursor paragraphCursor = result.getParagraphCursor(); final ZLTextParagraphCursor paragraphCursor = result.getParagraphCursor();
@ -858,8 +858,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
info = processTextLine(paragraphCursor, info.EndElementIndex, info.EndCharIndex, endIndex); info = processTextLine(paragraphCursor, info.EndElementIndex, info.EndCharIndex, endIndex);
textAreaHeight -= info.Height + info.Descent; textAreaHeight -= info.Height + info.Descent;
if (textAreaHeight < 0 && page.LineInfos.size() > page.Column0Height) { if (textAreaHeight < 0 && page.LineInfos.size() > page.Column0Height) {
if (columnCounter == 0 && page.twoColumnView()) { if (page.Column0Height == 0 && page.twoColumnView()) {
++columnCounter;
textAreaHeight = getTextAreaHeight(); textAreaHeight = getTextAreaHeight();
textAreaHeight -= info.Height + info.Descent; textAreaHeight -= info.Height + info.Descent;
page.Column0Height = page.LineInfos.size(); page.Column0Height = page.LineInfos.size();
@ -871,8 +870,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
result.moveTo(info.EndElementIndex, info.EndCharIndex); result.moveTo(info.EndElementIndex, info.EndCharIndex);
page.LineInfos.add(info); page.LineInfos.add(info);
if (textAreaHeight < 0) { if (textAreaHeight < 0) {
if (columnCounter == 0) { if (page.Column0Height == 0 && page.twoColumnView()) {
++columnCounter;
textAreaHeight = getTextAreaHeight(); textAreaHeight = getTextAreaHeight();
page.Column0Height = page.LineInfos.size(); page.Column0Height = page.LineInfos.size();
} else { } else {
@ -880,10 +878,16 @@ public abstract class ZLTextView extends ZLTextViewBase {
} }
} }
} }
} while (result.isEndOfParagraph() && result.nextParagraph() && textAreaHeight >= 0 && nextParagraph = result.isEndOfParagraph() && result.nextParagraph();
if (nextParagraph && result.getParagraphCursor().isEndOfSection()) {
if (page.Column0Height == 0 && page.twoColumnView() && !page.LineInfos.isEmpty()) {
textAreaHeight = getTextAreaHeight();
page.Column0Height = page.LineInfos.size();
}
}
} while (nextParagraph && textAreaHeight >= 0 &&
(!result.getParagraphCursor().isEndOfSection() || (!result.getParagraphCursor().isEndOfSection() ||
(page.twoColumnView() && page.LineInfos.size() == page.Column0Height) page.LineInfos.size() == page.Column0Height)
)
); );
resetTextStyle(); resetTextStyle();
} }
@ -1299,7 +1303,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
if (!page.StartCursor.isStartOfText()) { if (!page.StartCursor.isStartOfText()) {
switch (myScrollingMode) { switch (myScrollingMode) {
case ScrollingMode.NO_OVERLAPPING: case ScrollingMode.NO_OVERLAPPING:
page.StartCursor.setCursor(findStart(page.StartCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight())); page.StartCursor.setCursor(findStartOfPrevousPage(page.StartCursor));
break; break;
case ScrollingMode.KEEP_LINES: case ScrollingMode.KEEP_LINES:
{ {
@ -1309,14 +1313,14 @@ public abstract class ZLTextView extends ZLTextViewBase {
page.findLineFromEnd(endCursor, 1); page.findLineFromEnd(endCursor, 1);
} }
if (!endCursor.isNull()) { if (!endCursor.isNull()) {
ZLTextWordCursor startCursor = findStart(endCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight()); ZLTextWordCursor startCursor = findStartOfPrevousPage(endCursor);
if (startCursor.samePositionAs(page.StartCursor)) { if (startCursor.samePositionAs(page.StartCursor)) {
page.StartCursor.setCursor(findStart(page.StartCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight())); page.StartCursor.setCursor(findStartOfPrevousPage(page.StartCursor));
} else { } else {
page.StartCursor.setCursor(startCursor); page.StartCursor.setCursor(startCursor);
} }
} else { } else {
page.StartCursor.setCursor(findStart(page.StartCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight())); page.StartCursor.setCursor(findStartOfPrevousPage(page.StartCursor));
} }
break; break;
} }
@ -1338,7 +1342,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
buildInfos(page, page.StartCursor, page.EndCursor); buildInfos(page, page.StartCursor, page.EndCursor);
break; break;
case PaintStateEnum.END_IS_KNOWN: case PaintStateEnum.END_IS_KNOWN:
page.StartCursor.setCursor(findStart(page.EndCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight())); page.StartCursor.setCursor(findStartOfPrevousPage(page.EndCursor));
buildInfos(page, page.StartCursor, page.EndCursor); buildInfos(page, page.StartCursor, page.EndCursor);
break; break;
} }
@ -1429,6 +1433,14 @@ public abstract class ZLTextView extends ZLTextViewBase {
} }
} }
private ZLTextWordCursor findStartOfPrevousPage(ZLTextWordCursor end) {
if (twoColumnView()) {
end = findStart(end, SizeUnit.PIXEL_UNIT, getTextAreaHeight());
}
end = findStart(end, SizeUnit.PIXEL_UNIT, getTextAreaHeight());
return end;
}
private ZLTextWordCursor findStart(ZLTextWordCursor end, int unit, int size) { private ZLTextWordCursor findStart(ZLTextWordCursor end, int unit, int size) {
final ZLTextWordCursor start = new ZLTextWordCursor(end); final ZLTextWordCursor start = new ZLTextWordCursor(end);
size -= paragraphSize(start, true, unit); size -= paragraphSize(start, true, unit);
@ -1451,7 +1463,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
if (unit == SizeUnit.PIXEL_UNIT) { if (unit == SizeUnit.PIXEL_UNIT) {
boolean sameStart = start.samePositionAs(end); boolean sameStart = start.samePositionAs(end);
if (!sameStart && start.isEndOfParagraph() && end.isStartOfParagraph()) { if (!sameStart && start.isEndOfParagraph() && end.isStartOfParagraph()) {
ZLTextWordCursor startCopy = start; ZLTextWordCursor startCopy = new ZLTextWordCursor(start);
startCopy.nextParagraph(); startCopy.nextParagraph();
sameStart = startCopy.samePositionAs(end); sameStart = startCopy.samePositionAs(end);
} }