OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.compositor.layouts; |
| 6 |
| 7 import org.chromium.chrome.browser.compositor.layouts.eventfilter.GestureHandler
; |
| 8 |
| 9 /** |
| 10 * A {@link GestureHandler} that takes a {@link LayoutProvider} and delegates al
l gesture events |
| 11 * to {@link LayoutProvider#getActiveLayout()}. |
| 12 */ |
| 13 class GestureHandlerLayoutDelegate implements GestureHandler { |
| 14 private final LayoutProvider mLayoutProvider; |
| 15 |
| 16 /** |
| 17 * Creates an instance of the {@link GestureHandlerLayoutDelegate}. |
| 18 * @param provider A {@link LayoutProvider} instance. |
| 19 */ |
| 20 public GestureHandlerLayoutDelegate(LayoutProvider provider) { |
| 21 mLayoutProvider = provider; |
| 22 } |
| 23 |
| 24 @Override |
| 25 public void onDown(float x, float y) { |
| 26 if (mLayoutProvider.getActiveLayout() == null) return; |
| 27 mLayoutProvider.getActiveLayout().onDown(LayoutManager.time(), x, y); |
| 28 } |
| 29 |
| 30 @Override |
| 31 public void onUpOrCancel() { |
| 32 if (mLayoutProvider.getActiveLayout() == null) return; |
| 33 mLayoutProvider.getActiveLayout().onUpOrCancel(LayoutManager.time()); |
| 34 } |
| 35 |
| 36 @Override |
| 37 public void drag(float x, float y, float dx, float dy, float tx, float ty) { |
| 38 if (mLayoutProvider.getActiveLayout() == null) return; |
| 39 mLayoutProvider.getActiveLayout().drag(LayoutManager.time(), x, y, dx, d
y); |
| 40 } |
| 41 |
| 42 @Override |
| 43 public void click(float x, float y) { |
| 44 if (mLayoutProvider.getActiveLayout() == null) return; |
| 45 mLayoutProvider.getActiveLayout().click(LayoutManager.time(), x, y); |
| 46 } |
| 47 |
| 48 @Override |
| 49 public void fling(float x, float y, float velocityX, float velocityY) { |
| 50 if (mLayoutProvider.getActiveLayout() == null) return; |
| 51 mLayoutProvider.getActiveLayout().fling(LayoutManager.time(), x, y, velo
cityX, velocityY); |
| 52 } |
| 53 |
| 54 @Override |
| 55 public void onLongPress(float x, float y) { |
| 56 if (mLayoutProvider.getActiveLayout() == null) return; |
| 57 mLayoutProvider.getActiveLayout().onLongPress(LayoutManager.time(), x, y
); |
| 58 } |
| 59 |
| 60 @Override |
| 61 public void onPinch(float x0, float y0, float x1, float y1, boolean firstEve
nt) { |
| 62 if (mLayoutProvider.getActiveLayout() == null) return; |
| 63 mLayoutProvider.getActiveLayout().onPinch(LayoutManager.time(), x0, y0,
x1, y1, firstEvent); |
| 64 } |
| 65 } |
OLD | NEW |