Search in sources :

Example 1 with AnimatedLine

use of com.android.tools.sherpa.animation.AnimatedLine in project android by JetBrains.

the class SceneDraw method animateInCandidateAnchors.

/**
     * Utility function. Given the currently selected anchor, gather all the
     * potential anchors that we could connect to and start an AnimatedCircle animation
     * where they are, to indicate them to the user.
     */
private void animateInCandidateAnchors(ConstraintAnchor selectedAnchor) {
    if (selectedAnchor == null) {
        return;
    }
    mAnimationCandidateAnchors.clear();
    for (ConstraintWidget widget : mWidgetsScene.getWidgets()) {
        boolean highlighted = false;
        for (ConstraintAnchor a : widget.getAnchors()) {
            if (selectedAnchor.isValidConnection(a) && selectedAnchor.isConnectionAllowed(a.getOwner(), a)) {
                ConstraintHandle constraintHandle = WidgetInteractionTargets.constraintHandle(a);
                if (constraintHandle == null) {
                    continue;
                }
                mAnimationCandidateAnchors.add(new AnimatedLine(constraintHandle));
                highlighted = true;
            }
        }
        WidgetCompanion companion = (WidgetCompanion) widget.getCompanionWidget();
        WidgetDecorator decorator = companion.getWidgetDecorator(getCurrentStyle());
        if (decorator.getLook() == ColorTheme.Look.NORMAL) {
            if (highlighted) {
                decorator.setLook(ColorTheme.Look.HIGHLIGHTED);
            } else {
                decorator.setLook(ColorTheme.Look.SUBDUED);
            }
        }
    }
    mChoreographer.addAnimation(mAnimationCandidateAnchors);
}
Also used : AnimatedLine(com.android.tools.sherpa.animation.AnimatedLine) ConstraintHandle(com.android.tools.sherpa.interaction.ConstraintHandle) WidgetCompanion(com.android.tools.sherpa.structure.WidgetCompanion) WidgetDecorator(com.android.tools.sherpa.drawing.decorator.WidgetDecorator)

Aggregations

AnimatedLine (com.android.tools.sherpa.animation.AnimatedLine)1 WidgetDecorator (com.android.tools.sherpa.drawing.decorator.WidgetDecorator)1 ConstraintHandle (com.android.tools.sherpa.interaction.ConstraintHandle)1 WidgetCompanion (com.android.tools.sherpa.structure.WidgetCompanion)1