Search in sources :

Example 1 with SelectableRenderer

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

the class EditorElementHierarchy method setOrUpdateSelectionThumbsForElement.

void setOrUpdateSelectionThumbsForElement(@NonNull EditorElement element, @Nullable Matrix overlayMappingMatrix) {
    if (selectedElement != element) {
        removeAllSelectionArtifacts();
        if (element.getRenderer() instanceof SelectableRenderer) {
            selectedElement = element;
        } else {
            selectedElement = null;
        }
        if (selectedElement == null)
            return;
        selection.addElement(createSelectionBox());
        selection.addElement(createScaleControlThumb(element));
        selection.addElement(createRotateControlThumb(element));
    }
    if (overlayMappingMatrix != null) {
        Matrix selectionMatrix = selection.getLocalMatrix();
        if (selectedElement.getRenderer() instanceof SelectableRenderer) {
            SelectableRenderer renderer = (SelectableRenderer) selectedElement.getRenderer();
            RectF bounds = new RectF();
            renderer.getSelectionBounds(bounds);
            selectionMatrix.setRectToRect(Bounds.FULL_BOUNDS, bounds, Matrix.ScaleToFit.FILL);
        }
        selectionMatrix.postConcat(overlayMappingMatrix);
    }
}
Also used : RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) SelectableRenderer(org.signal.imageeditor.core.SelectableRenderer)

Example 2 with SelectableRenderer

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

the class EditorElementHierarchy method setOrUpdateSelectionThumbsForElement.

void setOrUpdateSelectionThumbsForElement(@NonNull EditorElement element, @Nullable Matrix overlayMappingMatrix) {
    if (selectedElement != element) {
        removeAllSelectionArtifacts();
        if (element.getRenderer() instanceof SelectableRenderer) {
            selectedElement = element;
        } else {
            selectedElement = null;
        }
        if (selectedElement == null)
            return;
        selection.addElement(createSelectionBox());
        selection.addElement(createScaleControlThumb(element));
        selection.addElement(createRotateControlThumb(element));
    }
    if (overlayMappingMatrix != null) {
        Matrix selectionMatrix = selection.getLocalMatrix();
        if (selectedElement.getRenderer() instanceof SelectableRenderer) {
            SelectableRenderer renderer = (SelectableRenderer) selectedElement.getRenderer();
            RectF bounds = new RectF();
            renderer.getSelectionBounds(bounds);
            selectionMatrix.setRectToRect(Bounds.FULL_BOUNDS, bounds, Matrix.ScaleToFit.FILL);
        }
        selectionMatrix.postConcat(overlayMappingMatrix);
    }
}
Also used : RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) SelectableRenderer(org.signal.imageeditor.core.SelectableRenderer)

Aggregations

Matrix (android.graphics.Matrix)2 RectF (android.graphics.RectF)2 SelectableRenderer (org.signal.imageeditor.core.SelectableRenderer)2