blob: bdb8e091454c63ca41834092d1da122e2aa29035 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package org.libreoffice.canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
public class Cursor extends CommonCanvasElement {
private static final float CURSOR_WIDTH = 2f;
private final Paint mCursorPaint = new Paint();
public RectF mPosition = new RectF();
public RectF mScaledPosition = new RectF();
public int mAlpha = 0;
public Cursor() {
mCursorPaint.setColor(Color.BLACK);
mCursorPaint.setAlpha(0xFF);
}
@Override
public boolean onHitTest(float x, float y) {
return false;
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawRect(mScaledPosition, mCursorPaint);
}
public void reposition(RectF rect) {
mScaledPosition = rect;
mScaledPosition.right = mScaledPosition.left + CURSOR_WIDTH;
}
public void cycleAlpha() {
mCursorPaint.setAlpha(mCursorPaint.getAlpha() == 0 ? 0xFF : 0);
}
}
|