Permalink
Browse files

MultiTouchController test

  • Loading branch information...
napthats committed Nov 6, 2012
1 parent fa5d4e5 commit f5b3ee0eaa0645f7a3e5c8653e6cfff580bbd1fb
Showing with 31 additions and 2 deletions.
  1. +30 −1 src/main/scala/BoardView.scala
  2. +1 −1 src/main/scala/MainActivity.scala
@@ -11,15 +11,25 @@ import _root_.android.graphics.Color
import _root_.android.view.MotionEvent
import _root_.android.widget.Toast
+import _root_.org.metalev.multitouch.controller.MultiTouchController;
+import _root_.org.metalev.multitouch.controller.MultiTouchController.MultiTouchObjectCanvas;
+import _root_.org.metalev.multitouch.controller.MultiTouchController.PointInfo;
+import _root_.org.metalev.multitouch.controller.MultiTouchController.PositionAndScale;
+
class Page(var x: Int, var y: Int, val size: Int, title: String) {
}
-class BoardView(context: Context, attrs:AttributeSet) extends View(context, attrs) {
+class BoardView(context: Context, attrs:AttributeSet) extends View(context, attrs) with MultiTouchObjectCanvas[Page]{
+/*
var prev_touch_x = 0
var prev_touch_y = 0
+*/
var page = new Page(200, 100, 20, "test")
+ val multiTouchController = new MultiTouchController[Page](this)
+
+
override def onDraw(canvas: Canvas) {
super.onDraw(canvas)
@@ -29,6 +39,24 @@ class BoardView(context: Context, attrs:AttributeSet) extends View(context, attr
canvas.drawRect(page.x, page.y, page.x + page.size, page.y + page.size, paint)
}
+ override def selectObject(page: Page, point: PointInfo) {
+ Toast.makeText(context, "touch!", Toast.LENGTH_SHORT).show()
+ }
+
+ override def setPositionAndScale(page: Page, pos_scale: PositionAndScale, point: PointInfo): Boolean = {
+ return true
+ }
+
+ override def getPositionAndScale(page: Page, pos_scale: PositionAndScale) {
+ }
+
+ override def getDraggableObjectAtPoint(point: PointInfo): Page = {
+ page
+ }
+
+ override def onTouchEvent(event: MotionEvent): Boolean = multiTouchController.onTouchEvent(event)
+
+/*
def onTouch(v: View, event: MotionEvent): Boolean = {
val x: Int = event.getX.toInt
val y: Int = event.getY.toInt
@@ -51,4 +79,5 @@ class BoardView(context: Context, attrs:AttributeSet) extends View(context, attr
this.invalidate()
return true
}
+*/
}
@@ -25,7 +25,7 @@ class MainActivity extends Activity with TypedActivity {
findView(TR.boardview).setOnTouchListener(new View.OnTouchListener() {
override def onTouch(v: View, event: MotionEvent): Boolean = {
//Toast.makeText(MainActivity.this, "test", Toast.LENGTH_SHORT).show()
- findView(TR.boardview).onTouch(v, event)
+ findView(TR.boardview).onTouchEvent(event)
}
})
}

0 comments on commit f5b3ee0

Please sign in to comment.