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

hide link border after visiting

This commit is contained in:
Nikolay Pultsin 2011-04-02 22:57:21 +01:00
parent 01594d8cf9
commit c147a8cf87
3 changed files with 77 additions and 43 deletions

View file

@ -53,6 +53,8 @@ class ProcessHyperlinkAction extends FBAction {
public void run() {
final ZLTextElementRegion region = Reader.getTextView().getSelectedRegion();
if (region instanceof ZLTextHyperlinkRegion) {
Reader.getTextView().hideSelectedRegionBorder();
Reader.repaintView();
final ZLTextHyperlink hyperlink = ((ZLTextHyperlinkRegion)region).Hyperlink;
switch (hyperlink.Type) {
case FBHyperlinkType.EXTERNAL:
@ -67,8 +69,9 @@ class ProcessHyperlinkAction extends FBAction {
Reader.tryOpenFootnote(hyperlink.Id);
break;
}
return;
} else if (region instanceof ZLTextImageRegion) {
Reader.getTextView().hideSelectedRegionBorder();
Reader.repaintView();
final String uriString = ((ZLTextImageRegion)region).ImageElement.URI;
if (uriString != null) {
try {

View file

@ -328,7 +328,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
}
final ZLTextElementRegion selectedElementRegion = getCurrentElementRegion(page);
if (selectedElementRegion != null) {
if (selectedElementRegion != null && myHighlightSelectedRegion) {
selectedElementRegion.draw(context);
}
}
@ -1307,6 +1307,12 @@ public abstract class ZLTextView extends ZLTextViewBase {
}
private ZLTextElementRegion mySelectedRegion;
private boolean myHighlightSelectedRegion = true;
public void hideSelectedRegionBorder() {
System.err.println("set to false");
myHighlightSelectedRegion = false;
}
private ZLTextElementRegion getCurrentElementRegion(ZLTextPage page) {
final ArrayList<ZLTextElementRegion> elementRegions = page.TextElementMap.ElementRegions;
@ -1337,11 +1343,17 @@ public abstract class ZLTextView extends ZLTextViewBase {
}
protected void selectRegion(ZLTextElementRegion region) {
if (region == null || !region.equals(mySelectedRegion)) {
System.err.println("set to true 1");
myHighlightSelectedRegion = true;
}
mySelectedRegion = region;
}
public void resetRegionPointer() {
mySelectedRegion = null;
System.err.println("set to true 2");
myHighlightSelectedRegion = true;
}
protected ZLTextElementRegion currentRegion() {

View file

@ -145,7 +145,16 @@ class CurlAnimationProvider extends AnimationProvider {
y = Math.max(y, 4 * h / 5);
}
}
super.startAutoScrolling(forward, Math.abs(speed), direction, w, h, x, y);
if (x == null && y == null) {
if (direction.IsHorizontal) {
x = speed < 0 ? w - 3 : 3;
y = 1;
} else {
x = 1;
y = speed < 0 ? h - 3 : 3;
}
}
super.startAutoScrolling(forward, speed, direction, w, h, x, y);
}
@Override
@ -154,56 +163,66 @@ class CurlAnimationProvider extends AnimationProvider {
return;
}
final int cornerX = myStartX > myWidth / 2 ? myWidth : 0;
final int cornerY = myStartY > myHeight / 2 ? myHeight : 0;
final int speed = (int)mySpeed;
final int speed = (int)Math.abs(mySpeed);
mySpeed *= 1.5;
final int cornerX = myStartX > myWidth / 2 ? myWidth : 0;
final int cornerY = myStartY > myHeight / 2 ? myHeight : 0;
final int boundX, boundY;
final boolean xOver, yOver;
if (getMode() == Mode.AutoScrollingForward) {
if (cornerX == 0) {
myEndX += speed;
boundX = 2 * myWidth;
xOver = myEndX >= boundX;
} else {
myEndX -= speed;
boundX = - myWidth;
xOver = myEndX <= boundX;
}
if (cornerY == 0) {
myEndY += speed;
boundY = 2 * myHeight;
yOver = myEndY >= boundY;
} else {
myEndY -= speed;
boundY = - myHeight;
yOver = myEndY <= boundY;
}
boundX = cornerX == 0 ? 2 * myWidth : -myWidth;
boundY = cornerY == 0 ? 2 * myHeight : -myHeight;
} else {
boundX = cornerX;
boundY = cornerY;
if (cornerX == 0) {
myEndX -= speed;
xOver = myEndX <= boundX;
} else {
myEndX += speed;
xOver = myEndX >= boundX;
}
final int deltaX = Math.abs(myEndX - cornerX);
final int deltaY = Math.abs(myEndY - cornerY);
final int speedX, speedY;
if (deltaX == 0 || deltaY == 0) {
speedX = speed;
speedY = speed;
} else if (deltaX < deltaY) {
speedX = speed;
speedY = speed * deltaY / deltaX;
} else {
speedX = speed * deltaX / deltaY;
speedY = speed;
}
final boolean xSpeedIsPositive, ySpeedIsPositive;
if (getMode() == Mode.AutoScrollingForward) {
xSpeedIsPositive = cornerX == 0;
ySpeedIsPositive = cornerY == 0;
} else {
xSpeedIsPositive = cornerX != 0;
ySpeedIsPositive = cornerY != 0;
}
if (xSpeedIsPositive) {
myEndX += speedX;
if (myEndX >= boundX) {
terminate();
}
if (cornerY == 0) {
myEndY -= speed;
yOver = myEndY <= boundY;
} else {
myEndY += speed;
yOver = myEndY >= boundY;
} else {
myEndX -= speedX;
if (myEndX <= boundX) {
terminate();
}
}
if (xOver && yOver) {
terminate();
} else if (xOver) {
myEndX = boundX;
} else if (yOver) {
myEndY = boundY;
if (ySpeedIsPositive) {
myEndY += speedY;
if (myEndY >= boundY) {
terminate();
}
} else {
myEndY -= speedY;
if (myEndY <= boundY) {
terminate();
}
}
}
}