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; |
20 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; | 21 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; |
21 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; | 22 import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; |
22 import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; | 23 import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; |
23 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 24 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
24 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EventFilter; | 25 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
; |
25 import org.chromium.chrome.browser.compositor.layouts.eventfilter.ScrollDirectio
n; | 28 import org.chromium.chrome.browser.compositor.layouts.eventfilter.ScrollDirectio
n; |
26 import org.chromium.chrome.browser.compositor.layouts.phone.stack.Stack; | 29 import org.chromium.chrome.browser.compositor.layouts.phone.stack.Stack; |
27 import org.chromium.chrome.browser.compositor.layouts.phone.stack.StackTab; | 30 import org.chromium.chrome.browser.compositor.layouts.phone.stack.StackTab; |
28 import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer; | 31 import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer; |
29 import org.chromium.chrome.browser.compositor.scene_layer.TabListSceneLayer; | 32 import org.chromium.chrome.browser.compositor.scene_layer.TabListSceneLayer; |
30 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; | 33 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; |
31 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; | 34 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; |
32 import org.chromium.chrome.browser.tab.Tab; | 35 import org.chromium.chrome.browser.tab.Tab; |
33 import org.chromium.chrome.browser.tabmodel.TabModel; | 36 import org.chromium.chrome.browser.tabmodel.TabModel; |
34 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 37 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 private boolean mDelayedLayoutTabInitRequired; | 128 private boolean mDelayedLayoutTabInitRequired; |
126 | 129 |
127 private Boolean mTemporarySelectedStack; | 130 private Boolean mTemporarySelectedStack; |
128 | 131 |
129 // Orientation Variables | 132 // Orientation Variables |
130 private PortraitViewport mCachedPortraitViewport; | 133 private PortraitViewport mCachedPortraitViewport; |
131 private PortraitViewport mCachedLandscapeViewport; | 134 private PortraitViewport mCachedLandscapeViewport; |
132 | 135 |
133 private final ViewGroup mViewContainer; | 136 private final ViewGroup mViewContainer; |
134 | 137 |
| 138 private final GestureEventFilter mGestureEventFilter; |
135 private final TabListSceneLayer mSceneLayer; | 139 private final TabListSceneLayer mSceneLayer; |
136 | 140 |
| 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 |
137 /** | 249 /** |
138 * @param context The current Android's context. | 250 * @param context The current Android's context. |
139 * @param updateHost The {@link LayoutUpdateHost} view for this layout. | 251 * @param updateHost The {@link LayoutUpdateHost} view for this layout. |
140 * @param renderHost The {@link LayoutRenderHost} view for this layout. | 252 * @param renderHost The {@link LayoutRenderHost} view for this layout. |
141 * @param eventFilter The {@link EventFilter} that is needed for this view. | 253 * @param eventFilter The {@link EventFilter} that is needed for this view. |
142 */ | 254 */ |
143 public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRende
rHost renderHost, | 255 public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRende
rHost renderHost) { |
144 EventFilter eventFilter) { | 256 super(context, updateHost, renderHost); |
145 super(context, updateHost, renderHost, eventFilter); | |
146 | 257 |
| 258 mGestureHandler = new StackLayoutGestureHandler(); |
| 259 mGestureEventFilter = new GestureEventFilter(context, mGestureHandler); |
147 final ViewConfiguration configuration = ViewConfiguration.get(context); | 260 final ViewConfiguration configuration = ViewConfiguration.get(context); |
148 mMinDirectionThreshold = configuration.getScaledTouchSlop(); | 261 mMinDirectionThreshold = configuration.getScaledTouchSlop(); |
149 mMinShortPressThresholdSqr = | 262 mMinShortPressThresholdSqr = |
150 configuration.getScaledPagingTouchSlop() * configuration.getScal
edPagingTouchSlop(); | 263 configuration.getScaledPagingTouchSlop() * configuration.getScal
edPagingTouchSlop(); |
151 | 264 |
152 mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5); | 265 mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5); |
153 mFlingSpeed = FLING_SPEED_DP; | 266 mFlingSpeed = FLING_SPEED_DP; |
154 mStacks = new Stack[2]; | 267 mStacks = new Stack[2]; |
155 mStacks[0] = new Stack(context, this); | 268 mStacks[0] = new Stack(context, this); |
156 mStacks[1] = new Stack(context, this); | 269 mStacks[1] = new Stack(context, this); |
157 mStackRects = new RectF[2]; | 270 mStackRects = new RectF[2]; |
158 mStackRects[0] = new RectF(); | 271 mStackRects[0] = new RectF(); |
159 mStackRects[1] = new RectF(); | 272 mStackRects[1] = new RectF(); |
160 | 273 |
161 mViewContainer = new FrameLayout(getContext()); | 274 mViewContainer = new FrameLayout(getContext()); |
162 mSceneLayer = new TabListSceneLayer(); | 275 mSceneLayer = new TabListSceneLayer(); |
163 } | 276 } |
164 | 277 |
165 @Override | 278 @Override |
166 public boolean forceShowBrowserControlsAndroidView() { | 279 public boolean forceShowBrowserControlsAndroidView() { |
167 return true; | 280 return true; |
168 } | 281 } |
169 | 282 |
| 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 |
170 @Override | 309 @Override |
171 public ViewportMode getViewportMode() { | 310 public ViewportMode getViewportMode() { |
172 return ViewportMode.ALWAYS_FULLSCREEN; | 311 return ViewportMode.ALWAYS_FULLSCREEN; |
173 } | 312 } |
174 | 313 |
175 @Override | 314 @Override |
176 public void setTabModelSelector(TabModelSelector modelSelector, TabContentMa
nager manager) { | 315 public void setTabModelSelector(TabModelSelector modelSelector, TabContentMa
nager manager) { |
177 super.setTabModelSelector(modelSelector, manager); | 316 super.setTabModelSelector(modelSelector, manager); |
178 mStacks[0].setTabModel(modelSelector.getModel(false)); | 317 mStacks[0].setTabModel(modelSelector.getModel(false)); |
179 mStacks[1].setTabModel(modelSelector.getModel(true)); | 318 mStacks[1].setTabModel(modelSelector.getModel(true)); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 730 |
592 @Override | 731 @Override |
593 public void contextChanged(Context context) { | 732 public void contextChanged(Context context) { |
594 super.contextChanged(context); | 733 super.contextChanged(context); |
595 StackTab.resetDimensionConstants(context); | 734 StackTab.resetDimensionConstants(context); |
596 mStacks[0].contextChanged(context); | 735 mStacks[0].contextChanged(context); |
597 mStacks[1].contextChanged(context); | 736 mStacks[1].contextChanged(context); |
598 requestStackUpdate(); | 737 requestStackUpdate(); |
599 } | 738 } |
600 | 739 |
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 | |
620 /** | 740 /** |
621 * Computes the input mode for drag and fling based on the first event posit
ion. | 741 * Computes the input mode for drag and fling based on the first event posit
ion. |
622 * @param time The current time of the app in ms. | 742 * @param time The current time of the app in ms. |
623 * @param x The x layout position of the mouse (without the displacement)
. | 743 * @param x The x layout position of the mouse (without the displacement)
. |
624 * @param y The y layout position of the mouse (without the displacement)
. | 744 * @param y The y layout position of the mouse (without the displacement)
. |
625 * @param dx The x displacement happening this frame. | 745 * @param dx The x displacement happening this frame. |
626 * @param dy The y displacement happening this frame. | 746 * @param dy The y displacement happening this frame. |
627 * @return The input mode to select. | 747 * @return The input mode to select. |
628 */ | 748 */ |
629 private SwipeMode computeInputMode(long time, float x, float y, float dx, fl
oat dy) { | 749 private SwipeMode computeInputMode(long time, float x, float y, float dx, fl
oat dy) { |
(...skipping 29 matching lines...) Expand all Loading... |
659 if (time - mLastOnDownTimeStamp > THRESHOLD_TIME_TO_SWITCH_STACK_INPUT_M
ODE) { | 779 if (time - mLastOnDownTimeStamp > THRESHOLD_TIME_TO_SWITCH_STACK_INPUT_M
ODE) { |
660 return SwipeMode.SEND_TO_STACK; | 780 return SwipeMode.SEND_TO_STACK; |
661 } | 781 } |
662 // Dragging fast | 782 // Dragging fast |
663 if (distanceToDownSqr > mMinShortPressThresholdSqr) { | 783 if (distanceToDownSqr > mMinShortPressThresholdSqr) { |
664 return SwipeMode.SWITCH_STACK; | 784 return SwipeMode.SWITCH_STACK; |
665 } | 785 } |
666 return SwipeMode.NONE; | 786 return SwipeMode.NONE; |
667 } | 787 } |
668 | 788 |
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 | |
689 class PortraitViewport { | 789 class PortraitViewport { |
690 protected float mWidth, mHeight; | 790 protected float mWidth, mHeight; |
691 PortraitViewport() { | 791 PortraitViewport() { |
692 mWidth = StackLayout.this.getWidth(); | 792 mWidth = StackLayout.this.getWidth(); |
693 mHeight = StackLayout.this.getHeightMinusBrowserControls(); | 793 mHeight = StackLayout.this.getHeightMinusBrowserControls(); |
694 } | 794 } |
695 | 795 |
696 float getClampedRenderedScrollOffset() { | 796 float getClampedRenderedScrollOffset() { |
697 if (mStacks[1].isDisplayable() || mFlingFromModelChange) { | 797 if (mStacks[1].isDisplayable() || mFlingFromModelChange) { |
698 return MathUtils.clamp(mRenderedScrollOffset, 0, -1); | 798 return MathUtils.clamp(mRenderedScrollOffset, 0, -1); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 911 } |
812 return mCachedPortraitViewport; | 912 return mCachedPortraitViewport; |
813 } else { | 913 } else { |
814 if (mCachedLandscapeViewport == null) { | 914 if (mCachedLandscapeViewport == null) { |
815 mCachedLandscapeViewport = new LandscapeViewport(); | 915 mCachedLandscapeViewport = new LandscapeViewport(); |
816 } | 916 } |
817 return mCachedLandscapeViewport; | 917 return mCachedLandscapeViewport; |
818 } | 918 } |
819 } | 919 } |
820 | 920 |
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 | |
835 /** | 921 /** |
836 * Check if we are dragging stack in a wrong direction. | 922 * Check if we are dragging stack in a wrong direction. |
837 * | 923 * |
838 * @param downX The X coordinate on the last down event. | 924 * @param downX The X coordinate on the last down event. |
839 * @param downY The Y coordinate on the last down event. | 925 * @param downY The Y coordinate on the last down event. |
840 * @param x The current X coordinate. | 926 * @param x The current X coordinate. |
841 * @param y The current Y coordinate. | 927 * @param y The current Y coordinate. |
842 * @param dx The amount of change in X coordinate. | 928 * @param dx The amount of change in X coordinate. |
843 * @param dy The amount of change in Y coordinate. | 929 * @param dy The amount of change in Y coordinate. |
844 * @param orientation The device orientation (portrait / landscape). | 930 * @param orientation The device orientation (portrait / landscape). |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 addToAnimation(this, Property.STACK_SNAP, mRenderedScrollOffset, tar
get, duration, 0); | 983 addToAnimation(this, Property.STACK_SNAP, mRenderedScrollOffset, tar
get, duration, 0); |
898 } else { | 984 } else { |
899 setProperty(Property.STACK_SNAP, target); | 985 setProperty(Property.STACK_SNAP, target); |
900 if (mTemporarySelectedStack != null) { | 986 if (mTemporarySelectedStack != null) { |
901 mTabModelSelector.selectModel(mTemporarySelectedStack); | 987 mTabModelSelector.selectModel(mTemporarySelectedStack); |
902 mTemporarySelectedStack = null; | 988 mTemporarySelectedStack = null; |
903 } | 989 } |
904 } | 990 } |
905 } | 991 } |
906 | 992 |
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 | |
935 /** | 993 /** |
936 * Pushes a rectangle to be drawn on the screen on top of everything. | 994 * Pushes a rectangle to be drawn on the screen on top of everything. |
937 * | 995 * |
938 * @param rect The rectangle to be drawn on screen | 996 * @param rect The rectangle to be drawn on screen |
939 * @param color The color of the rectangle | 997 * @param color The color of the rectangle |
940 */ | 998 */ |
941 public void pushDebugRect(Rect rect, int color) { | 999 public void pushDebugRect(Rect rect, int color) { |
942 if (rect.left > rect.right) { | 1000 if (rect.left > rect.right) { |
943 int tmp = rect.right; | 1001 int tmp = rect.right; |
944 rect.right = rect.left; | 1002 rect.right = rect.left; |
945 rect.left = tmp; | 1003 rect.left = tmp; |
946 } | 1004 } |
947 if (rect.top > rect.bottom) { | 1005 if (rect.top > rect.bottom) { |
948 int tmp = rect.bottom; | 1006 int tmp = rect.bottom; |
949 rect.bottom = rect.top; | 1007 rect.bottom = rect.top; |
950 rect.top = tmp; | 1008 rect.top = tmp; |
951 } | 1009 } |
952 mRenderHost.pushDebugRect(rect, color); | 1010 mRenderHost.pushDebugRect(rect, color); |
953 } | 1011 } |
954 | 1012 |
955 @Override | 1013 @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 | |
961 protected void updateLayout(long time, long dt) { | 1014 protected void updateLayout(long time, long dt) { |
962 super.updateLayout(time, dt); | 1015 super.updateLayout(time, dt); |
963 boolean needUpdate = false; | 1016 boolean needUpdate = false; |
964 | 1017 |
965 final PortraitViewport viewport = getViewportParameters(); | 1018 final PortraitViewport viewport = getViewportParameters(); |
966 mStackRects[0].left = viewport.getStack0Left(); | 1019 mStackRects[0].left = viewport.getStack0Left(); |
967 mStackRects[0].right = mStackRects[0].left + viewport.getWidth(); | 1020 mStackRects[0].right = mStackRects[0].left + viewport.getWidth(); |
968 mStackRects[0].top = viewport.getStack0Top(); | 1021 mStackRects[0].top = viewport.getStack0Top(); |
969 mStackRects[0].bottom = mStackRects[0].top + viewport.getHeight(); | 1022 mStackRects[0].bottom = mStackRects[0].top + viewport.getHeight(); |
970 mStackRects[1].left = mStackRects[0].left + viewport.getStack0ToStack1Tr
anslationX(); | 1023 mStackRects[1].left = mStackRects[0].left + viewport.getStack0ToStack1Tr
anslationX(); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 | 1273 |
1221 /** | 1274 /** |
1222 * Called by the stacks whenever they finish their animations. | 1275 * Called by the stacks whenever they finish their animations. |
1223 */ | 1276 */ |
1224 public void onStackAnimationFinished() { | 1277 public void onStackAnimationFinished() { |
1225 mStackAnimationCount--; | 1278 mStackAnimationCount--; |
1226 if (mStackAnimationCount == 0) super.onAnimationFinished(); | 1279 if (mStackAnimationCount == 0) super.onAnimationFinished(); |
1227 } | 1280 } |
1228 | 1281 |
1229 @Override | 1282 @Override |
| 1283 protected EventFilter getEventFilter() { |
| 1284 return mGestureEventFilter; |
| 1285 } |
| 1286 |
| 1287 @Override |
1230 protected SceneLayer getSceneLayer() { | 1288 protected SceneLayer getSceneLayer() { |
1231 return mSceneLayer; | 1289 return mSceneLayer; |
1232 } | 1290 } |
1233 | 1291 |
1234 @Override | 1292 @Override |
1235 protected void updateSceneLayer(RectF viewport, RectF contentViewport, | 1293 protected void updateSceneLayer(RectF viewport, RectF contentViewport, |
1236 LayerTitleCache layerTitleCache, TabContentManager tabContentManager
, | 1294 LayerTitleCache layerTitleCache, TabContentManager tabContentManager
, |
1237 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM
anager) { | 1295 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM
anager) { |
1238 super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabCo
ntentManager, | 1296 super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabCo
ntentManager, |
1239 resourceManager, fullscreenManager); | 1297 resourceManager, fullscreenManager); |
1240 assert mSceneLayer != null; | 1298 assert mSceneLayer != null; |
1241 mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, la
yerTitleCache, | 1299 mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, la
yerTitleCache, |
1242 tabContentManager, resourceManager, fullscreenManager); | 1300 tabContentManager, resourceManager, fullscreenManager); |
1243 } | 1301 } |
1244 } | 1302 } |
OLD | NEW |