Search in sources :

Example 16 with LayoutTab

use of org.chromium.chrome.browser.compositor.layouts.components.LayoutTab in project AndroidChromium by JackyAndroid.

the class TabListSceneLayer method pushLayers.

/**
     * Pushes all relevant {@link LayoutTab}s from a {@link Layout} to the CC Layer tree.  This will
     * let them be rendered on the screen.  This should only be called when the Compositor has
     * disabled ScheduleComposite calls as this will change the tree and could subsequently cause
     * unnecessary follow up renders.
     * @param context         The {@link Context} to use to query device information.
     * @param layout          The {@link Layout} to push to the screen.
     */
public void pushLayers(Context context, Rect viewport, Rect contentViewport, Layout layout, LayerTitleCache layerTitleCache, TabContentManager tabContentManager, ResourceManager resourceManager) {
    if (mNativePtr == 0)
        return;
    Resources res = context.getResources();
    final float dpToPx = res.getDisplayMetrics().density;
    LayoutTab[] tabs = layout.getLayoutTabsToRender();
    int tabsCount = tabs != null ? tabs.length : 0;
    nativeBeginBuildingFrame(mNativePtr);
    nativeUpdateLayer(mNativePtr, getTabListBackgroundColor(context), viewport.left, viewport.top, viewport.width(), viewport.height(), layerTitleCache, tabContentManager, resourceManager);
    for (int i = 0; i < tabsCount; i++) {
        LayoutTab t = tabs[i];
        assert t.isVisible() : "LayoutTab in that list should be visible";
        final float decoration = t.getDecorationAlpha();
        int defaultThemeColor = t.isIncognito() ? ApiCompatibilityUtils.getColor(res, R.color.incognito_primary_color) : ApiCompatibilityUtils.getColor(res, R.color.default_primary_color);
        int closeButtonColor = ColorUtils.getThemedAssetColor(t.getToolbarBackgroundColor(), t.isIncognito());
        int borderColorResource = t.isIncognito() ? R.color.tab_back_incognito : R.color.tab_back;
        // TODO(dtrainor, clholgat): remove "* dpToPx" once the native part fully supports dp.
        nativePutTabLayer(mNativePtr, t.getId(), R.id.control_container, R.drawable.btn_tab_close, R.drawable.tabswitcher_border_frame_shadow, R.drawable.tabswitcher_border_frame_decoration, R.drawable.logo_card_back, R.drawable.tabswitcher_border_frame, R.drawable.tabswitcher_border_frame_inner_shadow, t.canUseLiveTexture(), t.getBackgroundColor(), ApiCompatibilityUtils.getColor(res, borderColorResource), t.isIncognito(), layout.getOrientation() == Orientation.PORTRAIT, t.getRenderX() * dpToPx, t.getRenderY() * dpToPx, t.getScaledContentWidth() * dpToPx, t.getScaledContentHeight() * dpToPx, t.getOriginalContentWidth() * dpToPx, t.getOriginalContentHeight() * dpToPx, contentViewport.height(), t.getClippedX() * dpToPx, t.getClippedY() * dpToPx, Math.min(t.getClippedWidth(), t.getScaledContentWidth()) * dpToPx, Math.min(t.getClippedHeight(), t.getScaledContentHeight()) * dpToPx, t.getTiltXPivotOffset() * dpToPx, t.getTiltYPivotOffset() * dpToPx, t.getTiltX(), t.getTiltY(), t.getAlpha(), t.getBorderAlpha() * decoration, t.getBorderInnerShadowAlpha() * decoration, decoration, t.getShadowOpacity() * decoration, t.getBorderCloseButtonAlpha() * decoration, LayoutTab.CLOSE_BUTTON_WIDTH_DP * dpToPx, t.getStaticToViewBlend(), t.getBorderScale(), t.getSaturation(), t.getBrightness(), t.showToolbar(), defaultThemeColor, t.getToolbarBackgroundColor(), closeButtonColor, t.anonymizeToolbar(), R.drawable.textbox, t.getTextBoxBackgroundColor(), t.getTextBoxAlpha(), t.getToolbarAlpha(), t.getToolbarYOffset() * dpToPx, t.getSideBorderScale(), true, t.insetBorderVertical());
    }
    nativeFinishBuildingFrame(mNativePtr);
}
Also used : Resources(android.content.res.Resources) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)

Example 17 with LayoutTab

use of org.chromium.chrome.browser.compositor.layouts.components.LayoutTab in project AndroidChromium by JackyAndroid.

the class StackAnimation method createFullRollAnimatorSet.

/**
     * 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;
}
Also used : ChromeAnimation(org.chromium.chrome.browser.compositor.layouts.ChromeAnimation) Animatable(org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)

Example 18 with LayoutTab

use of org.chromium.chrome.browser.compositor.layouts.components.LayoutTab in project AndroidChromium by JackyAndroid.

the class StackAnimationLandscape method createTabFocusedAnimatorSet.

@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 left of the focused tab move them left to 0.
            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(), Math.max(0.0f, tab.getScrollOffset() - mWidth - spacing), TAB_FOCUSED_ANIMATION_DURATION, 0);
        } else if (i > focusIndex) {
            // We also need to animate the X Translation to move them right
            // off the screen.
            float coveringTabPosition = layoutTab.getX();
            float distanceToBorder = LocalizationUtils.isLayoutRtl() ? coveringTabPosition + layoutTab.getScaledContentWidth() : mWidth - coveringTabPosition;
            float clampedDistanceToBorder = MathUtils.clamp(distanceToBorder, 0, mWidth);
            float delay = TAB_FOCUSED_MAX_DELAY * clampedDistanceToBorder / mWidth;
            addAnimation(set, tab, X_IN_STACK_OFFSET, tab.getXInStackOffset(), tab.getXInStackOffset() + (LocalizationUtils.isLayoutRtl() ? -mWidth : mWidth), (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
            // X Translation so that it looks like it is zooming into the
            // full screen view.  We move the card to the top left and extend it out so
            // it becomes a full card.
            tab.setXOutOfStack(0);
            tab.setYOutOfStack(0.0f);
            layoutTab.setBorderScale(1.f);
            addAnimation(set, tab, SCROLL_OFFSET, tab.getScrollOffset(), StackTab.screenToScroll(0, warpSize), TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(set, tab, SCALE, tab.getScale(), 1.0f, TAB_FOCUSED_ANIMATION_DURATION, 0);
            addAnimation(set, tab, X_IN_STACK_INFLUENCE, tab.getXInStackInfluence(), 0.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;
}
Also used : ChromeAnimation(org.chromium.chrome.browser.compositor.layouts.ChromeAnimation) Animatable(org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)

Example 19 with LayoutTab

use of org.chromium.chrome.browser.compositor.layouts.components.LayoutTab in project AndroidChromium by JackyAndroid.

the class StackAnimationPortrait method createTabFocusedAnimatorSet.

@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;
}
Also used : ChromeAnimation(org.chromium.chrome.browser.compositor.layouts.ChromeAnimation) Animatable(org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)

Example 20 with LayoutTab

use of org.chromium.chrome.browser.compositor.layouts.components.LayoutTab in project AndroidChromium by JackyAndroid.

the class SimpleAnimationLayout method tabCreatedInForeground.

/**
     * Animate opening a tab in the foreground.
     *
     * @param id             The id of the new tab to animate.
     * @param sourceId       The id of the tab that spawned this new tab.
     * @param newIsIncognito true if the new tab is an incognito tab.
     * @param originX        The X coordinate of the last touch down event that spawned this tab.
     * @param originY        The Y coordinate of the last touch down event that spawned this tab.
     */
private void tabCreatedInForeground(int id, int sourceId, boolean newIsIncognito, float originX, float originY) {
    LayoutTab newLayoutTab = createLayoutTab(id, newIsIncognito, NO_CLOSE_BUTTON, NO_TITLE);
    if (mLayoutTabs == null || mLayoutTabs.length == 0) {
        mLayoutTabs = new LayoutTab[] { newLayoutTab };
    } else {
        mLayoutTabs = new LayoutTab[] { mLayoutTabs[0], newLayoutTab };
    }
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id, sourceId)));
    newLayoutTab.setBorderAlpha(0.0f);
    newLayoutTab.setStaticToViewBlend(1.f);
    forceAnimationToFinish();
    Interpolator interpolator = BakedBezierInterpolator.TRANSFORM_CURVE;
    addToAnimation(newLayoutTab, LayoutTab.Property.SCALE, 0.f, 1.f, FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.ALPHA, 0.f, 1.f, FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.X, originX, 0.f, FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.Y, originY, 0.f, FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    mTabModelSelector.selectModel(newIsIncognito);
    startHiding(id, false);
}
Also used : Interpolator(android.view.animation.Interpolator) BakedBezierInterpolator(org.chromium.ui.interpolators.BakedBezierInterpolator) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)

Aggregations

LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)25 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)4 ChromeAnimation (org.chromium.chrome.browser.compositor.layouts.ChromeAnimation)3 Animatable (org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable)3 Tab (org.chromium.chrome.browser.tab.Tab)2 OverviewListLayout (org.chromium.chrome.browser.widget.OverviewListLayout)2 Resources (android.content.res.Resources)1 Interpolator (android.view.animation.Interpolator)1 ArrayList (java.util.ArrayList)1 Layout (org.chromium.chrome.browser.compositor.layouts.Layout)1 StackLayout (org.chromium.chrome.browser.compositor.layouts.phone.StackLayout)1 SceneLayer (org.chromium.chrome.browser.compositor.scene_layer.SceneLayer)1 TabModelSelector (org.chromium.chrome.browser.tabmodel.TabModelSelector)1 DocumentTabModelSelector (org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector)1 BakedBezierInterpolator (org.chromium.ui.interpolators.BakedBezierInterpolator)1