session-android/src/org/thoughtcrime/securesms/imageeditor/DrawingSession.java

46 lines
1.4 KiB
Java
Raw Normal View History

2019-05-09 17:11:11 +00:00
package org.thoughtcrime.securesms.imageeditor;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.support.annotation.NonNull;
import org.thoughtcrime.securesms.imageeditor.model.EditorElement;
import org.thoughtcrime.securesms.imageeditor.renderers.BezierDrawingRenderer;
/**
* Passes touch events into a {@link BezierDrawingRenderer}.
*/
class DrawingSession extends ElementEditSession {
private final BezierDrawingRenderer renderer;
private DrawingSession(@NonNull EditorElement selected, @NonNull Matrix inverseMatrix, @NonNull BezierDrawingRenderer renderer) {
super(selected, inverseMatrix);
this.renderer = renderer;
}
public static EditSession start(EditorElement element, BezierDrawingRenderer renderer, Matrix inverseMatrix, PointF point) {
DrawingSession drawingSession = new DrawingSession(element, inverseMatrix, renderer);
drawingSession.setScreenStartPoint(0, point);
renderer.setFirstPoint(drawingSession.startPointElement[0]);
return drawingSession;
}
@Override
public void movePoint(int p, @NonNull PointF point) {
if (p != 0) return;
setScreenEndPoint(p, point);
renderer.addNewPoint(endPointElement[0]);
}
@Override
public EditSession newPoint(Matrix newInverse, PointF point, int p) {
return this;
}
@Override
public EditSession removePoint(Matrix newInverse, int p) {
return this;
}
}