Permalink
Browse files

Change Rect to Text

  • Loading branch information...
1 parent 3b967f5 commit 57fb4c5d9b76d931751d54e70a9dba90d3824cee @napthats committed Nov 11, 2012
Showing with 7 additions and 8 deletions.
  1. +2 −2 src/main/scala/BoardView.scala
  2. +5 −6 src/main/scala/Page.scala
@@ -35,8 +35,8 @@ object BoardView {
class BoardView(context: Context, attrs:AttributeSet) extends View(context, attrs) with MultiTouchObjectCanvas[Page]{
val multiTouchController = new MultiTouchController[Page](this)
- PageContainer.add(Page(200.0, 100.0, Color.BLUE))
- PageContainer.add(Page(400.0, 400.0, Color.RED))
+ PageContainer.add(Page("test1", 200.0, 100.0, Color.BLUE))
+ PageContainer.add(Page("test2", 400.0, 400.0, Color.RED))
//for Canvas#drawRect
View
@@ -10,7 +10,7 @@ object Page {
private val height = 20.0
private def winWidth = width * BoardView.base_scale
private def winHeight = height * BoardView.base_scale
- def apply(x: Double, y: Double, color: Int) = new Page(x, y, color, "")
+ def apply(title: String, x: Double, y: Double, color: Int) = new Page(x, y, color, title)
val dummy = new Page(0.0, 0.0, 0, "") {
override def scale = BoardView.base_scale
override def scale_=(x: Double) {}
@@ -44,15 +44,14 @@ class Page private (var x: Double, var y: Double, val color: Int, title: String)
}
def containPoint(pos: {val x: Double; val y: Double}): Boolean =
- pos.x >= x && pos.x <= x + width && pos.y >= y && pos.y <= y + height
+ pos.x >= x && pos.x <= x + width && pos.y >= y - height && pos.y <= y
- //TODO: change parameter to window-coordinated canvas
+ //TODO: change canvas to window-coordinated Canvas
def draw(canvas: Canvas) {
val paint = new Paint()
paint.setColor(color)
- canvas.drawRect(winX, winY, winX + winWidth, winY + winHeight, paint)
- paint.setColor(Color.WHITE)
- canvas.drawRect(winX + winWidth * 0.05, winY + winHeight * 0.05, winX + winWidth * 0.95, winY + winHeight * 0.95, paint)
+ paint.setTextSize(24.0 * scale * BoardView.base_scale)
+ canvas.drawText(title, winX, winY, paint)
}
}

0 comments on commit 57fb4c5

Please sign in to comment.