Commit 0309b2a1 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Replace ChromeAnimation instances in SimpleAnimationLayout

This change replaces all of the usages of ChromeAnimation in the
SimpleAnimationLayout with CompositorAnimators. For simplicity
all of the properties used by this layout have been converted into
FloatPropery.

BUG=750381

Change-Id: I9ecf38725e8081926a0b85cab4ebea8905ed35a6
Reviewed-on: https://chromium-review.googlesource.com/833177
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539859}
parent dc639a91
......@@ -111,23 +111,42 @@ public class CompositorAnimator extends Animator {
* A utility for creating a basic animator.
* @param handler The {@link CompositorAnimationHandler} responsible for running the animation.
* @param target The object to modify.
* @param property The projecty of the object to modify.
* @param property The property of the object to modify.
* @param startValue The starting animation value.
* @param endValue The end animation value.
* @param durationMs The duration of the animation in ms.
* @param interpolator The time interpolator for the animation.
* @return A {@link CompositorAnimator} for the property.
*/
public static <T> CompositorAnimator ofFloatProperty(CompositorAnimationHandler handler,
final T target, final FloatProperty<T> property, float startValue, float endValue,
long durationMs) {
long durationMs, TimeInterpolator interpolator) {
CompositorAnimator animator = new CompositorAnimator(handler);
animator.setValues(startValue, endValue);
animator.setDuration(durationMs);
animator.addUpdateListener(
(CompositorAnimator a) -> property.setValue(target, a.getAnimatedValue()));
animator.setInterpolator(interpolator);
return animator;
}
/**
* A utility for creating a basic animator.
* @param handler The {@link CompositorAnimationHandler} responsible for running the animation.
* @param target The object to modify.
* @param property The property of the object to modify.
* @param startValue The starting animation value.
* @param endValue The end animation value.
* @param durationMs The duration of the animation in ms.
* @return A {@link CompositorAnimator} for the property.
*/
public static <T> CompositorAnimator ofFloatProperty(CompositorAnimationHandler handler,
final T target, final FloatProperty<T> property, float startValue, float endValue,
long durationMs) {
return ofFloatProperty(handler, target, property, startValue, endValue, durationMs,
ChromeAnimation.getDecelerateInterpolator());
}
/** An interface for listening for frames of an animation. */
public interface AnimatorUpdateListener {
/**
......
......@@ -12,6 +12,7 @@ import android.graphics.Color;
import android.graphics.RectF;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.animation.FloatProperty;
import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.toolbar.ToolbarPhone;
......@@ -1017,4 +1018,78 @@ public class LayoutTab implements ChromeAnimation.Animatable<LayoutTab.Property>
mCurrentAnimations = null;
}
}
public static final FloatProperty<LayoutTab> ALPHA = new FloatProperty<LayoutTab>("ALPHA") {
@Override
public void setValue(LayoutTab layoutTab, float v) {
layoutTab.setAlpha(v);
}
@Override
public Float get(LayoutTab layoutTab) {
return layoutTab.getAlpha();
}
};
public static final FloatProperty<LayoutTab> BORDER_ALPHA =
new FloatProperty<LayoutTab>("BORDER_ALPHA") {
@Override
public void setValue(LayoutTab layoutTab, float v) {
layoutTab.setBorderAlpha(v);
}
@Override
public Float get(LayoutTab layoutTab) {
return layoutTab.getBorderAlpha();
}
};
public static final FloatProperty<LayoutTab> BORDER_SCALE =
new FloatProperty<LayoutTab>("BORDER_SCALE") {
@Override
public void setValue(LayoutTab layoutTab, float v) {
layoutTab.setBorderScale(v);
}
@Override
public Float get(LayoutTab layoutTab) {
return layoutTab.getBorderScale();
}
};
public static final FloatProperty<LayoutTab> SCALE = new FloatProperty<LayoutTab>("SCALE") {
@Override
public void setValue(LayoutTab layoutTab, float v) {
layoutTab.setScale(v);
}
@Override
public Float get(LayoutTab layoutTab) {
return layoutTab.getScale();
}
};
public static final FloatProperty<LayoutTab> X = new FloatProperty<LayoutTab>("X") {
@Override
public void setValue(LayoutTab layoutTab, float v) {
layoutTab.setX(v);
}
@Override
public Float get(LayoutTab layoutTab) {
return layoutTab.getX();
}
};
public static final FloatProperty<LayoutTab> Y = new FloatProperty<LayoutTab>("Y") {
@Override
public void setValue(LayoutTab layoutTab, float v) {
layoutTab.setY(v);
}
@Override
public Float get(LayoutTab layoutTab) {
return layoutTab.getY();
}
};
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment