org.chromium.chrome.browser.compositor.layouts.ChromeAnimation Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.ChromeAnimation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StackAnimation.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Responsible for generating the animations that shows a new tab being opened.
 *
 * @param tabs          The tabs that make up the stack.  These are the
 *                      tabs that will be affected by the TabSwitcherAnimation.
 * @param focusIndex    The focused index.  In this case, this is the index of
 *                      the tab that was just created.
 * @param discardRange  The maximum value the discard amount.
 * @return              The TabSwitcherAnimation instance that will tween the
 *                      tabs to create the appropriate animation.
 */
// TODO(dtrainor): Remove this after confirming nothing uses this.
protected ChromeAnimation<?> createNewTabOpenedAnimatorSet(
        StackTab[] tabs, int focusIndex, float discardRange) {
    if (focusIndex < 0 || focusIndex >= tabs.length) return null;
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    StackTab tab = tabs[focusIndex];
    tab.getLayoutTab().setVisible(false);
    tab.setXInStackInfluence(0.0f);
    tab.setYInStackInfluence(0.0f);
    tab.setDiscardFromClick(true);
    tab.setDiscardOriginX(tab.getLayoutTab().getOriginalContentWidth());
    tab.setDiscardOriginY(tab.getLayoutTab().getOriginalContentHeight() / 2.f);
    tab.getLayoutTab().setAlpha(0.0f);
    tab.getLayoutTab().setBorderAlpha(0.0f);
    addAnimation(set, tab, DISCARD_AMOUNT, getTabCreationDirection() * discardRange, 0.0f,
            TAB_OPENED_ANIMATION_DURATION, 0, false,
            ChromeAnimation.getAccelerateInterpolator());
    return set;
}
 
Example #2
Source File: StackAnimationLandscape.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createViewMoreAnimatorSet(StackTab[] tabs, int selectedIndex) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    if (selectedIndex + 1 >= tabs.length) return set;

    float offset = tabs[selectedIndex].getScrollOffset()
            - tabs[selectedIndex + 1].getScrollOffset()
            + (tabs[selectedIndex].getLayoutTab().getScaledContentWidth()
                           * VIEW_MORE_SIZE_RATIO);
    offset = Math.max(VIEW_MORE_MIN_SIZE, offset);
    for (int i = selectedIndex + 1; i < tabs.length; ++i) {
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                tabs[i].getScrollOffset() + offset, VIEW_MORE_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #3
Source File: StackAnimationLandscape.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createReachTopAnimatorSet(StackTab[] tabs, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    float screenTarget = 0.0f;
    for (int i = 0; i < tabs.length; ++i) {
        if (screenTarget >= tabs[i].getLayoutTab().getX()) {
            break;
        }
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                StackTab.screenToScroll(screenTarget, warpSize), REACH_TOP_ANIMATION_DURATION,
                0);
        screenTarget += tabs[i].getLayoutTab().getScaledContentWidth();
    }

    return set;
}
 
Example #4
Source File: StackAnimation.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Responsible for generating the animations that shows a new tab being opened.
 *
 * @param tabs          The tabs that make up the stack.  These are the
 *                      tabs that will be affected by the TabSwitcherAnimation.
 * @param focusIndex    The focused index.  In this case, this is the index of
 *                      the tab that was just created.
 * @param discardRange  The maximum value the discard amount.
 * @return              The TabSwitcherAnimation instance that will tween the
 *                      tabs to create the appropriate animation.
 */
// TODO(dtrainor): Remove this after confirming nothing uses this.
protected ChromeAnimation<?> createNewTabOpenedAnimatorSet(
        StackTab[] tabs, int focusIndex, float discardRange) {
    if (focusIndex < 0 || focusIndex >= tabs.length) return null;
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    StackTab tab = tabs[focusIndex];
    tab.getLayoutTab().setVisible(false);
    tab.setXInStackInfluence(0.0f);
    tab.setYInStackInfluence(0.0f);
    tab.setDiscardFromClick(true);
    tab.setDiscardOriginX(tab.getLayoutTab().getOriginalContentWidth());
    tab.setDiscardOriginY(tab.getLayoutTab().getOriginalContentHeight() / 2.f);
    tab.getLayoutTab().setAlpha(0.0f);
    tab.getLayoutTab().setBorderAlpha(0.0f);
    addAnimation(set, tab, DISCARD_AMOUNT, getTabCreationDirection() * discardRange, 0.0f,
            TAB_OPENED_ANIMATION_DURATION, 0, false,
            ChromeAnimation.getAccelerateInterpolator());
    return set;
}
 
Example #5
Source File: StackAnimationLandscape.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createReachTopAnimatorSet(StackTab[] tabs, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    float screenTarget = 0.0f;
    for (int i = 0; i < tabs.length; ++i) {
        if (screenTarget >= tabs[i].getLayoutTab().getX()) {
            break;
        }
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                StackTab.screenToScroll(screenTarget, warpSize), REACH_TOP_ANIMATION_DURATION,
                0);
        screenTarget += tabs[i].getLayoutTab().getScaledContentWidth();
    }

    return set;
}
 
Example #6
Source File: StackAnimationLandscape.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createViewMoreAnimatorSet(StackTab[] tabs, int selectedIndex) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    if (selectedIndex + 1 >= tabs.length) return set;

    float offset = tabs[selectedIndex].getScrollOffset()
            - tabs[selectedIndex + 1].getScrollOffset()
            + (tabs[selectedIndex].getLayoutTab().getScaledContentWidth()
                           * VIEW_MORE_SIZE_RATIO);
    offset = Math.max(VIEW_MORE_MIN_SIZE, offset);
    for (int i = selectedIndex + 1; i < tabs.length; ++i) {
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                tabs[i].getScrollOffset() + offset, VIEW_MORE_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #7
Source File: StackAnimationPortrait.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createViewMoreAnimatorSet(StackTab[] tabs, int selectedIndex) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    if (selectedIndex + 1 >= tabs.length) return set;

    float offset = tabs[selectedIndex].getScrollOffset()
            - tabs[selectedIndex + 1].getScrollOffset()
            + (tabs[selectedIndex].getLayoutTab().getScaledContentHeight()
                           * VIEW_MORE_SIZE_RATIO);
    offset = Math.max(VIEW_MORE_MIN_SIZE, offset);
    for (int i = selectedIndex + 1; i < tabs.length; ++i) {
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                tabs[i].getScrollOffset() + offset, VIEW_MORE_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #8
Source File: StackAnimationPortrait.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createReachTopAnimatorSet(StackTab[] tabs, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    float screenTarget = 0.0f;
    for (int i = 0; i < tabs.length; ++i) {
        if (screenTarget >= tabs[i].getLayoutTab().getY()) {
            break;
        }
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                StackTab.screenToScroll(screenTarget, warpSize), REACH_TOP_ANIMATION_DURATION,
                0);
        screenTarget += tabs[i].getLayoutTab().getScaledContentHeight();
    }

    return set;
}
 
Example #9
Source File: StackAnimationPortrait.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createViewMoreAnimatorSet(StackTab[] tabs, int selectedIndex) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    if (selectedIndex + 1 >= tabs.length) return set;

    float offset = tabs[selectedIndex].getScrollOffset()
            - tabs[selectedIndex + 1].getScrollOffset()
            + (tabs[selectedIndex].getLayoutTab().getScaledContentHeight()
                           * VIEW_MORE_SIZE_RATIO);
    offset = Math.max(VIEW_MORE_MIN_SIZE, offset);
    for (int i = selectedIndex + 1; i < tabs.length; ++i) {
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                tabs[i].getScrollOffset() + offset, VIEW_MORE_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #10
Source File: StackAnimationLandscape.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createReachTopAnimatorSet(StackTab[] tabs, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    float screenTarget = 0.0f;
    for (int i = 0; i < tabs.length; ++i) {
        if (screenTarget >= tabs[i].getLayoutTab().getX()) {
            break;
        }
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                StackTab.screenToScroll(screenTarget, warpSize), REACH_TOP_ANIMATION_DURATION,
                0);
        screenTarget += tabs[i].getLayoutTab().getScaledContentWidth();
    }

    return set;
}
 
Example #11
Source File: StackAnimationPortrait.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createViewMoreAnimatorSet(StackTab[] tabs, int selectedIndex) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    if (selectedIndex + 1 >= tabs.length) return set;

    float offset = tabs[selectedIndex].getScrollOffset()
            - tabs[selectedIndex + 1].getScrollOffset()
            + (tabs[selectedIndex].getLayoutTab().getScaledContentHeight()
                           * VIEW_MORE_SIZE_RATIO);
    offset = Math.max(VIEW_MORE_MIN_SIZE, offset);
    for (int i = selectedIndex + 1; i < tabs.length; ++i) {
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                tabs[i].getScrollOffset() + offset, VIEW_MORE_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #12
Source File: StackAnimationPortrait.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createReachTopAnimatorSet(StackTab[] tabs, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    float screenTarget = 0.0f;
    for (int i = 0; i < tabs.length; ++i) {
        if (screenTarget >= tabs[i].getLayoutTab().getY()) {
            break;
        }
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                StackTab.screenToScroll(screenTarget, warpSize), REACH_TOP_ANIMATION_DURATION,
                0);
        screenTarget += tabs[i].getLayoutTab().getScaledContentHeight();
    }

    return set;
}
 
Example #13
Source File: StackAnimation.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Responsible for generating the animations that shows a new tab being opened.
 *
 * @param tabs          The tabs that make up the stack.  These are the
 *                      tabs that will be affected by the TabSwitcherAnimation.
 * @param focusIndex    The focused index.  In this case, this is the index of
 *                      the tab that was just created.
 * @param discardRange  The maximum value the discard amount.
 * @return              The TabSwitcherAnimation instance that will tween the
 *                      tabs to create the appropriate animation.
 */
// TODO(dtrainor): Remove this after confirming nothing uses this.
protected ChromeAnimation<?> createNewTabOpenedAnimatorSet(
        StackTab[] tabs, int focusIndex, float discardRange) {
    if (focusIndex < 0 || focusIndex >= tabs.length) return null;
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    StackTab tab = tabs[focusIndex];
    tab.getLayoutTab().setVisible(false);
    tab.setXInStackInfluence(0.0f);
    tab.setYInStackInfluence(0.0f);
    tab.setDiscardFromClick(true);
    tab.setDiscardOriginX(tab.getLayoutTab().getOriginalContentWidth());
    tab.setDiscardOriginY(tab.getLayoutTab().getOriginalContentHeight() / 2.f);
    tab.getLayoutTab().setAlpha(0.0f);
    tab.getLayoutTab().setBorderAlpha(0.0f);
    addAnimation(set, tab, DISCARD_AMOUNT, getTabCreationDirection() * discardRange, 0.0f,
            TAB_OPENED_ANIMATION_DURATION, 0, false,
            ChromeAnimation.getAccelerateInterpolator());
    return set;
}
 
Example #14
Source File: StackAnimationPortrait.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected ChromeAnimation<?> createReachTopAnimatorSet(StackTab[] tabs, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    float screenTarget = 0.0f;
    for (int i = 0; i < tabs.length; ++i) {
        if (screenTarget >= tabs[i].getLayoutTab().getY()) {
            break;
        }
        addAnimation(set, tabs[i], SCROLL_OFFSET, tabs[i].getScrollOffset(),
                StackTab.screenToScroll(screenTarget, warpSize), REACH_TOP_ANIMATION_DURATION,
                0);
        screenTarget += tabs[i].getLayoutTab().getScaledContentHeight();
    }

    return set;
}
 
Example #15
Source File: StackAnimation.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Responsible for generating the animations that flattens tabs when a pinch begins.
 *
 * @param tabs The tabs that make up the stack. These are the tabs that will
 *             be affected by the animations.
 * @return     The TabSwitcherAnimation instance that will tween the tabs to
 *             create the appropriate animation.
 */
protected ChromeAnimation<?> createStartPinchAnimatorSet(StackTab[] tabs) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    for (int i = 0; i < tabs.length; ++i) {
        addTiltScrollAnimation(
                set, tabs[i].getLayoutTab(), 0, START_PINCH_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #16
Source File: StackAnimation.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Responsible for generating the animations that make all the tabs do a full roll.
 *
 * @param tabs The tabs that make up the stack. These are the tabs that will be affected by the
 *             animations.
 * @return     The TabSwitcherAnimation instance that will tween the tabs to create the
 *             appropriate animation.
 */
protected ChromeAnimation<?> createFullRollAnimatorSet(StackTab[] tabs) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    for (int i = 0; i < tabs.length; ++i) {
        LayoutTab layoutTab = tabs[i].getLayoutTab();
        // Set the pivot
        layoutTab.setTiltX(layoutTab.getTiltX(), layoutTab.getScaledContentHeight() / 2.0f);
        layoutTab.setTiltY(layoutTab.getTiltY(), layoutTab.getScaledContentWidth() / 2.0f);
        // Create the angle animation
        addTiltScrollAnimation(set, layoutTab, -360.0f, FULL_ROLL_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #17
Source File: StackAnimation.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Responsible for generating the animations that flattens tabs when a pinch begins.
 *
 * @param tabs The tabs that make up the stack. These are the tabs that will
 *             be affected by the animations.
 * @return     The TabSwitcherAnimation instance that will tween the tabs to
 *             create the appropriate animation.
 */
protected ChromeAnimation<?> createStartPinchAnimatorSet(StackTab[] tabs) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    for (int i = 0; i < tabs.length; ++i) {
        addTiltScrollAnimation(
                set, tabs[i].getLayoutTab(), 0, START_PINCH_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #18
Source File: StripLayoutTab.java    From delion with Apache License 2.0 5 votes vote down vote up
private void startAnimation(Animation<Animatable<?>> animation, boolean finishPrevious) {
    if (finishPrevious) finishAnimation();

    if (mContentAnimations == null) {
        mContentAnimations = new ChromeAnimation<Animatable<?>>();
    }

    mContentAnimations.add(animation);
}
 
Example #19
Source File: LayoutTab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} from data extracted from a {@link Tab}.
 * As this function may be expensive and can be delayed we initialize it as a separately.
 *
 * @param backgroundColor       The color of the page background.
 * @param fallbackThumbnailId   The id of a cached thumbnail to show if the current
 *                              thumbnail is unavailable, or {@link Tab.INVALID_TAB_ID}
 *                              if none exists.
 * @param shouldStall           Whether the tab should display a desaturated thumbnail and
 *                              wait for the content layer to load.
 * @param canUseLiveTexture     Whether the tab can use a live texture when being displayed.
 * @return True if the init requires the compositor to update.
 */
public boolean initFromHost(int backgroundColor, boolean shouldStall, boolean canUseLiveTexture,
        int toolbarBackgroundColor, int textBoxBackgroundColor, float textBoxAlpha) {
    mBackgroundColor = backgroundColor;

    boolean needsUpdate = false;

    // If the toolbar color changed, animate between the old and new colors.
    if (mToolbarBackgroundColor != toolbarBackgroundColor && isVisible()
            && mInitFromHostCalled) {
        ChromeAnimation.Animation<ChromeAnimation.Animatable<?>>  themeColorAnimation =
                createAnimation(this, Property.TOOLBAR_COLOR, 0.0f, 1.0f,
                ToolbarPhone.THEME_COLOR_TRANSITION_DURATION, 0, false,
                BakedBezierInterpolator.TRANSFORM_CURVE);

        mInitialThemeColor = mToolbarBackgroundColor;
        mFinalThemeColor = toolbarBackgroundColor;

        if (mCurrentAnimations != null) {
            mCurrentAnimations.updateAndFinish();
        }

        mCurrentAnimations = new ChromeAnimation<ChromeAnimation.Animatable<?>>();
        mCurrentAnimations.add(themeColorAnimation);
        mCurrentAnimations.start();
        needsUpdate = true;
    } else {
        // If the layout tab isn't visible, just set the toolbar color without animating.
        mToolbarBackgroundColor = toolbarBackgroundColor;
    }

    mTextBoxBackgroundColor = textBoxBackgroundColor;
    mTextBoxAlpha = textBoxAlpha;
    mShouldStall = shouldStall;
    mCanUseLiveTexture = canUseLiveTexture;
    mInitFromHostCalled = true;

    return needsUpdate;
}
 
Example #20
Source File: StripLayoutHelper.java    From delion with Apache License 2.0 5 votes vote down vote up
private void startAnimation(Animation<Animatable<?>> animation, boolean finishPrevious) {
    if (finishPrevious) finishAnimation();

    if (mLayoutAnimations == null) {
        mLayoutAnimations = new ChromeAnimation<ChromeAnimation.Animatable<?>>();
    }

    mLayoutAnimations.add(animation);

    mUpdateHost.requestUpdate();
}
 
Example #21
Source File: StripLayoutHelper.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void startAnimation(Animation<Animatable<?>> animation, boolean finishPrevious) {
    if (finishPrevious) finishAnimation();

    if (mLayoutAnimations == null) {
        mLayoutAnimations = new ChromeAnimation<ChromeAnimation.Animatable<?>>();
    }

    mLayoutAnimations.add(animation);

    mUpdateHost.requestUpdate();
}
 
Example #22
Source File: OverlayPanelAnimation.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Appends an Animation to the current animation set and starts it immediately.  If the set is
 * already finished or doesn't exist, the animation set is also started.
 */
protected void addToAnimation(ChromeAnimation.Animation<Animatable<?>> component) {
    if (mLayoutAnimations == null || mLayoutAnimations.finished()) {
        onAnimationStarted();
        mLayoutAnimations = new ChromeAnimation<Animatable<?>>();
        mLayoutAnimations.start();
    }
    component.start();
    mLayoutAnimations.add(component);
    requestUpdate();
}
 
Example #23
Source File: OverlayPanelAnimation.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Appends an Animation to the current animation set and starts it immediately.  If the set is
 * already finished or doesn't exist, the animation set is also started.
 */
protected void addToAnimation(ChromeAnimation.Animation<Animatable<?>> component) {
    if (mLayoutAnimations == null || mLayoutAnimations.finished()) {
        onAnimationStarted();
        mLayoutAnimations = new ChromeAnimation<Animatable<?>>();
        mLayoutAnimations.start();
    }
    component.start();
    mLayoutAnimations.add(component);
    requestUpdate();
}
 
Example #24
Source File: StripLayoutHelper.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void startAnimation(Animation<Animatable<?>> animation, boolean finishPrevious) {
    if (finishPrevious) finishAnimation();

    if (mLayoutAnimations == null) {
        mLayoutAnimations = new ChromeAnimation<ChromeAnimation.Animatable<?>>();
    }

    mLayoutAnimations.add(animation);

    mUpdateHost.requestUpdate();
}
 
Example #25
Source File: StackAnimation.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Responsible for generating the animations that make all the tabs do a full roll.
 *
 * @param tabs The tabs that make up the stack. These are the tabs that will be affected by the
 *             animations.
 * @return     The TabSwitcherAnimation instance that will tween the tabs to create the
 *             appropriate animation.
 */
protected ChromeAnimation<?> createFullRollAnimatorSet(StackTab[] tabs) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    for (int i = 0; i < tabs.length; ++i) {
        LayoutTab layoutTab = tabs[i].getLayoutTab();
        // Set the pivot
        layoutTab.setTiltX(layoutTab.getTiltX(), layoutTab.getScaledContentHeight() / 2.0f);
        layoutTab.setTiltY(layoutTab.getTiltY(), layoutTab.getScaledContentWidth() / 2.0f);
        // Create the angle animation
        addTiltScrollAnimation(set, layoutTab, -360.0f, FULL_ROLL_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #26
Source File: StripLayoutTab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void startAnimation(Animation<Animatable<?>> animation, boolean finishPrevious) {
    if (finishPrevious) finishAnimation();

    if (mContentAnimations == null) {
        mContentAnimations = new ChromeAnimation<Animatable<?>>();
    }

    mContentAnimations.add(animation);
}
 
Example #27
Source File: StackAnimation.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Responsible for generating the animations that make all the tabs do a full roll.
 *
 * @param tabs The tabs that make up the stack. These are the tabs that will be affected by the
 *             animations.
 * @return     The TabSwitcherAnimation instance that will tween the tabs to create the
 *             appropriate animation.
 */
protected ChromeAnimation<?> createFullRollAnimatorSet(StackTab[] tabs) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();

    for (int i = 0; i < tabs.length; ++i) {
        LayoutTab layoutTab = tabs[i].getLayoutTab();
        // Set the pivot
        layoutTab.setTiltX(layoutTab.getTiltX(), layoutTab.getScaledContentHeight() / 2.0f);
        layoutTab.setTiltY(layoutTab.getTiltY(), layoutTab.getScaledContentWidth() / 2.0f);
        // Create the angle animation
        addTiltScrollAnimation(set, layoutTab, -360.0f, FULL_ROLL_ANIMATION_DURATION, 0);
    }

    return set;
}
 
Example #28
Source File: LayoutTab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} from data extracted from a {@link Tab}.
 * As this function may be expensive and can be delayed we initialize it as a separately.
 *
 * @param backgroundColor       The color of the page background.
 * @param fallbackThumbnailId   The id of a cached thumbnail to show if the current
 *                              thumbnail is unavailable, or {@link Tab.INVALID_TAB_ID}
 *                              if none exists.
 * @param shouldStall           Whether the tab should display a desaturated thumbnail and
 *                              wait for the content layer to load.
 * @param canUseLiveTexture     Whether the tab can use a live texture when being displayed.
 * @return True if the init requires the compositor to update.
 */
public boolean initFromHost(int backgroundColor, boolean shouldStall, boolean canUseLiveTexture,
        int toolbarBackgroundColor, int textBoxBackgroundColor, float textBoxAlpha) {
    mBackgroundColor = backgroundColor;

    boolean needsUpdate = false;

    // If the toolbar color changed, animate between the old and new colors.
    if (mToolbarBackgroundColor != toolbarBackgroundColor && isVisible()
            && mInitFromHostCalled) {
        ChromeAnimation.Animation<ChromeAnimation.Animatable<?>>  themeColorAnimation =
                createAnimation(this, Property.TOOLBAR_COLOR, 0.0f, 1.0f,
                ToolbarPhone.THEME_COLOR_TRANSITION_DURATION, 0, false,
                BakedBezierInterpolator.TRANSFORM_CURVE);

        mInitialThemeColor = mToolbarBackgroundColor;
        mFinalThemeColor = toolbarBackgroundColor;

        if (mCurrentAnimations != null) {
            mCurrentAnimations.updateAndFinish();
        }

        mCurrentAnimations = new ChromeAnimation<ChromeAnimation.Animatable<?>>();
        mCurrentAnimations.add(themeColorAnimation);
        mCurrentAnimations.start();
        needsUpdate = true;
    } else {
        // If the layout tab isn't visible, just set the toolbar color without animating.
        mToolbarBackgroundColor = toolbarBackgroundColor;
    }

    mTextBoxBackgroundColor = textBoxBackgroundColor;
    mTextBoxAlpha = textBoxAlpha;
    mShouldStall = shouldStall;
    mCanUseLiveTexture = canUseLiveTexture;
    mInitFromHostCalled = true;

    return needsUpdate;
}
 
Example #29
Source File: StackAnimationPortrait.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected ChromeAnimation<?> createNewTabOpenedAnimatorSet(
        StackTab[] tabs, int focusIndex, float discardRange) {
    return super.createNewTabOpenedAnimatorSet(tabs, focusIndex, -discardRange);
}
 
Example #30
Source File: StackAnimationPortrait.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected ChromeAnimation<?> createTabFocusedAnimatorSet(
        StackTab[] tabs, int focusIndex, int spacing, float warpSize) {
    ChromeAnimation<Animatable<?>> set = new ChromeAnimation<Animatable<?>>();
    for (int i = 0; i < tabs.length; ++i) {
        StackTab tab = tabs[i];
        LayoutTab layoutTab = tab.getLayoutTab();

        addTiltScrollAnimation(set, layoutTab, 0.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
        addAnimation(set, tab, DISCARD_AMOUNT, tab.getDiscardAmount(), 0.0f,
                TAB_FOCUSED_ANIMATION_DURATION, 0);

        if (i < focusIndex) {
            // For tabs above the focused tab move them up to 0.
            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    tab.getScrollOffset() - mHeight - spacing, TAB_FOCUSED_ANIMATION_DURATION,
                    0);
        } else if (i > focusIndex) {
            // We also need to animate the Y Translation to move them down
            // off the screen.
            float coveringTabPosition = layoutTab.getY();
            float distanceToBorder = MathUtils.clamp(mHeight - coveringTabPosition, 0, mHeight);
            float delay = TAB_FOCUSED_MAX_DELAY * distanceToBorder / mHeight;
            addAnimation(set, tab, Y_IN_STACK_OFFSET, tab.getYInStackOffset(),
                    tab.getYInStackOffset() + mHeight,
                    (TAB_FOCUSED_ANIMATION_DURATION - (long) delay), (long) delay);
        } else {
            // This is the focused tab.  We need to scale it back to
            // 1.0f, move it to the top of the screen, and animate the
            // YTranslation so that it looks like it is zooming into the
            // full screen view.
            tab.setXOutOfStack(0.0f);
            tab.setYOutOfStack(0.0f);
            layoutTab.setBorderScale(1.f);

            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(),
                    Math.max(0.0f, tab.getScrollOffset() - mWidth - spacing),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(
                    set, tab, SCALE, tab.getScale(), 1.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
            int tabYInfluenceDuration = FeatureUtilities.isChromeHomeEnabled()
                    ? TAB_FOCUSED_ANIMATION_DURATION
                    : TAB_FOCUSED_Y_STACK_DURATION;
            addAnimation(set, tab, Y_IN_STACK_INFLUENCE, tab.getYInStackInfluence(), 0.0f,
                    tabYInfluenceDuration, 0);
            addAnimation(set, tab.getLayoutTab(), MAX_CONTENT_HEIGHT,
                    tab.getLayoutTab().getMaxContentHeight(),
                    tab.getLayoutTab().getUnclampedOriginalContentHeight(),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            tab.setYOutOfStack(getStaticTabPosition());
            if (layoutTab.shouldStall()) {
                addAnimation(set, layoutTab, SATURATION, 1.0f, 0.0f,
                        TAB_FOCUSED_BORDER_ALPHA_DURATION, TAB_FOCUSED_BORDER_ALPHA_DELAY);
            }
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_ALPHA, layoutTab.getToolbarAlpha(),
                    1.f, TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), TOOLBAR_Y_OFFSET,
                    getToolbarOffsetToLineUpWithBorder(), 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
            addAnimation(set, tab.getLayoutTab(), SIDE_BORDER_SCALE, 1.f, 0.f,
                    TAB_FOCUSED_TOOLBAR_ALPHA_DURATION, TAB_FOCUSED_TOOLBAR_ALPHA_DELAY);
        }
    }

    return set;
}