summaryrefslogtreecommitdiff
path: root/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/SelectionHandleMiddle.java
blob: 7415d6d3dadd88ea72e43887b1bc16317e4b52e6 (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
package org.libreoffice.canvas;

import android.content.Context;
import android.graphics.Bitmap;

import org.libreoffice.R;

/**
 * Selection handle that is used to manipulate the cursor.
 */
public class SelectionHandleMiddle extends SelectionHandle {
    public SelectionHandleMiddle(Context context) {
        super(getBitmapForDrawable(context, R.drawable.handle_middle));
    }

    /**
     * Change the position of the handle on the screen. Take into account the
     * handle alignment to the center.
     */
    @Override
    public void reposition(float x, float y) {
        super.reposition(x, y);
        // align to the center
        float offset = mScreenPosition.width() / 2.0f;
        mScreenPosition.offset(-offset, 0);
    }

    /**
     * Define the type of the handle.
     */
    @Override
    public HandleType getHandleType() {
        return HandleType.MIDDLE;
    }
}