org.chromium.chrome.browser.compositor.layouts.phone.stack.Stack Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.phone.stack.Stack. 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: StackLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost,
        EventFilter eventFilter) {
    super(context, updateHost, renderHost, eventFilter);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
Example #2
Source File: StackLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost) {
    super(context, updateHost, renderHost);

    mGestureHandler = new StackLayoutGestureHandler();
    mGestureEventFilter = new GestureEventFilter(context, mGestureHandler);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
Example #3
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost,
        EventFilter eventFilter) {
    super(context, updateHost, renderHost, eventFilter);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
Example #4
Source File: SimpleAnimationLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the position, scale, rotation and alpha values of mAnimatedTab.
 *
 * @param discard The value that specify how far along are we in the discard animation. 0 is
 *                filling the screen. Valid values are [-range .. range] where range is
 *                computed by {@link SimpleAnimationLayout#getDiscardRange()}.
 */
private void setDiscardAmount(float discard) {
    if (mAnimatedTab != null) {
        final float range = getDiscardRange();
        final float scale = Stack.computeDiscardScale(discard, range, true);

        final float deltaX = mAnimatedTab.getOriginalContentWidth();
        final float deltaY = mAnimatedTab.getOriginalContentHeight() / 2.f;
        mAnimatedTab.setX(deltaX * (1.f - scale));
        mAnimatedTab.setY(deltaY * (1.f - scale));
        mAnimatedTab.setScale(scale);
        mAnimatedTab.setBorderScale(scale);
        mAnimatedTab.setAlpha(Stack.computeDiscardAlpha(discard, range));
    }
}
 
Example #5
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts the tabs from a stack and append them into a list.
 * @param stack     The stack that contains the tabs.
 * @param outList   The output list where will be the tabs from the stack.
 * @param index     The current number of item in the outList.
 * @return The updated index incremented by the number of tabs in the stack.
 */
private static int addAllTabs(Stack stack, StackTab[] outList, int index) {
    StackTab[] stackTabs = stack.getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; ++i) {
            outList[index++] = stackTabs[i];
        }
    }
    return index;
}
 
Example #6
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onTabClosing(long time, int id) {
    Stack stack = getTabStack(id);
    if (stack == null) return;
    stack.tabClosingEffect(time, id);

    // Just in case we closed the last tab of a stack we need to trigger the overlap animation.
    startMarginAnimation(true);

    // Animate the stack to leave incognito mode.
    if (!mStacks[1].isDisplayable()) uiPreemptivelySelectTabModel(false);
}
 
Example #7
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onTabClosing(long time, int id) {
    Stack stack = getTabStack(id);
    if (stack == null) return;
    stack.tabClosingEffect(time, id);

    // Just in case we closed the last tab of a stack we need to trigger the overlap animation.
    startMarginAnimation(true);

    // Animate the stack to leave incognito mode.
    if (!mStacks[1].isDisplayable()) uiPreemptivelySelectTabModel(false);
}
 
Example #8
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts the tabs from a stack and append them into a list.
 * @param stack     The stack that contains the tabs.
 * @param outList   The output list where will be the tabs from the stack.
 * @param index     The current number of item in the outList.
 * @return The updated index incremented by the number of tabs in the stack.
 */
private static int addAllTabs(Stack stack, StackTab[] outList, int index) {
    StackTab[] stackTabs = stack.getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; ++i) {
            outList[index++] = stackTabs[i];
        }
    }
    return index;
}
 
Example #9
Source File: SimpleAnimationLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the position, scale, rotation and alpha values of mAnimatedTab.
 *
 * @param discard The value that specify how far along are we in the discard animation. 0 is
 *                filling the screen. Valid values are [-range .. range] where range is
 *                computed by {@link SimpleAnimationLayout#getDiscardRange()}.
 */
private void setDiscardAmount(float discard) {
    if (mAnimatedTab != null) {
        final float range = getDiscardRange();
        final float scale = Stack.computeDiscardScale(discard, range, true);

        final float deltaX = mAnimatedTab.getOriginalContentWidth();
        final float deltaY = mAnimatedTab.getOriginalContentHeight() / 2.f;
        mAnimatedTab.setX(deltaX * (1.f - scale));
        mAnimatedTab.setY(deltaY * (1.f - scale));
        mAnimatedTab.setScale(scale);
        mAnimatedTab.setBorderScale(scale);
        mAnimatedTab.setAlpha(Stack.computeDiscardAlpha(discard, range));
    }
}
 
Example #10
Source File: SimpleAnimationLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the position, scale, rotation and alpha values of mAnimatedTab.
 *
 * @param discard The value that specify how far along are we in the discard animation. 0 is
 *                filling the screen. Valid values are [-range .. range] where range is
 *                computed by {@link SimpleAnimationLayout#getDiscardRange()}.
 */
private void setDiscardAmount(float discard) {
    if (mAnimatedTab != null) {
        final float range = getDiscardRange();
        final float scale = Stack.computeDiscardScale(discard, range, true);

        final float deltaX = mAnimatedTab.getOriginalContentWidth();
        final float deltaY = mAnimatedTab.getOriginalContentHeight() / 2.f;
        mAnimatedTab.setX(deltaX * (1.f - scale));
        mAnimatedTab.setY(deltaY * (1.f - scale));
        mAnimatedTab.setScale(scale);
        mAnimatedTab.setBorderScale(scale);
        mAnimatedTab.setAlpha(Stack.computeDiscardAlpha(discard, range));
    }
}
 
Example #11
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onTabClosing(long time, int id) {
    Stack stack = getTabStack(id);
    if (stack == null) return;
    stack.tabClosingEffect(time, id);

    // Just in case we closed the last tab of a stack we need to trigger the overlap animation.
    startMarginAnimation(true);

    // Animate the stack to leave incognito mode.
    if (!mStacks[1].isDisplayable()) uiPreemptivelySelectTabModel(false);
}
 
Example #12
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts the tabs from a stack and append them into a list.
 * @param stack     The stack that contains the tabs.
 * @param outList   The output list where will be the tabs from the stack.
 * @param index     The current number of item in the outList.
 * @return The updated index incremented by the number of tabs in the stack.
 */
private static int addAllTabs(Stack stack, StackTab[] outList, int index) {
    StackTab[] stackTabs = stack.getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; ++i) {
            outList[index++] = stackTabs[i];
        }
    }
    return index;
}
 
Example #13
Source File: SimpleAnimationLayout.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return The range of the discard amount.
 */
private float getDiscardRange() {
    return Math.min(getWidth(), getHeight()) * Stack.DISCARD_RANGE_SCREEN;
}
 
Example #14
Source File: SimpleAnimationLayout.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return The range of the discard amount.
 */
private float getDiscardRange() {
    return Math.min(getWidth(), getHeight()) * Stack.DISCARD_RANGE_SCREEN;
}
 
Example #15
Source File: SimpleAnimationLayout.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return The range of the discard amount.
 */
private float getDiscardRange() {
    return Math.min(getWidth(), getHeight()) * Stack.DISCARD_RANGE_SCREEN;
}
 
Example #16
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack state for the given tab id.
 * @VisibleForTesting
 */
protected Stack getTabStack(int tabId) {
    return mStacks[getTabStackIndex(tabId)];
}
 
Example #17
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Get the tab stack state for the specified mode.
 *
 * @param incognito Whether the TabStackState to be returned should be the one for incognito.
 * @return The tab stack state for the given mode.
 * @VisibleForTesting
 */
public Stack getTabStack(boolean incognito) {
    return mStacks[incognito ? 1 : 0];
}
 
Example #18
Source File: StackLayout.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Get the tab stack state for the specified mode.
 *
 * @param incognito Whether the TabStackState to be returned should be the one for incognito.
 * @return The tab stack state for the given mode.
 * @VisibleForTesting
 */
public Stack getTabStack(boolean incognito) {
    return mStacks[incognito ? 1 : 0];
}
 
Example #19
Source File: StackLayout.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack state for the given tab id.
 * @VisibleForTesting
 */
protected Stack getTabStack(int tabId) {
    return mStacks[getTabStackIndex(tabId)];
}
 
Example #20
Source File: StackLayout.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack state for the given tab id.
 * @VisibleForTesting
 */
protected Stack getTabStack(int tabId) {
    return mStacks[getTabStackIndex(tabId)];
}
 
Example #21
Source File: StackLayout.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Get the tab stack state for the specified mode.
 *
 * @param incognito Whether the TabStackState to be returned should be the one for incognito.
 * @return The tab stack state for the given mode.
 * @VisibleForTesting
 */
public Stack getTabStack(boolean incognito) {
    return mStacks[incognito ? 1 : 0];
}