Kaydet (Commit) 25f0d577 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Miklos Vajna

android: add contains (hit test) to CanvasElement interface

Change-Id: Ic0022790c9ee1a5be1352eba0815e0d63ae17025
üst 24587ecb
...@@ -21,5 +21,12 @@ public interface CanvasElement { ...@@ -21,5 +21,12 @@ public interface CanvasElement {
* @param canvas - the canvas * @param canvas - the canvas
*/ */
void draw(Canvas canvas); void draw(Canvas canvas);
/**
* Hit test - returns true if the object has been hit
* @param x - x coordinate of the
* @param y - y coordinate of the
*/
boolean contains(float x, float y);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
...@@ -64,6 +64,7 @@ public class GraphicSelection implements CanvasElement { ...@@ -64,6 +64,7 @@ public class GraphicSelection implements CanvasElement {
mHandles[7].reposition(scaledRectangle.right, scaledRectangle.bottom); mHandles[7].reposition(scaledRectangle.right, scaledRectangle.bottom);
} }
@Override
public boolean contains(float x, float y) { public boolean contains(float x, float y) {
// Check if handle was hit // Check if handle was hit
for (GraphicSelectionHandle handle : mHandles) { for (GraphicSelectionHandle handle : mHandles) {
......
...@@ -73,6 +73,7 @@ public class GraphicSelectionHandle implements CanvasElement { ...@@ -73,6 +73,7 @@ public class GraphicSelectionHandle implements CanvasElement {
mHitRect.bottom = mPosition.y + mRadius * 1.75f; mHitRect.bottom = mPosition.y + mRadius * 1.75f;
} }
@Override
public boolean contains(float x, float y) { public boolean contains(float x, float y) {
return mHitRect.contains(x, y); return mHitRect.contains(x, y);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment