comparison android/DWindows.kt @ 2538:1b3b40c89cd0

Android: Move the text to below the point, not above it. Adjust the rect and origin based on the calculated text height.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 11 May 2021 22:53:29 +0000
parents cd9d2ba251d5
children 822f814a54f4
comparison
equal deleted inserted replaced
2537:cd9d2ba251d5 2538:1b3b40c89cd0
1935 paint.color = bgcolor 1935 paint.color = bgcolor
1936 paint.flags = 0 1936 paint.flags = 0
1937 paint.style = Paint.Style.FILL_AND_STROKE 1937 paint.style = Paint.Style.FILL_AND_STROKE
1938 paint.textAlign = Paint.Align.LEFT 1938 paint.textAlign = Paint.Align.LEFT
1939 paint.getTextBounds(text, 0, text.length, rect) 1939 paint.getTextBounds(text, 0, text.length, rect)
1940 rect.top += y 1940 val textheight = rect.bottom - rect.top
1941 rect.bottom += y 1941 rect.top += y + textheight
1942 rect.bottom += y + textheight
1942 rect.left += x 1943 rect.left += x
1943 rect.right += x 1944 rect.right += x
1944 canvas.drawRect(rect, paint) 1945 canvas.drawRect(rect, paint)
1945 // Restore the color and prepare to draw text 1946 // Restore the color and prepare to draw text
1946 paint.color = oldcolor 1947 paint.color = oldcolor
1947 paint.style = Paint.Style.STROKE 1948 paint.style = Paint.Style.STROKE
1948 canvas.drawText(text, x.toFloat(), y.toFloat(), paint) 1949 canvas.drawText(text, x.toFloat(), y.toFloat() + textheight.toFloat(), paint)
1949 } 1950 }
1950 } 1951 }
1951 } 1952 }
1952 1953
1953 fun drawRect(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, width: Int, height: Int) 1954 fun drawRect(render: DWRender?, bitmap: Bitmap?, x: Int, y: Int, width: Int, height: Int)