android: rename graphic selection and handle
Change-Id: I7bf89b92190ba37535fa89118269d706d6bf05d9
This commit is contained in:
committed by
Miklos Vajna
parent
b1def00ac3
commit
16d8839c24
@@ -17,13 +17,13 @@ import android.graphics.RectF;
|
|||||||
import org.libreoffice.LOKitShell;
|
import org.libreoffice.LOKitShell;
|
||||||
import org.mozilla.gecko.gfx.LayerView;
|
import org.mozilla.gecko.gfx.LayerView;
|
||||||
|
|
||||||
import static org.libreoffice.canvas.GraphicSelectionHandleCanvasElement.HandlePosition;
|
import static org.libreoffice.canvas.GraphicSelectionHandle.HandlePosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is responsible to draw and reposition the selection
|
* This class is responsible to draw and reposition the selection
|
||||||
* rectangle.
|
* rectangle.
|
||||||
*/
|
*/
|
||||||
public class GraphicSelectionCanvasElement implements CanvasElement {
|
public class GraphicSelection implements CanvasElement {
|
||||||
private final Paint mPaint;
|
private final Paint mPaint;
|
||||||
public RectF mRectangle = new RectF();
|
public RectF mRectangle = new RectF();
|
||||||
public RectF mScaledRectangle = new RectF();
|
public RectF mScaledRectangle = new RectF();
|
||||||
@@ -31,23 +31,23 @@ public class GraphicSelectionCanvasElement implements CanvasElement {
|
|||||||
private DragType mType = DragType.NONE;
|
private DragType mType = DragType.NONE;
|
||||||
private PointF mStartDragPosition;
|
private PointF mStartDragPosition;
|
||||||
|
|
||||||
private GraphicSelectionHandleCanvasElement mHandles[] = new GraphicSelectionHandleCanvasElement[8];
|
private GraphicSelectionHandle mHandles[] = new GraphicSelectionHandle[8];
|
||||||
private GraphicSelectionHandleCanvasElement mDragHandle = null;
|
private GraphicSelectionHandle mDragHandle = null;
|
||||||
|
|
||||||
public GraphicSelectionCanvasElement() {
|
public GraphicSelection() {
|
||||||
mPaint = new Paint();
|
mPaint = new Paint();
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
mPaint.setColor(Color.BLACK);
|
mPaint.setColor(Color.BLACK);
|
||||||
mPaint.setStrokeWidth(2);
|
mPaint.setStrokeWidth(2);
|
||||||
|
|
||||||
mHandles[0] = new GraphicSelectionHandleCanvasElement(HandlePosition.TOP_LEFT);
|
mHandles[0] = new GraphicSelectionHandle(HandlePosition.TOP_LEFT);
|
||||||
mHandles[1] = new GraphicSelectionHandleCanvasElement(HandlePosition.TOP);
|
mHandles[1] = new GraphicSelectionHandle(HandlePosition.TOP);
|
||||||
mHandles[2] = new GraphicSelectionHandleCanvasElement(HandlePosition.TOP_RIGHT);
|
mHandles[2] = new GraphicSelectionHandle(HandlePosition.TOP_RIGHT);
|
||||||
mHandles[3] = new GraphicSelectionHandleCanvasElement(HandlePosition.LEFT);
|
mHandles[3] = new GraphicSelectionHandle(HandlePosition.LEFT);
|
||||||
mHandles[4] = new GraphicSelectionHandleCanvasElement(HandlePosition.RIGHT);
|
mHandles[4] = new GraphicSelectionHandle(HandlePosition.RIGHT);
|
||||||
mHandles[5] = new GraphicSelectionHandleCanvasElement(HandlePosition.BOTTOM_LEFT);
|
mHandles[5] = new GraphicSelectionHandle(HandlePosition.BOTTOM_LEFT);
|
||||||
mHandles[6] = new GraphicSelectionHandleCanvasElement(HandlePosition.BOTTOM);
|
mHandles[6] = new GraphicSelectionHandle(HandlePosition.BOTTOM);
|
||||||
mHandles[7] = new GraphicSelectionHandleCanvasElement(HandlePosition.BOTTOM_RIGHT);
|
mHandles[7] = new GraphicSelectionHandle(HandlePosition.BOTTOM_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reposition(RectF scaledRectangle) {
|
public void reposition(RectF scaledRectangle) {
|
||||||
@@ -66,7 +66,7 @@ public class GraphicSelectionCanvasElement implements CanvasElement {
|
|||||||
|
|
||||||
public boolean contains(float x, float y) {
|
public boolean contains(float x, float y) {
|
||||||
// Check if handle was hit
|
// Check if handle was hit
|
||||||
for (GraphicSelectionHandleCanvasElement handle : mHandles) {
|
for (GraphicSelectionHandle handle : mHandles) {
|
||||||
if (handle.contains(x, y)) {
|
if (handle.contains(x, y)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ public class GraphicSelectionCanvasElement implements CanvasElement {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void draw(Canvas canvas) {
|
||||||
canvas.drawRect(mDrawRectangle, mPaint);
|
canvas.drawRect(mDrawRectangle, mPaint);
|
||||||
for (GraphicSelectionHandleCanvasElement handle : mHandles) {
|
for (GraphicSelectionHandle handle : mHandles) {
|
||||||
handle.draw(canvas);
|
handle.draw(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ public class GraphicSelectionCanvasElement implements CanvasElement {
|
|||||||
public void dragStart(PointF position) {
|
public void dragStart(PointF position) {
|
||||||
mDragHandle = null;
|
mDragHandle = null;
|
||||||
mType = DragType.NONE;
|
mType = DragType.NONE;
|
||||||
for (GraphicSelectionHandleCanvasElement handle : mHandles) {
|
for (GraphicSelectionHandle handle : mHandles) {
|
||||||
if (handle.contains(position.x, position.y)) {
|
if (handle.contains(position.x, position.y)) {
|
||||||
mDragHandle = handle;
|
mDragHandle = handle;
|
||||||
mDragHandle.select();
|
mDragHandle.select();
|
||||||
@@ -189,7 +189,7 @@ public class GraphicSelectionCanvasElement implements CanvasElement {
|
|||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mDragHandle = null;
|
mDragHandle = null;
|
||||||
for (GraphicSelectionHandleCanvasElement handle : mHandles) {
|
for (GraphicSelectionHandle handle : mHandles) {
|
||||||
handle.reset();
|
handle.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -19,7 +19,7 @@ import android.graphics.RectF;
|
|||||||
* position and perform a hit test to determine if the selection handle was
|
* position and perform a hit test to determine if the selection handle was
|
||||||
* touched.
|
* touched.
|
||||||
*/
|
*/
|
||||||
public class GraphicSelectionHandleCanvasElement implements CanvasElement {
|
public class GraphicSelectionHandle implements CanvasElement {
|
||||||
private final HandlePosition mHandlePosition;
|
private final HandlePosition mHandlePosition;
|
||||||
public PointF mPosition = new PointF();
|
public PointF mPosition = new PointF();
|
||||||
private float mRadius = 20.0f;
|
private float mRadius = 20.0f;
|
||||||
@@ -29,7 +29,7 @@ public class GraphicSelectionHandleCanvasElement implements CanvasElement {
|
|||||||
private RectF mHitRect = new RectF();
|
private RectF mHitRect = new RectF();
|
||||||
private boolean mSelected = false;
|
private boolean mSelected = false;
|
||||||
|
|
||||||
public GraphicSelectionHandleCanvasElement(HandlePosition position) {
|
public GraphicSelectionHandle(HandlePosition position) {
|
||||||
mHandlePosition = position;
|
mHandlePosition = position;
|
||||||
|
|
||||||
mStrokePaint.setStyle(Paint.Style.STROKE);
|
mStrokePaint.setStyle(Paint.Style.STROKE);
|
@@ -20,8 +20,7 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.libreoffice.LOKitShell;
|
import org.libreoffice.LOKitShell;
|
||||||
import org.libreoffice.canvas.GraphicSelectionCanvasElement;
|
import org.libreoffice.canvas.GraphicSelection;
|
||||||
import org.libreoffice.canvas.GraphicSelectionHandleCanvasElement;
|
|
||||||
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
|
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
|
||||||
import org.mozilla.gecko.gfx.LayerView;
|
import org.mozilla.gecko.gfx.LayerView;
|
||||||
import org.mozilla.gecko.gfx.RectUtils;
|
import org.mozilla.gecko.gfx.RectUtils;
|
||||||
@@ -49,7 +48,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
|
|||||||
private Paint mSelectionPaint = new Paint();
|
private Paint mSelectionPaint = new Paint();
|
||||||
private boolean mSelectionsVisible;
|
private boolean mSelectionsVisible;
|
||||||
|
|
||||||
private GraphicSelectionCanvasElement mGraphicSelection;
|
private GraphicSelection mGraphicSelection;
|
||||||
|
|
||||||
private boolean mGraphicSelectionVisible;
|
private boolean mGraphicSelectionVisible;
|
||||||
private boolean mGraphicSelectionMove = false;
|
private boolean mGraphicSelectionMove = false;
|
||||||
@@ -86,7 +85,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
|
|||||||
mSelectionPaint.setAlpha(50);
|
mSelectionPaint.setAlpha(50);
|
||||||
mSelectionsVisible = false;
|
mSelectionsVisible = false;
|
||||||
|
|
||||||
mGraphicSelection = new GraphicSelectionCanvasElement();
|
mGraphicSelection = new GraphicSelection();
|
||||||
|
|
||||||
mGraphicSelectionVisible = false;
|
mGraphicSelectionVisible = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user