Search in sources :

Example 1 with MotionEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity in project Signal-Android by WhisperSystems.

the class MotionView method findEntityAtPoint.

@Nullable
private MotionEntity findEntityAtPoint(float x, float y) {
    MotionEntity selected = null;
    PointF p = new PointF(x, y);
    for (int i = entities.size() - 1; i >= 0; i--) {
        if (entities.get(i).pointInLayerRect(p)) {
            selected = entities.get(i);
            break;
        }
    }
    return selected;
}
Also used : PointF(android.graphics.PointF) MotionEntity(org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity) Paint(android.graphics.Paint) Nullable(android.support.annotation.Nullable)

Example 2 with MotionEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity in project Signal-Android by WhisperSystems.

the class MotionView method updateSelectionOnTap.

private void updateSelectionOnTap(MotionEvent e) {
    MotionEntity entity = findEntityAtPoint(e.getX(), e.getY());
    selectEntity(entity, true);
}
Also used : MotionEntity(org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity)

Example 3 with MotionEntity

use of org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity in project Signal-Android by WhisperSystems.

the class MotionView method afterTextChanged.

@Override
public void afterTextChanged(Editable s) {
    String text = s.toString();
    MotionEntity entity = getSelectedEntity();
    if (entity != null && entity instanceof TextEntity) {
        TextEntity textEntity = (TextEntity) entity;
        if (!textEntity.getLayer().getText().equals(text)) {
            textEntity.getLayer().setText(text);
            textEntity.updateEntity();
            MotionView.this.invalidate();
        }
    }
}
Also used : MotionEntity(org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity) TextEntity(org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)

Aggregations

MotionEntity (org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity)3 Paint (android.graphics.Paint)1 PointF (android.graphics.PointF)1 Nullable (android.support.annotation.Nullable)1 TextEntity (org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)1