org.chromium.chrome.browser.compositor.layouts.Layout.Orientation Java Examples
The following examples show how to use
org.chromium.chrome.browser.compositor.layouts.Layout.Orientation.
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: Stack.java From 365browser with Apache License 2.0 | 6 votes |
/** * Called on drag event (from scroll events in the gesture detector). * * @param time The current time of the app in ms. * @param x The x coordinate of the end of the drag event. * @param y The y coordinate of the end of the drag event. * @param amountX The number of pixels dragged in the x direction since the last event. * @param amountY The number of pixels dragged in the y direction since the last event. */ public void drag(long time, float x, float y, float amountX, float amountY) { float scrollDrag, discardDrag; if (mCurrentMode == Orientation.PORTRAIT) { discardDrag = amountX; scrollDrag = amountY; } else { discardDrag = amountY; scrollDrag = LocalizationUtils.isLayoutRtl() ? -amountX : amountX; } DragLock hintLock = computeDragLock(scrollDrag, discardDrag); if (hintLock == DragLock.DISCARD) { discard(x, y, amountX, amountY); } else { // Only cancel the current discard attempt if the scroll lock is committed: // by using mDragLock instead of hintLock. if (mDragLock == DragLock.SCROLL && mDiscardingTab != null) { commitDiscard(time, false); } scroll(x, y, LocalizationUtils.isLayoutRtl() ? -amountX : amountX, amountY, false); } requestUpdate(); }
Example #2
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void updateOverscrollOffset() { float clamped = MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false)); if (!allowOverscroll()) { mScrollOffset = clamped; } float overscroll = mScrollOffset - clamped; // Counts the number of overscroll push in the same direction in a row. int derivativeState = (int) Math.signum(Math.abs(mOverScrollOffset) - Math.abs(overscroll)); if (derivativeState != mOverScrollDerivative && derivativeState == 1 && overscroll < 0) { mOverScrollCounter++; } else if (overscroll > 0 || mCurrentMode == Orientation.LANDSCAPE) { mOverScrollCounter = 0; } mOverScrollDerivative = derivativeState; mOverScrollOffset = overscroll; }
Example #3
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Called on drag event (from scroll events in the gesture detector). * * @param time The current time of the app in ms. * @param x The x coordinate of the end of the drag event. * @param y The y coordinate of the end of the drag event. * @param amountX The number of pixels dragged in the x direction since the last event. * @param amountY The number of pixels dragged in the y direction since the last event. */ public void drag(long time, float x, float y, float amountX, float amountY) { float scrollDrag, discardDrag; if (mCurrentMode == Orientation.PORTRAIT) { discardDrag = amountX; scrollDrag = amountY; } else { discardDrag = amountY; scrollDrag = LocalizationUtils.isLayoutRtl() ? -amountX : amountX; } DragLock hintLock = computeDragLock(scrollDrag, discardDrag); if (hintLock == DragLock.DISCARD) { discard(x, y, amountX, amountY); } else { // Only cancel the current discard attempt if the scroll lock is committed: // by using mDragLock instead of hintLock. if (mDragLock == DragLock.SCROLL && mDiscardingTab != null) { commitDiscard(time, false); } scroll(x, y, LocalizationUtils.isLayoutRtl() ? -amountX : amountX, amountY, false); } requestUpdate(); }
Example #4
Source File: StackAnimation.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * The factory method that creates the particular factory method based on the orientation * parameter. * * @param width The width of the layout in dp. * @param height The height of the layout in dp. * @param heightMinusBrowserControls The height of the layout minus the browser controls in dp. * @param borderFramePaddingTop The top padding of the border frame in dp. * @param borderFramePaddingTopOpaque The opaque top padding of the border frame in dp. * @param borderFramePaddingLeft The left padding of the border frame in dp. * @param orientation The orientation that will be used to create the * appropriate {@link StackAnimation}. * @return The TabSwitcherAnimationFactory instance. */ public static StackAnimation createAnimationFactory(float width, float height, float heightMinusBrowserControls, float borderFramePaddingTop, float borderFramePaddingTopOpaque, float borderFramePaddingLeft, int orientation) { StackAnimation factory = null; switch (orientation) { case Orientation.LANDSCAPE: factory = new StackAnimationLandscape(width, height, heightMinusBrowserControls, borderFramePaddingTop, borderFramePaddingTopOpaque, borderFramePaddingLeft); break; case Orientation.PORTRAIT: default: factory = new StackAnimationPortrait(width, height, heightMinusBrowserControls, borderFramePaddingTop, borderFramePaddingTopOpaque, borderFramePaddingLeft); break; } return factory; }
Example #5
Source File: StackAnimation.java From delion with Apache License 2.0 | 6 votes |
/** * The factory method that creates the particular factory method based on the orientation * parameter. * * @param width The width of the layout in dp. * @param height The height of the layout in dp. * @param heightMinusTopControls The height of the layout minus the top controls in dp. * @param borderFramePaddingTop The top padding of the border frame in dp. * @param borderFramePaddingTopOpaque The opaque top padding of the border frame in dp. * @param borderFramePaddingLeft The left padding of the border frame in dp. * @param orientation The orientation that will be used to create the * appropriate {@link StackAnimation}. * @return The TabSwitcherAnimationFactory instance. */ public static StackAnimation createAnimationFactory(float width, float height, float heightMinusTopControls, float borderFramePaddingTop, float borderFramePaddingTopOpaque, float borderFramePaddingLeft, int orientation) { StackAnimation factory = null; switch (orientation) { case Orientation.LANDSCAPE: factory = new StackAnimationLandscape(width, height, heightMinusTopControls, borderFramePaddingTop, borderFramePaddingTopOpaque, borderFramePaddingLeft); break; case Orientation.PORTRAIT: default: factory = new StackAnimationPortrait(width, height, heightMinusTopControls, borderFramePaddingTop, borderFramePaddingTopOpaque, borderFramePaddingLeft); break; } return factory; }
Example #6
Source File: Stack.java From delion with Apache License 2.0 | 6 votes |
private void updateOverscrollOffset() { float clamped = MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false)); if (!allowOverscroll()) { mScrollOffset = clamped; } float overscroll = mScrollOffset - clamped; // Counts the number of overscroll push in the same direction in a row. int derivativeState = (int) Math.signum(Math.abs(mOverScrollOffset) - Math.abs(overscroll)); if (derivativeState != mOverScrollDerivative && derivativeState == 1 && overscroll < 0) { mOverScrollCounter++; } else if (overscroll > 0 || mCurrentMode == Orientation.LANDSCAPE) { mOverScrollCounter = 0; } mOverScrollDerivative = derivativeState; mOverScrollOffset = overscroll; }
Example #7
Source File: Stack.java From 365browser with Apache License 2.0 | 6 votes |
private void updateOverscrollOffset() { float clamped = MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false)); if (!allowOverscroll()) { mScrollOffset = clamped; } float overscroll = mScrollOffset - clamped; // Counts the number of overscroll push in the same direction in a row. int derivativeState = (int) Math.signum(Math.abs(mOverScrollOffset) - Math.abs(overscroll)); if (derivativeState != mOverScrollDerivative && derivativeState == 1 && overscroll < 0) { mOverScrollCounter++; } else if (overscroll > 0 || mCurrentMode == Orientation.LANDSCAPE) { mOverScrollCounter = 0; } mOverScrollDerivative = derivativeState; mOverScrollOffset = overscroll; }
Example #8
Source File: Stack.java From delion with Apache License 2.0 | 6 votes |
/** * Called on drag event (from scroll events in the gesture detector). * * @param time The current time of the app in ms. * @param x The x coordinate of the end of the drag event. * @param y The y coordinate of the end of the drag event. * @param amountX The number of pixels dragged in the x direction since the last event. * @param amountY The number of pixels dragged in the y direction since the last event. */ public void drag(long time, float x, float y, float amountX, float amountY) { float scrollDrag, discardDrag; if (mCurrentMode == Orientation.PORTRAIT) { discardDrag = amountX; scrollDrag = amountY; } else { discardDrag = amountY; scrollDrag = LocalizationUtils.isLayoutRtl() ? -amountX : amountX; } DragLock hintLock = computeDragLock(scrollDrag, discardDrag); if (hintLock == DragLock.DISCARD) { discard(x, y, amountX, amountY); } else { // Only cancel the current discard attempt if the scroll lock is committed: // by using mDragLock instead of hintLock. if (mDragLock == DragLock.SCROLL && mDiscardingTab != null) { commitDiscard(time, false); } scroll(x, y, LocalizationUtils.isLayoutRtl() ? -amountX : amountX, amountY, false); } requestUpdate(); }
Example #9
Source File: StackAnimation.java From 365browser with Apache License 2.0 | 6 votes |
/** * The factory method that creates the particular factory method based on the orientation * parameter. * * @param stack The stack of tabs being animated. * @param width The width of the layout in dp. * @param height The height of the layout in dp. * @param heightMinusBrowserControls The height of the layout minus the browser controls in dp. * @param borderFramePaddingTop The top padding of the border frame in dp. * @param borderFramePaddingTopOpaque The opaque top padding of the border frame in dp. * @param borderFramePaddingLeft The left padding of the border frame in dp. * @param orientation The orientation that will be used to create the * appropriate {@link StackAnimation}. * @return The TabSwitcherAnimationFactory instance. */ public static StackAnimation createAnimationFactory(Stack stack, float width, float height, float heightMinusBrowserControls, float borderFramePaddingTop, float borderFramePaddingTopOpaque, float borderFramePaddingLeft, int orientation) { StackAnimation factory = null; switch (orientation) { case Orientation.LANDSCAPE: factory = new StackAnimationLandscape(stack, width, height, heightMinusBrowserControls, borderFramePaddingTop, borderFramePaddingTopOpaque, borderFramePaddingLeft); break; case Orientation.PORTRAIT: default: factory = new StackAnimationPortrait(stack, width, height, heightMinusBrowserControls, borderFramePaddingTop, borderFramePaddingTopOpaque, borderFramePaddingLeft); break; } return factory; }
Example #10
Source File: Stack.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called on touch click event. * * @param time The current time of the app in ms. * @param x The x coordinate in pixel inside the stack view. * @param y The y coordinate in pixel inside the stack view. */ public void click(long time, float x, float y) { if (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.UNDISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) { return; } int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop()); if (clicked >= 0) { // Check if the click was within the boundaries of the close button defined by its // visible coordinates. boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) { // Tell the model to close the tab because the close button was pressed. The model // will then trigger a notification which will start the actual close process here // if necessary. StackTab tab = mStackTabs[clicked]; final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f; final float halfCloseBtnHeight = mBorderTopPadding / 2.f; final float contentWidth = tab.getLayoutTab().getOriginalContentWidth(); tab.setDiscardOriginY(halfCloseBtnHeight); tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth); tab.setDiscardFromClick(true); mLayout.uiRequestingCloseTab(time, tab.getId()); RecordUserAction.record("MobileStackViewCloseTab"); RecordUserAction.record("MobileTabClosed"); } else { // Let the model know that a new {@link LayoutTab} was selected. The model will // notify us if we need to do anything visual. setIndex() will possibly switch the // models and broadcast the event. mLayout.uiSelectingTab(time, mStackTabs[clicked].getId()); } } }
Example #11
Source File: Stack.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return The maximum height of a layout tab in the tab switcher. */ public float getMaxTabHeight() { if (FeatureUtilities.isChromeHomeEnabled() && mCurrentMode == Orientation.PORTRAIT) { return mLayout.getHeight(); } return mLayout.getHeightMinusBrowserControls(); }
Example #12
Source File: Stack.java From delion with Apache License 2.0 | 5 votes |
/** * Animates all the tabs closing at once. * * @param time The current time of the app in ms. */ public void tabsAllClosingEffect(long time) { boolean needAnimation = false; if (mStackTabs != null) { for (int i = 0; i < mStackTabs.length; ++i) { needAnimation |= !mStackTabs[i].isDying(); mStackTabs[i].setDying(true); } } else { // This needs to be set to true to handle the case where both the normal and incognito // tabs are being closed. needAnimation = true; } if (needAnimation) { mScrollOffsetForDyingTabs = mScrollOffset; mSpacing = computeSpacing(0); if (mStackTabs != null) { boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); for (int i = 0; i < mStackTabs.length; i++) { StackTab tab = mStackTabs[i]; tab.setDiscardOriginY(0.f); tab.setDiscardOriginX( isRtl ? 0.f : tab.getLayoutTab().getOriginalContentWidth()); tab.setDiscardFromClick(true); } } startAnimation(time, OverviewAnimationType.DISCARD_ALL); } mIsDying = true; }
Example #13
Source File: Stack.java From 365browser with Apache License 2.0 | 5 votes |
/** * Animates all the tabs closing at once. * * @param time The current time of the app in ms. */ public void tabsAllClosingEffect(long time) { boolean needAnimation = false; if (mStackTabs != null) { for (int i = 0; i < mStackTabs.length; ++i) { needAnimation |= !mStackTabs[i].isDying(); mStackTabs[i].setDying(true); } } else { // This needs to be set to true to handle the case where both the normal and incognito // tabs are being closed. needAnimation = true; } if (needAnimation) { mScrollOffsetForDyingTabs = mScrollOffset; mSpacing = computeSpacing(0); if (mStackTabs != null) { boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); for (int i = 0; i < mStackTabs.length; i++) { StackTab tab = mStackTabs[i]; tab.setDiscardOriginY(0.f); tab.setDiscardOriginX( isRtl ? 0.f : tab.getLayoutTab().getOriginalContentWidth()); tab.setDiscardFromClick(true); } } startAnimation(time, OverviewAnimationType.DISCARD_ALL); } mIsDying = true; }
Example #14
Source File: Stack.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called when the swipe animation get initiated. It gives a chance to initialize everything. * @param time The current time of the app in ms. * @param direction The direction the swipe is in. * @param x The horizontal coordinate the swipe started at in dp. * @param y The vertical coordinate the swipe started at in dp. */ public void swipeStarted(long time, ScrollDirection direction, float x, float y) { if (direction != ScrollDirection.DOWN) return; // Turn off warping the tabs because we need them to track the user's finger. setWarpState(false, false); // Restart the enter stack animation with the new warp values. startAnimation(time, OverviewAnimationType.ENTER_STACK); // Update the scroll offset to put the focused tab at the top. final int index = mTabModel.index(); if (mCurrentMode == Orientation.PORTRAIT) { mScrollOffset = -index * mSpacing; } else { mScrollOffset = -index * mSpacing + x - LANDSCAPE_SWIPE_DRAG_TAB_OFFSET_DP; mScrollOffset = MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false)); } setScrollTarget(mScrollOffset, true); // Don't let the tabs even out during this scroll. mEvenOutProgress = 1.f; // Set up the tracking scroll parameters. mSwipeUnboundScrollOffset = mScrollOffset; mSwipeBoundedScrollOffset = mScrollOffset; // Reset other state. mSwipeIsCancelable = false; mSwipeCanScroll = false; mInSwipe = true; }
Example #15
Source File: LayoutManager.java From 365browser with Apache License 2.0 | 5 votes |
private int getOrientation() { if (mHost.getWidth() > mHost.getHeight()) { return Orientation.LANDSCAPE; } else { return Orientation.PORTRAIT; } }
Example #16
Source File: StackTab.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @param orientation The orientation to choose to get the size. * @return The size of the content along the provided orientation. */ public float getSizeInScrollDirection(int orientation) { if (orientation == Orientation.PORTRAIT) { return mLayoutTab.getScaledContentHeight(); } else { return mLayoutTab.getScaledContentWidth(); } }
Example #17
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Called when the swipe animation get initiated. It gives a chance to initialize everything. * @param time The current time of the app in ms. * @param direction The direction the swipe is in. * @param x The horizontal coordinate the swipe started at in dp. * @param y The vertical coordinate the swipe started at in dp. */ public void swipeStarted(long time, ScrollDirection direction, float x, float y) { if (direction != ScrollDirection.DOWN) return; // Turn off warping the tabs because we need them to track the user's finger. setWarpState(false, false); // Restart the enter stack animation with the new warp values. startAnimation(time, OverviewAnimationType.ENTER_STACK); // Update the scroll offset to put the focused tab at the top. final int index = mTabModel.index(); if (mCurrentMode == Orientation.PORTRAIT) { mScrollOffset = -index * mSpacing; } else { mScrollOffset = -index * mSpacing + x - LANDSCAPE_SWIPE_DRAG_TAB_OFFSET_DP; mScrollOffset = MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false)); } setScrollTarget(mScrollOffset, true); // Don't let the tabs even out during this scroll. mEvenOutProgress = 1.f; // Set up the tracking scroll parameters. mSwipeUnboundScrollOffset = mScrollOffset; mSwipeBoundedScrollOffset = mScrollOffset; // Reset other state. mSwipeIsCancelable = false; mSwipeCanScroll = false; mInSwipe = true; }
Example #18
Source File: StackTab.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param orientation The orientation to choose to get the size. * @return The size of the content along the provided orientation. */ public float getSizeInScrollDirection(int orientation) { if (orientation == Orientation.PORTRAIT) { return mLayoutTab.getScaledContentHeight(); } else { return mLayoutTab.getScaledContentWidth(); } }
Example #19
Source File: LayoutManager.java From delion with Apache License 2.0 | 5 votes |
private int getOrientation() { if (mLastContentWidthDp > mLastContentHeightDp) { return Orientation.LANDSCAPE; } else { return Orientation.PORTRAIT; } }
Example #20
Source File: Stack.java From delion with Apache License 2.0 | 5 votes |
/** * Called on touch click event. * * @param time The current time of the app in ms. * @param x The x coordinate in pixel inside the stack view. * @param y The y coordinate in pixel inside the stack view. */ public void click(long time, float x, float y) { if (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.UNDISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) { return; } int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop()); if (clicked >= 0) { // Check if the click was within the boundaries of the close button defined by its // visible coordinates. boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) { // Tell the model to close the tab because the close button was pressed. The model // will then trigger a notification which will start the actual close process here // if necessary. StackTab tab = mStackTabs[clicked]; final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f; final float halfCloseBtnHeight = mBorderTopPadding / 2.f; final float contentWidth = tab.getLayoutTab().getOriginalContentWidth(); tab.setDiscardOriginY(halfCloseBtnHeight); tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth); tab.setDiscardFromClick(true); mLayout.uiRequestingCloseTab(time, tab.getId()); RecordUserAction.record("MobileStackViewCloseTab"); RecordUserAction.record("MobileTabClosed"); } else { // Let the model know that a new {@link LayoutTab} was selected. The model will // notify us if we need to do anything visual. setIndex() will possibly switch the // models and broadcast the event. mLayout.uiSelectingTab(time, mStackTabs[clicked].getId()); } } }
Example #21
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Animates all the tabs closing at once. * * @param time The current time of the app in ms. */ public void tabsAllClosingEffect(long time) { boolean needAnimation = false; if (mStackTabs != null) { for (int i = 0; i < mStackTabs.length; ++i) { needAnimation |= !mStackTabs[i].isDying(); mStackTabs[i].setDying(true); } } else { // This needs to be set to true to handle the case where both the normal and incognito // tabs are being closed. needAnimation = true; } if (needAnimation) { mScrollOffsetForDyingTabs = mScrollOffset; mSpacing = computeSpacing(0); if (mStackTabs != null) { boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); for (int i = 0; i < mStackTabs.length; i++) { StackTab tab = mStackTabs[i]; tab.setDiscardOriginY(0.f); tab.setDiscardOriginX( isRtl ? 0.f : tab.getLayoutTab().getOriginalContentWidth()); tab.setDiscardFromClick(true); } } startAnimation(time, OverviewAnimationType.DISCARD_ALL); } mIsDying = true; }
Example #22
Source File: LayoutManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
private int getOrientation() { if (mLastContentWidthDp > mLastContentHeightDp) { return Orientation.LANDSCAPE; } else { return Orientation.PORTRAIT; } }
Example #23
Source File: StackTab.java From delion with Apache License 2.0 | 5 votes |
/** * @param orientation The orientation to choose to get the size. * @return The size of the content along the provided orientation. */ public float getSizeInScrollDirection(int orientation) { if (orientation == Orientation.PORTRAIT) { return mLayoutTab.getScaledContentHeight(); } else { return mLayoutTab.getScaledContentWidth(); } }
Example #24
Source File: Stack.java From delion with Apache License 2.0 | 5 votes |
/** * Called when the swipe animation get initiated. It gives a chance to initialize everything. * @param time The current time of the app in ms. * @param direction The direction the swipe is in. * @param x The horizontal coordinate the swipe started at in dp. * @param y The vertical coordinate the swipe started at in dp. */ public void swipeStarted(long time, ScrollDirection direction, float x, float y) { if (direction != ScrollDirection.DOWN) return; // Turn off warping the tabs because we need them to track the user's finger. setWarpState(false, false); // Restart the enter stack animation with the new warp values. startAnimation(time, OverviewAnimationType.ENTER_STACK); // Update the scroll offset to put the focused tab at the top. final int index = mTabModel.index(); if (mCurrentMode == Orientation.PORTRAIT) { mScrollOffset = -index * mSpacing; } else { mScrollOffset = -index * mSpacing + x - LANDSCAPE_SWIPE_DRAG_TAB_OFFSET_DP; mScrollOffset = MathUtils.clamp(mScrollOffset, getMinScroll(false), getMaxScroll(false)); } setScrollTarget(mScrollOffset, true); // Don't let the tabs even out during this scroll. mEvenOutProgress = 1.f; // Set up the tracking scroll parameters. mSwipeUnboundScrollOffset = mScrollOffset; mSwipeBoundedScrollOffset = mScrollOffset; // Reset other state. mSwipeIsCancelable = false; mSwipeCanScroll = false; mInSwipe = true; }
Example #25
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Called on touch click event. * * @param time The current time of the app in ms. * @param x The x coordinate in pixel inside the stack view. * @param y The y coordinate in pixel inside the stack view. */ public void click(long time, float x, float y) { if (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.UNDISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) { return; } int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop()); if (clicked >= 0) { // Check if the click was within the boundaries of the close button defined by its // visible coordinates. boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) { // Tell the model to close the tab because the close button was pressed. The model // will then trigger a notification which will start the actual close process here // if necessary. StackTab tab = mStackTabs[clicked]; final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f; final float halfCloseBtnHeight = mBorderTopPadding / 2.f; final float contentWidth = tab.getLayoutTab().getOriginalContentWidth(); tab.setDiscardOriginY(halfCloseBtnHeight); tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth); tab.setDiscardFromClick(true); mLayout.uiRequestingCloseTab(time, tab.getId()); RecordUserAction.record("MobileStackViewCloseTab"); RecordUserAction.record("MobileTabClosed"); } else { // Let the model know that a new {@link LayoutTab} was selected. The model will // notify us if we need to do anything visual. setIndex() will possibly switch the // models and broadcast the event. mLayout.uiSelectingTab(time, mStackTabs[clicked].getId()); } } }
Example #26
Source File: Stack.java From delion with Apache License 2.0 | 4 votes |
private float getRange(float range) { return range * (mCurrentMode == Orientation.PORTRAIT ? mLayout.getWidth() : mLayout.getHeightMinusTopControls()); }
Example #27
Source File: Stack.java From delion with Apache License 2.0 | 4 votes |
private float getDefaultDiscardDirection() { return (mCurrentMode == Orientation.LANDSCAPE && LocalizationUtils.isLayoutRtl()) ? -1.0f : 1.0f; }
Example #28
Source File: Stack.java From delion with Apache License 2.0 | 4 votes |
/** * Discards and updates the position based on the input event values. * * @param x The x coordinate of the end of the drag event. * @param y The y coordinate of the end of the drag event. * @param amountX The number of pixels dragged in the x direction since the last event. * @param amountY The number of pixels dragged in the y direction since the last event. */ private void discard(float x, float y, float amountX, float amountY) { if (mStackTabs == null || (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL && mOverviewAnimationType != OverviewAnimationType.UNDISCARD)) { return; } if (mDiscardingTab == null) { if (!mInSwipe) { mDiscardingTab = getTabAtPositon(x, y); } else { if (mTabModel.index() < 0) return; mDiscardingTab = mStackTabs[mTabModel.index()]; } if (mDiscardingTab != null) { cancelDiscardScrollingAnimation(); // Make sure we are well within the tab in the discard direction. RectF target = mDiscardingTab.getLayoutTab().getClickTargetBounds(); float distanceToEdge; float edgeToEdge; if (mCurrentMode == Orientation.PORTRAIT) { mDiscardDirection = 1.0f; distanceToEdge = Math.max(target.left - x, x - target.right); edgeToEdge = target.width(); } else { mDiscardDirection = 2.0f - 4.0f * (x / mLayout.getWidth()); mDiscardDirection = MathUtils.clamp(mDiscardDirection, -1.0f, 1.0f); distanceToEdge = Math.max(target.top - y, y - target.bottom); edgeToEdge = target.height(); } float scaledDiscardX = x - mDiscardingTab.getLayoutTab().getX(); float scaledDiscardY = y - mDiscardingTab.getLayoutTab().getY(); mDiscardingTab.setDiscardOriginX(scaledDiscardX / mDiscardingTab.getScale()); mDiscardingTab.setDiscardOriginY(scaledDiscardY / mDiscardingTab.getScale()); mDiscardingTab.setDiscardFromClick(false); if (Math.abs(distanceToEdge) < DISCARD_SAFE_SELECTION_PCTG * edgeToEdge) { mDiscardingTab = null; } } } if (mDiscardingTab != null) { float deltaAmount = mCurrentMode == Orientation.PORTRAIT ? amountX : amountY; mDiscardingTab.addToDiscardAmount(deltaAmount); } }
Example #29
Source File: Stack.java From 365browser with Apache License 2.0 | 4 votes |
private float getRange(float range) { return range * (mCurrentMode == Orientation.PORTRAIT ? mLayout.getWidth() : mLayout.getHeightMinusBrowserControls()); }
Example #30
Source File: Stack.java From delion with Apache License 2.0 | 4 votes |
private float getScrollDimensionSize() { return mCurrentMode == Orientation.PORTRAIT ? mLayout.getHeightMinusTopControls() : mLayout.getWidth(); }