diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-04-01 17:14:50 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-04-07 09:18:07 +0200 |
commit | bf995db73982016f6baf752e5cf03bca3975c640 (patch) | |
tree | cafa395f01e4128c94a5fc16cd9a262804d442cd /android/experimental | |
parent | 492e52c1df9e4acb8ae33aa10d50e1ab7f3e97d6 (diff) |
android: add onHitTest for implementations, add impl. interface
CanvasElementImplRequirement is a interface to define which methods
can/should a CanvasElement subclass implement.
Change-Id: I61ea6d56bbdd8bd4402b821675a0206ce43b25ce
Diffstat (limited to 'android/experimental')
6 files changed, 32 insertions, 13 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index 1ea06d62d853..00af8d51b1d5 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -17,13 +17,11 @@ import org.libreoffice.kit.DirectBufferAllocator; import org.libreoffice.kit.Document; import org.libreoffice.kit.LibreOfficeKit; import org.libreoffice.kit.Office; - import org.mozilla.gecko.gfx.BufferedCairoImage; import org.mozilla.gecko.gfx.CairoImage; import org.mozilla.gecko.gfx.GeckoLayerClient; import org.mozilla.gecko.gfx.IntSize; - import java.nio.ByteBuffer; /** diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java index 322cb99066d2..51e8801f6b58 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java @@ -25,14 +25,6 @@ public interface CanvasElement { void draw(Canvas canvas); /** - * Called inside draw if the element is visible. Override this method to - * draw the element on the canvas. - * - * @param canvas - the canvas - */ - void onDraw(Canvas canvas); - - /** * Hit test - returns true if the object has been hit * @param x - x coordinate of the * @param y - y coordinate of the diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElementImplRequirement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElementImplRequirement.java new file mode 100644 index 000000000000..b9ad464321d8 --- /dev/null +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElementImplRequirement.java @@ -0,0 +1,21 @@ +package org.libreoffice.canvas; + +import android.graphics.Canvas; + +interface CanvasElementImplRequirement { + + /** + * Implement hit test here + * @param x - x coordinate of the + * @param y - y coordinate of the + */ + boolean onHitTest(float x, float y); + + /** + * Called inside draw if the element is visible. Override this method to + * draw the element on the canvas. + * + * @param canvas - the canvas + */ + void onDraw(Canvas canvas); +} diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java index f8492908e0fc..5f037c0066a6 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java @@ -5,7 +5,7 @@ import android.graphics.Canvas; /** * Common implementation to canvas elements. */ -public abstract class CommonCanvasElement implements CanvasElement { +public abstract class CommonCanvasElement implements CanvasElement, CanvasElementImplRequirement { private boolean mVisible = false; @@ -25,4 +25,12 @@ public abstract class CommonCanvasElement implements CanvasElement { onDraw(canvas); } } + + @Override + public boolean contains(float x, float y) { + if (!isVisible()) { + return false; + } + return onHitTest(x, y); + } } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java index 0cdd53bd1697..e54b0f6ec619 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java @@ -88,7 +88,7 @@ public class GraphicSelection extends CommonCanvasElement { * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas) */ @Override - public boolean contains(float x, float y) { + public boolean onHitTest(float x, float y) { // Check if handle was hit for (GraphicSelectionHandle handle : mHandles) { if (handle.contains(x, y)) { diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java index b8b22fc4f30f..0c088e0590d6 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java @@ -109,7 +109,7 @@ public class GraphicSelectionHandle extends CommonCanvasElement { * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas) */ @Override - public boolean contains(float x, float y) { + public boolean onHitTest(float x, float y) { return mHitRect.contains(x, y); } |