Java Code Examples for org.chromium.chrome.browser.compositor.layouts.components.LayoutTab#getY()

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.components.LayoutTab#getY() . 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: StackAnimationPortrait.java    From delion 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);
            addAnimation(set, tab, Y_IN_STACK_INFLUENCE, tab.getYInStackInfluence(), 0.0f,
                    TAB_FOCUSED_Y_STACK_DURATION, 0);
            addAnimation(set, tab.getLayoutTab(), MAX_CONTENT_HEIGHT,
                    tab.getLayoutTab().getMaxContentHeight(),
                    tab.getLayoutTab().getUnclampedOriginalContentHeight(),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            tab.setYOutOfStack(mHeight - mHeightMinusTopControls - mBorderTopHeight);
            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;
}
 
Example 2
Source File: StackAnimationPortrait.java    From AndroidChromium 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);
            addAnimation(set, tab, Y_IN_STACK_INFLUENCE, tab.getYInStackInfluence(), 0.0f,
                    TAB_FOCUSED_Y_STACK_DURATION, 0);
            addAnimation(set, tab.getLayoutTab(), MAX_CONTENT_HEIGHT,
                    tab.getLayoutTab().getMaxContentHeight(),
                    tab.getLayoutTab().getUnclampedOriginalContentHeight(),
                    TAB_FOCUSED_ANIMATION_DURATION, 0);
            tab.setYOutOfStack(mHeight - mHeightMinusBrowserControls - mBorderTopHeight);
            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;
}
 
Example 3
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;
}