| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.compositor.layouts.phone; | 5 package org.chromium.chrome.browser.compositor.layouts.phone; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Rect; | 8 import android.graphics.Rect; |
| 9 import android.graphics.RectF; | 9 import android.graphics.RectF; |
| 10 import android.os.SystemClock; | 10 import android.os.SystemClock; |
| 11 import android.view.ViewConfiguration; | 11 import android.view.ViewConfiguration; |
| 12 import android.view.ViewGroup; | 12 import android.view.ViewGroup; |
| 13 import android.view.ViewGroup.LayoutParams; | 13 import android.view.ViewGroup.LayoutParams; |
| 14 import android.widget.FrameLayout; | 14 import android.widget.FrameLayout; |
| 15 | 15 |
| 16 import org.chromium.base.VisibleForTesting; | 16 import org.chromium.base.VisibleForTesting; |
| 17 import org.chromium.chrome.browser.compositor.LayerTitleCache; | 17 import org.chromium.chrome.browser.compositor.LayerTitleCache; |
| 18 import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable
; | 18 import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Animatable
; |
| 19 import org.chromium.chrome.browser.compositor.layouts.Layout; | 19 import org.chromium.chrome.browser.compositor.layouts.Layout; |
| 20 import org.chromium.chrome.browser.compositor.layouts.LayoutManager; | |
| 21 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; | 20 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; |
| 22 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; | 21 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; |
| 23 import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; | 22 import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; |
| 24 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 23 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
| 25 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EventFilter; | 24 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EventFilter; |
| 26 import org.chromium.chrome.browser.compositor.layouts.eventfilter.GestureEventFi
lter; | |
| 27 import org.chromium.chrome.browser.compositor.layouts.eventfilter.GestureHandler
; | |
| 28 import org.chromium.chrome.browser.compositor.layouts.eventfilter.ScrollDirectio
n; | 25 import org.chromium.chrome.browser.compositor.layouts.eventfilter.ScrollDirectio
n; |
| 29 import org.chromium.chrome.browser.compositor.layouts.phone.stack.Stack; | 26 import org.chromium.chrome.browser.compositor.layouts.phone.stack.Stack; |
| 30 import org.chromium.chrome.browser.compositor.layouts.phone.stack.StackTab; | 27 import org.chromium.chrome.browser.compositor.layouts.phone.stack.StackTab; |
| 31 import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer; | 28 import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer; |
| 32 import org.chromium.chrome.browser.compositor.scene_layer.TabListSceneLayer; | 29 import org.chromium.chrome.browser.compositor.scene_layer.TabListSceneLayer; |
| 33 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; | 30 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; |
| 34 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; | 31 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; |
| 35 import org.chromium.chrome.browser.tab.Tab; | 32 import org.chromium.chrome.browser.tab.Tab; |
| 36 import org.chromium.chrome.browser.tabmodel.TabModel; | 33 import org.chromium.chrome.browser.tabmodel.TabModel; |
| 37 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 34 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 private boolean mDelayedLayoutTabInitRequired; | 125 private boolean mDelayedLayoutTabInitRequired; |
| 129 | 126 |
| 130 private Boolean mTemporarySelectedStack; | 127 private Boolean mTemporarySelectedStack; |
| 131 | 128 |
| 132 // Orientation Variables | 129 // Orientation Variables |
| 133 private PortraitViewport mCachedPortraitViewport; | 130 private PortraitViewport mCachedPortraitViewport; |
| 134 private PortraitViewport mCachedLandscapeViewport; | 131 private PortraitViewport mCachedLandscapeViewport; |
| 135 | 132 |
| 136 private final ViewGroup mViewContainer; | 133 private final ViewGroup mViewContainer; |
| 137 | 134 |
| 138 private final GestureEventFilter mGestureEventFilter; | |
| 139 private final TabListSceneLayer mSceneLayer; | 135 private final TabListSceneLayer mSceneLayer; |
| 140 | 136 |
| 141 private StackLayoutGestureHandler mGestureHandler; | |
| 142 | |
| 143 private class StackLayoutGestureHandler implements GestureHandler { | |
| 144 @Override | |
| 145 public void onDown(float x, float y, boolean fromMouse, int buttons) { | |
| 146 long time = time(); | |
| 147 mLastOnDownX = x; | |
| 148 mLastOnDownY = y; | |
| 149 mLastOnDownTimeStamp = time; | |
| 150 mInputMode = computeInputMode(time, x, y, 0, 0); | |
| 151 mStacks[getTabStackIndex()].onDown(time); | |
| 152 } | |
| 153 | |
| 154 @Override | |
| 155 public void onUpOrCancel() { | |
| 156 onUpOrCancel(time()); | |
| 157 } | |
| 158 | |
| 159 @Override | |
| 160 public void drag(float x, float y, float dx, float dy, float tx, float t
y) { | |
| 161 SwipeMode oldInputMode = mInputMode; | |
| 162 long time = time(); | |
| 163 float amountX = dx; | |
| 164 float amountY = dy; | |
| 165 mInputMode = computeInputMode(time, x, y, amountX, amountY); | |
| 166 | |
| 167 if (oldInputMode == SwipeMode.SEND_TO_STACK && mInputMode == SwipeMo
de.SWITCH_STACK) { | |
| 168 mStacks[getTabStackIndex()].onUpOrCancel(time); | |
| 169 } else if (oldInputMode == SwipeMode.SWITCH_STACK | |
| 170 && mInputMode == SwipeMode.SEND_TO_STACK) { | |
| 171 onUpOrCancel(time); | |
| 172 } | |
| 173 | |
| 174 if (mInputMode == SwipeMode.SEND_TO_STACK) { | |
| 175 mStacks[getTabStackIndex()].drag(time, x, y, amountX, amountY); | |
| 176 } else if (mInputMode == SwipeMode.SWITCH_STACK) { | |
| 177 scrollStacks(getOrientation() == Orientation.PORTRAIT ? amountX
: amountY); | |
| 178 } | |
| 179 } | |
| 180 | |
| 181 @Override | |
| 182 public void click(float x, float y, boolean fromMouse, int buttons) { | |
| 183 // Click event happens before the up event. mClicked is set to mute
the up event. | |
| 184 mClicked = true; | |
| 185 PortraitViewport viewportParams = getViewportParameters(); | |
| 186 int stackIndexAt = viewportParams.getStackIndexAt(x, y); | |
| 187 if (stackIndexAt == getTabStackIndex()) { | |
| 188 mStacks[getTabStackIndex()].click(time(), x, y); | |
| 189 } else { | |
| 190 flingStacks(getTabStackIndex() == 0); | |
| 191 } | |
| 192 requestStackUpdate(); | |
| 193 } | |
| 194 | |
| 195 @Override | |
| 196 public void fling(float x, float y, float velocityX, float velocityY) { | |
| 197 long time = time(); | |
| 198 float vx = velocityX; | |
| 199 float vy = velocityY; | |
| 200 | |
| 201 if (mInputMode == SwipeMode.NONE) { | |
| 202 mInputMode = computeInputMode( | |
| 203 time, x, y, vx * SWITCH_STACK_FLING_DT, vy * SWITCH_STAC
K_FLING_DT); | |
| 204 } | |
| 205 | |
| 206 if (mInputMode == SwipeMode.SEND_TO_STACK) { | |
| 207 mStacks[getTabStackIndex()].fling(time, x, y, vx, vy); | |
| 208 } else if (mInputMode == SwipeMode.SWITCH_STACK) { | |
| 209 final float velocity = getOrientation() == Orientation.PORTRAIT
? vx : vy; | |
| 210 final float origin = getOrientation() == Orientation.PORTRAIT ?
x : y; | |
| 211 final float max = | |
| 212 getOrientation() == Orientation.PORTRAIT ? getWidth() :
getHeight(); | |
| 213 final float predicted = origin + velocity * SWITCH_STACK_FLING_D
T; | |
| 214 final float delta = MathUtils.clamp(predicted, 0, max) - origin; | |
| 215 scrollStacks(delta); | |
| 216 } | |
| 217 requestStackUpdate(); | |
| 218 } | |
| 219 | |
| 220 @Override | |
| 221 public void onLongPress(float x, float y) { | |
| 222 mStacks[getTabStackIndex()].onLongPress(time(), x, y); | |
| 223 } | |
| 224 | |
| 225 @Override | |
| 226 public void onPinch(float x0, float y0, float x1, float y1, boolean firs
tEvent) { | |
| 227 mStacks[getTabStackIndex()].onPinch(time(), x0, y0, x1, y1, firstEve
nt); | |
| 228 } | |
| 229 | |
| 230 private void onUpOrCancel(long time) { | |
| 231 int currentIndex = getTabStackIndex(); | |
| 232 int nextIndex = 1 - currentIndex; | |
| 233 if (!mClicked | |
| 234 && Math.abs(currentIndex + mRenderedScrollOffset) > THRESHOL
D_TO_SWITCH_STACK | |
| 235 && mStacks[nextIndex].isDisplayable()) { | |
| 236 setActiveStackState(nextIndex == 1); | |
| 237 } | |
| 238 mClicked = false; | |
| 239 finishScrollStacks(); | |
| 240 mStacks[getTabStackIndex()].onUpOrCancel(time); | |
| 241 mInputMode = SwipeMode.NONE; | |
| 242 } | |
| 243 | |
| 244 private long time() { | |
| 245 return LayoutManager.time(); | |
| 246 } | |
| 247 } | |
| 248 | |
| 249 /** | 137 /** |
| 250 * @param context The current Android's context. | 138 * @param context The current Android's context. |
| 251 * @param updateHost The {@link LayoutUpdateHost} view for this layout. | 139 * @param updateHost The {@link LayoutUpdateHost} view for this layout. |
| 252 * @param renderHost The {@link LayoutRenderHost} view for this layout. | 140 * @param renderHost The {@link LayoutRenderHost} view for this layout. |
| 253 * @param eventFilter The {@link EventFilter} that is needed for this view. | 141 * @param eventFilter The {@link EventFilter} that is needed for this view. |
| 254 */ | 142 */ |
| 255 public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRende
rHost renderHost) { | 143 public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRende
rHost renderHost, |
| 256 super(context, updateHost, renderHost); | 144 EventFilter eventFilter) { |
| 145 super(context, updateHost, renderHost, eventFilter); |
| 257 | 146 |
| 258 mGestureHandler = new StackLayoutGestureHandler(); | |
| 259 mGestureEventFilter = new GestureEventFilter(context, mGestureHandler); | |
| 260 final ViewConfiguration configuration = ViewConfiguration.get(context); | 147 final ViewConfiguration configuration = ViewConfiguration.get(context); |
| 261 mMinDirectionThreshold = configuration.getScaledTouchSlop(); | 148 mMinDirectionThreshold = configuration.getScaledTouchSlop(); |
| 262 mMinShortPressThresholdSqr = | 149 mMinShortPressThresholdSqr = |
| 263 configuration.getScaledPagingTouchSlop() * configuration.getScal
edPagingTouchSlop(); | 150 configuration.getScaledPagingTouchSlop() * configuration.getScal
edPagingTouchSlop(); |
| 264 | 151 |
| 265 mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5); | 152 mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5); |
| 266 mFlingSpeed = FLING_SPEED_DP; | 153 mFlingSpeed = FLING_SPEED_DP; |
| 267 mStacks = new Stack[2]; | 154 mStacks = new Stack[2]; |
| 268 mStacks[0] = new Stack(context, this); | 155 mStacks[0] = new Stack(context, this); |
| 269 mStacks[1] = new Stack(context, this); | 156 mStacks[1] = new Stack(context, this); |
| 270 mStackRects = new RectF[2]; | 157 mStackRects = new RectF[2]; |
| 271 mStackRects[0] = new RectF(); | 158 mStackRects[0] = new RectF(); |
| 272 mStackRects[1] = new RectF(); | 159 mStackRects[1] = new RectF(); |
| 273 | 160 |
| 274 mViewContainer = new FrameLayout(getContext()); | 161 mViewContainer = new FrameLayout(getContext()); |
| 275 mSceneLayer = new TabListSceneLayer(); | 162 mSceneLayer = new TabListSceneLayer(); |
| 276 } | 163 } |
| 277 | 164 |
| 278 @Override | 165 @Override |
| 279 public boolean forceShowBrowserControlsAndroidView() { | 166 public boolean forceShowBrowserControlsAndroidView() { |
| 280 return true; | 167 return true; |
| 281 } | 168 } |
| 282 | 169 |
| 283 /** | |
| 284 * Simulates a click on the view at the specified pixel offset | |
| 285 * from the top left of the view. | |
| 286 * This is used by UI tests. | |
| 287 * @param x Coordinate of the click in dp. | |
| 288 * @param y Coordinate of the click in dp. | |
| 289 */ | |
| 290 @VisibleForTesting | |
| 291 public void simulateClick(float x, float y) { | |
| 292 mGestureHandler.click(x, y, false, -1); | |
| 293 } | |
| 294 | |
| 295 /** | |
| 296 * Simulates a drag and issues Up-event to commit the drag. | |
| 297 * @param x Coordinate to start the Drag from in dp. | |
| 298 * @param y Coordinate to start the Drag from in dp. | |
| 299 * @param dX Amount of drag in X direction in dp. | |
| 300 * @param dY Amount of drag in Y direction in dp. | |
| 301 */ | |
| 302 @VisibleForTesting | |
| 303 public void simulateDrag(float x, float y, float dX, float dY) { | |
| 304 mGestureHandler.onDown(x, y, false, -1); | |
| 305 mGestureHandler.drag(x, y, dX, dY, -1, -1); | |
| 306 mGestureHandler.onUpOrCancel(); | |
| 307 } | |
| 308 | |
| 309 @Override | 170 @Override |
| 310 public ViewportMode getViewportMode() { | 171 public ViewportMode getViewportMode() { |
| 311 return ViewportMode.ALWAYS_FULLSCREEN; | 172 return ViewportMode.ALWAYS_FULLSCREEN; |
| 312 } | 173 } |
| 313 | 174 |
| 314 @Override | 175 @Override |
| 315 public void setTabModelSelector(TabModelSelector modelSelector, TabContentMa
nager manager) { | 176 public void setTabModelSelector(TabModelSelector modelSelector, TabContentMa
nager manager) { |
| 316 super.setTabModelSelector(modelSelector, manager); | 177 super.setTabModelSelector(modelSelector, manager); |
| 317 mStacks[0].setTabModel(modelSelector.getModel(false)); | 178 mStacks[0].setTabModel(modelSelector.getModel(false)); |
| 318 mStacks[1].setTabModel(modelSelector.getModel(true)); | 179 mStacks[1].setTabModel(modelSelector.getModel(true)); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 591 |
| 731 @Override | 592 @Override |
| 732 public void contextChanged(Context context) { | 593 public void contextChanged(Context context) { |
| 733 super.contextChanged(context); | 594 super.contextChanged(context); |
| 734 StackTab.resetDimensionConstants(context); | 595 StackTab.resetDimensionConstants(context); |
| 735 mStacks[0].contextChanged(context); | 596 mStacks[0].contextChanged(context); |
| 736 mStacks[1].contextChanged(context); | 597 mStacks[1].contextChanged(context); |
| 737 requestStackUpdate(); | 598 requestStackUpdate(); |
| 738 } | 599 } |
| 739 | 600 |
| 601 @Override |
| 602 public void drag(long time, float x, float y, float amountX, float amountY)
{ |
| 603 SwipeMode oldInputMode = mInputMode; |
| 604 mInputMode = computeInputMode(time, x, y, amountX, amountY); |
| 605 |
| 606 if (oldInputMode == SwipeMode.SEND_TO_STACK && mInputMode == SwipeMode.S
WITCH_STACK) { |
| 607 mStacks[getTabStackIndex()].onUpOrCancel(time); |
| 608 } else if (oldInputMode == SwipeMode.SWITCH_STACK |
| 609 && mInputMode == SwipeMode.SEND_TO_STACK) { |
| 610 onUpOrCancel(time); |
| 611 } |
| 612 |
| 613 if (mInputMode == SwipeMode.SEND_TO_STACK) { |
| 614 mStacks[getTabStackIndex()].drag(time, x, y, amountX, amountY); |
| 615 } else if (mInputMode == SwipeMode.SWITCH_STACK) { |
| 616 scrollStacks(getOrientation() == Orientation.PORTRAIT ? amountX : am
ountY); |
| 617 } |
| 618 } |
| 619 |
| 740 /** | 620 /** |
| 741 * Computes the input mode for drag and fling based on the first event posit
ion. | 621 * Computes the input mode for drag and fling based on the first event posit
ion. |
| 742 * @param time The current time of the app in ms. | 622 * @param time The current time of the app in ms. |
| 743 * @param x The x layout position of the mouse (without the displacement)
. | 623 * @param x The x layout position of the mouse (without the displacement)
. |
| 744 * @param y The y layout position of the mouse (without the displacement)
. | 624 * @param y The y layout position of the mouse (without the displacement)
. |
| 745 * @param dx The x displacement happening this frame. | 625 * @param dx The x displacement happening this frame. |
| 746 * @param dy The y displacement happening this frame. | 626 * @param dy The y displacement happening this frame. |
| 747 * @return The input mode to select. | 627 * @return The input mode to select. |
| 748 */ | 628 */ |
| 749 private SwipeMode computeInputMode(long time, float x, float y, float dx, fl
oat dy) { | 629 private SwipeMode computeInputMode(long time, float x, float y, float dx, fl
oat dy) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 779 if (time - mLastOnDownTimeStamp > THRESHOLD_TIME_TO_SWITCH_STACK_INPUT_M
ODE) { | 659 if (time - mLastOnDownTimeStamp > THRESHOLD_TIME_TO_SWITCH_STACK_INPUT_M
ODE) { |
| 780 return SwipeMode.SEND_TO_STACK; | 660 return SwipeMode.SEND_TO_STACK; |
| 781 } | 661 } |
| 782 // Dragging fast | 662 // Dragging fast |
| 783 if (distanceToDownSqr > mMinShortPressThresholdSqr) { | 663 if (distanceToDownSqr > mMinShortPressThresholdSqr) { |
| 784 return SwipeMode.SWITCH_STACK; | 664 return SwipeMode.SWITCH_STACK; |
| 785 } | 665 } |
| 786 return SwipeMode.NONE; | 666 return SwipeMode.NONE; |
| 787 } | 667 } |
| 788 | 668 |
| 669 @Override |
| 670 public void fling(long time, float x, float y, float vx, float vy) { |
| 671 if (mInputMode == SwipeMode.NONE) { |
| 672 mInputMode = computeInputMode( |
| 673 time, x, y, vx * SWITCH_STACK_FLING_DT, vy * SWITCH_STACK_FL
ING_DT); |
| 674 } |
| 675 |
| 676 if (mInputMode == SwipeMode.SEND_TO_STACK) { |
| 677 mStacks[getTabStackIndex()].fling(time, x, y, vx, vy); |
| 678 } else if (mInputMode == SwipeMode.SWITCH_STACK) { |
| 679 final float velocity = getOrientation() == Orientation.PORTRAIT ? vx
: vy; |
| 680 final float origin = getOrientation() == Orientation.PORTRAIT ? x :
y; |
| 681 final float max = getOrientation() == Orientation.PORTRAIT ? getWidt
h() : getHeight(); |
| 682 final float predicted = origin + velocity * SWITCH_STACK_FLING_DT; |
| 683 final float delta = MathUtils.clamp(predicted, 0, max) - origin; |
| 684 scrollStacks(delta); |
| 685 } |
| 686 requestStackUpdate(); |
| 687 } |
| 688 |
| 789 class PortraitViewport { | 689 class PortraitViewport { |
| 790 protected float mWidth, mHeight; | 690 protected float mWidth, mHeight; |
| 791 PortraitViewport() { | 691 PortraitViewport() { |
| 792 mWidth = StackLayout.this.getWidth(); | 692 mWidth = StackLayout.this.getWidth(); |
| 793 mHeight = StackLayout.this.getHeightMinusBrowserControls(); | 693 mHeight = StackLayout.this.getHeightMinusBrowserControls(); |
| 794 } | 694 } |
| 795 | 695 |
| 796 float getClampedRenderedScrollOffset() { | 696 float getClampedRenderedScrollOffset() { |
| 797 if (mStacks[1].isDisplayable() || mFlingFromModelChange) { | 697 if (mStacks[1].isDisplayable() || mFlingFromModelChange) { |
| 798 return MathUtils.clamp(mRenderedScrollOffset, 0, -1); | 698 return MathUtils.clamp(mRenderedScrollOffset, 0, -1); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 } | 811 } |
| 912 return mCachedPortraitViewport; | 812 return mCachedPortraitViewport; |
| 913 } else { | 813 } else { |
| 914 if (mCachedLandscapeViewport == null) { | 814 if (mCachedLandscapeViewport == null) { |
| 915 mCachedLandscapeViewport = new LandscapeViewport(); | 815 mCachedLandscapeViewport = new LandscapeViewport(); |
| 916 } | 816 } |
| 917 return mCachedLandscapeViewport; | 817 return mCachedLandscapeViewport; |
| 918 } | 818 } |
| 919 } | 819 } |
| 920 | 820 |
| 821 @Override |
| 822 public void click(long time, float x, float y) { |
| 823 // Click event happens before the up event. mClicked is set to mute the
up event. |
| 824 mClicked = true; |
| 825 PortraitViewport viewportParams = getViewportParameters(); |
| 826 int stackIndexAt = viewportParams.getStackIndexAt(x, y); |
| 827 if (stackIndexAt == getTabStackIndex()) { |
| 828 mStacks[getTabStackIndex()].click(time, x, y); |
| 829 } else { |
| 830 flingStacks(getTabStackIndex() == 0); |
| 831 } |
| 832 requestStackUpdate(); |
| 833 } |
| 834 |
| 921 /** | 835 /** |
| 922 * Check if we are dragging stack in a wrong direction. | 836 * Check if we are dragging stack in a wrong direction. |
| 923 * | 837 * |
| 924 * @param downX The X coordinate on the last down event. | 838 * @param downX The X coordinate on the last down event. |
| 925 * @param downY The Y coordinate on the last down event. | 839 * @param downY The Y coordinate on the last down event. |
| 926 * @param x The current X coordinate. | 840 * @param x The current X coordinate. |
| 927 * @param y The current Y coordinate. | 841 * @param y The current Y coordinate. |
| 928 * @param dx The amount of change in X coordinate. | 842 * @param dx The amount of change in X coordinate. |
| 929 * @param dy The amount of change in Y coordinate. | 843 * @param dy The amount of change in Y coordinate. |
| 930 * @param orientation The device orientation (portrait / landscape). | 844 * @param orientation The device orientation (portrait / landscape). |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 addToAnimation(this, Property.STACK_SNAP, mRenderedScrollOffset, tar
get, duration, 0); | 897 addToAnimation(this, Property.STACK_SNAP, mRenderedScrollOffset, tar
get, duration, 0); |
| 984 } else { | 898 } else { |
| 985 setProperty(Property.STACK_SNAP, target); | 899 setProperty(Property.STACK_SNAP, target); |
| 986 if (mTemporarySelectedStack != null) { | 900 if (mTemporarySelectedStack != null) { |
| 987 mTabModelSelector.selectModel(mTemporarySelectedStack); | 901 mTabModelSelector.selectModel(mTemporarySelectedStack); |
| 988 mTemporarySelectedStack = null; | 902 mTemporarySelectedStack = null; |
| 989 } | 903 } |
| 990 } | 904 } |
| 991 } | 905 } |
| 992 | 906 |
| 907 @Override |
| 908 public void onDown(long time, float x, float y) { |
| 909 mLastOnDownX = x; |
| 910 mLastOnDownY = y; |
| 911 mLastOnDownTimeStamp = time; |
| 912 mInputMode = computeInputMode(time, x, y, 0, 0); |
| 913 mStacks[getTabStackIndex()].onDown(time); |
| 914 } |
| 915 |
| 916 @Override |
| 917 public void onLongPress(long time, float x, float y) { |
| 918 mStacks[getTabStackIndex()].onLongPress(time, x, y); |
| 919 } |
| 920 |
| 921 @Override |
| 922 public void onUpOrCancel(long time) { |
| 923 int currentIndex = getTabStackIndex(); |
| 924 int nextIndex = 1 - currentIndex; |
| 925 if (!mClicked && Math.abs(currentIndex + mRenderedScrollOffset) > THRESH
OLD_TO_SWITCH_STACK |
| 926 && mStacks[nextIndex].isDisplayable()) { |
| 927 setActiveStackState(nextIndex == 1); |
| 928 } |
| 929 mClicked = false; |
| 930 finishScrollStacks(); |
| 931 mStacks[getTabStackIndex()].onUpOrCancel(time); |
| 932 mInputMode = SwipeMode.NONE; |
| 933 } |
| 934 |
| 993 /** | 935 /** |
| 994 * Pushes a rectangle to be drawn on the screen on top of everything. | 936 * Pushes a rectangle to be drawn on the screen on top of everything. |
| 995 * | 937 * |
| 996 * @param rect The rectangle to be drawn on screen | 938 * @param rect The rectangle to be drawn on screen |
| 997 * @param color The color of the rectangle | 939 * @param color The color of the rectangle |
| 998 */ | 940 */ |
| 999 public void pushDebugRect(Rect rect, int color) { | 941 public void pushDebugRect(Rect rect, int color) { |
| 1000 if (rect.left > rect.right) { | 942 if (rect.left > rect.right) { |
| 1001 int tmp = rect.right; | 943 int tmp = rect.right; |
| 1002 rect.right = rect.left; | 944 rect.right = rect.left; |
| 1003 rect.left = tmp; | 945 rect.left = tmp; |
| 1004 } | 946 } |
| 1005 if (rect.top > rect.bottom) { | 947 if (rect.top > rect.bottom) { |
| 1006 int tmp = rect.bottom; | 948 int tmp = rect.bottom; |
| 1007 rect.bottom = rect.top; | 949 rect.bottom = rect.top; |
| 1008 rect.top = tmp; | 950 rect.top = tmp; |
| 1009 } | 951 } |
| 1010 mRenderHost.pushDebugRect(rect, color); | 952 mRenderHost.pushDebugRect(rect, color); |
| 1011 } | 953 } |
| 1012 | 954 |
| 1013 @Override | 955 @Override |
| 956 public void onPinch(long time, float x0, float y0, float x1, float y1, boole
an firstEvent) { |
| 957 mStacks[getTabStackIndex()].onPinch(time, x0, y0, x1, y1, firstEvent); |
| 958 } |
| 959 |
| 960 @Override |
| 1014 protected void updateLayout(long time, long dt) { | 961 protected void updateLayout(long time, long dt) { |
| 1015 super.updateLayout(time, dt); | 962 super.updateLayout(time, dt); |
| 1016 boolean needUpdate = false; | 963 boolean needUpdate = false; |
| 1017 | 964 |
| 1018 final PortraitViewport viewport = getViewportParameters(); | 965 final PortraitViewport viewport = getViewportParameters(); |
| 1019 mStackRects[0].left = viewport.getStack0Left(); | 966 mStackRects[0].left = viewport.getStack0Left(); |
| 1020 mStackRects[0].right = mStackRects[0].left + viewport.getWidth(); | 967 mStackRects[0].right = mStackRects[0].left + viewport.getWidth(); |
| 1021 mStackRects[0].top = viewport.getStack0Top(); | 968 mStackRects[0].top = viewport.getStack0Top(); |
| 1022 mStackRects[0].bottom = mStackRects[0].top + viewport.getHeight(); | 969 mStackRects[0].bottom = mStackRects[0].top + viewport.getHeight(); |
| 1023 mStackRects[1].left = mStackRects[0].left + viewport.getStack0ToStack1Tr
anslationX(); | 970 mStackRects[1].left = mStackRects[0].left + viewport.getStack0ToStack1Tr
anslationX(); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 | 1220 |
| 1274 /** | 1221 /** |
| 1275 * Called by the stacks whenever they finish their animations. | 1222 * Called by the stacks whenever they finish their animations. |
| 1276 */ | 1223 */ |
| 1277 public void onStackAnimationFinished() { | 1224 public void onStackAnimationFinished() { |
| 1278 mStackAnimationCount--; | 1225 mStackAnimationCount--; |
| 1279 if (mStackAnimationCount == 0) super.onAnimationFinished(); | 1226 if (mStackAnimationCount == 0) super.onAnimationFinished(); |
| 1280 } | 1227 } |
| 1281 | 1228 |
| 1282 @Override | 1229 @Override |
| 1283 protected EventFilter getEventFilter() { | |
| 1284 return mGestureEventFilter; | |
| 1285 } | |
| 1286 | |
| 1287 @Override | |
| 1288 protected SceneLayer getSceneLayer() { | 1230 protected SceneLayer getSceneLayer() { |
| 1289 return mSceneLayer; | 1231 return mSceneLayer; |
| 1290 } | 1232 } |
| 1291 | 1233 |
| 1292 @Override | 1234 @Override |
| 1293 protected void updateSceneLayer(RectF viewport, RectF contentViewport, | 1235 protected void updateSceneLayer(RectF viewport, RectF contentViewport, |
| 1294 LayerTitleCache layerTitleCache, TabContentManager tabContentManager
, | 1236 LayerTitleCache layerTitleCache, TabContentManager tabContentManager
, |
| 1295 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM
anager) { | 1237 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM
anager) { |
| 1296 super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabCo
ntentManager, | 1238 super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabCo
ntentManager, |
| 1297 resourceManager, fullscreenManager); | 1239 resourceManager, fullscreenManager); |
| 1298 assert mSceneLayer != null; | 1240 assert mSceneLayer != null; |
| 1299 mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, la
yerTitleCache, | 1241 mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, la
yerTitleCache, |
| 1300 tabContentManager, resourceManager, fullscreenManager); | 1242 tabContentManager, resourceManager, fullscreenManager); |
| 1301 } | 1243 } |
| 1302 } | 1244 } |
| OLD | NEW |