Search in sources :

Example 1 with ThumbRenderer

use of org.signal.imageeditor.core.model.ThumbRenderer in project Signal-Android by WhisperSystems.

the class ImageEditorView method startAMoveAndResizeSession.

private EditSession startAMoveAndResizeSession(@NonNull Matrix inverse, @NonNull PointF point, @Nullable EditorElement selected) {
    Matrix elementInverseMatrix;
    if (selected == null)
        return null;
    if (selected.getRenderer() instanceof ThumbRenderer) {
        ThumbRenderer thumb = (ThumbRenderer) selected.getRenderer();
        EditorElement thumbControlledElement = getModel().findById(thumb.getElementToControl());
        if (thumbControlledElement == null)
            return null;
        EditorElement thumbsParent = getModel().getRoot().findParent(selected);
        if (thumbsParent == null)
            return null;
        Matrix thumbContainerRelativeMatrix = model.findRelativeMatrix(thumbsParent, thumbControlledElement);
        if (thumbContainerRelativeMatrix == null)
            return null;
        selected = thumbControlledElement;
        elementInverseMatrix = model.findElementInverseMatrix(selected, viewMatrix);
        if (elementInverseMatrix != null) {
            return ThumbDragEditSession.startDrag(selected, elementInverseMatrix, thumbContainerRelativeMatrix, thumb.getControlPoint(), point);
        } else {
            return null;
        }
    }
    return ElementDragEditSession.startDrag(selected, inverse, point);
}
Also used : Matrix(android.graphics.Matrix) EditorElement(org.signal.imageeditor.core.model.EditorElement) ThumbRenderer(org.signal.imageeditor.core.model.ThumbRenderer)

Example 2 with ThumbRenderer

use of org.signal.imageeditor.core.model.ThumbRenderer in project Signal-Android by signalapp.

the class ImageEditorView method startAMoveAndResizeSession.

private EditSession startAMoveAndResizeSession(@NonNull Matrix inverse, @NonNull PointF point, @Nullable EditorElement selected) {
    Matrix elementInverseMatrix;
    if (selected == null)
        return null;
    if (selected.getRenderer() instanceof ThumbRenderer) {
        ThumbRenderer thumb = (ThumbRenderer) selected.getRenderer();
        EditorElement thumbControlledElement = getModel().findById(thumb.getElementToControl());
        if (thumbControlledElement == null)
            return null;
        EditorElement thumbsParent = getModel().getRoot().findParent(selected);
        if (thumbsParent == null)
            return null;
        Matrix thumbContainerRelativeMatrix = model.findRelativeMatrix(thumbsParent, thumbControlledElement);
        if (thumbContainerRelativeMatrix == null)
            return null;
        selected = thumbControlledElement;
        elementInverseMatrix = model.findElementInverseMatrix(selected, viewMatrix);
        if (elementInverseMatrix != null) {
            return ThumbDragEditSession.startDrag(selected, elementInverseMatrix, thumbContainerRelativeMatrix, thumb.getControlPoint(), point);
        } else {
            return null;
        }
    }
    return ElementDragEditSession.startDrag(selected, inverse, point);
}
Also used : Matrix(android.graphics.Matrix) EditorElement(org.signal.imageeditor.core.model.EditorElement) ThumbRenderer(org.signal.imageeditor.core.model.ThumbRenderer)

Aggregations

Matrix (android.graphics.Matrix)2 EditorElement (org.signal.imageeditor.core.model.EditorElement)2 ThumbRenderer (org.signal.imageeditor.core.model.ThumbRenderer)2