OLD | NEW |
| (Empty) |
1 // Copyright 2012 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 #include "config.h" | |
6 | |
7 #include "CCScrollbarAnimationController.h" | |
8 | |
9 #include "CCScrollbarLayerImpl.h" | |
10 #include <wtf/CurrentTime.h> | |
11 | |
12 #if OS(ANDROID) | |
13 #include "CCScrollbarAnimationControllerLinearFade.h" | |
14 #endif | |
15 | |
16 namespace cc { | |
17 | |
18 #if OS(ANDROID) | |
19 PassOwnPtr<CCScrollbarAnimationController> CCScrollbarAnimationController::creat
e(CCLayerImpl* scrollLayer) | |
20 { | |
21 static const double fadeoutDelay = 0.3; | |
22 static const double fadeoutLength = 0.3; | |
23 return CCScrollbarAnimationControllerLinearFade::create(scrollLayer, fadeout
Delay, fadeoutLength); | |
24 } | |
25 #else | |
26 PassOwnPtr<CCScrollbarAnimationController> CCScrollbarAnimationController::creat
e(CCLayerImpl* scrollLayer) | |
27 { | |
28 return adoptPtr(new CCScrollbarAnimationController(scrollLayer)); | |
29 } | |
30 #endif | |
31 | |
32 CCScrollbarAnimationController::CCScrollbarAnimationController(CCLayerImpl* scro
llLayer) | |
33 : m_horizontalScrollbarLayer(0) | |
34 , m_verticalScrollbarLayer(0) | |
35 { | |
36 CCScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, 0); | |
37 } | |
38 | |
39 CCScrollbarAnimationController::~CCScrollbarAnimationController() | |
40 { | |
41 } | |
42 | |
43 bool CCScrollbarAnimationController::animate(double) | |
44 { | |
45 return false; | |
46 } | |
47 | |
48 void CCScrollbarAnimationController::didPinchGestureBegin() | |
49 { | |
50 didPinchGestureBeginAtTime(monotonicallyIncreasingTime()); | |
51 } | |
52 | |
53 void CCScrollbarAnimationController::didPinchGestureUpdate() | |
54 { | |
55 didPinchGestureUpdateAtTime(monotonicallyIncreasingTime()); | |
56 } | |
57 | |
58 void CCScrollbarAnimationController::didPinchGestureEnd() | |
59 { | |
60 didPinchGestureEndAtTime(monotonicallyIncreasingTime()); | |
61 } | |
62 | |
63 void CCScrollbarAnimationController::updateScrollOffset(CCLayerImpl* scrollLayer
) | |
64 { | |
65 updateScrollOffsetAtTime(scrollLayer, monotonicallyIncreasingTime()); | |
66 } | |
67 | |
68 IntSize CCScrollbarAnimationController::getScrollLayerBounds(const CCLayerImpl*
scrollLayer) | |
69 { | |
70 if (!scrollLayer->children().size()) | |
71 return IntSize(); | |
72 // Copy & paste from CCLayerTreeHostImpl... | |
73 // FIXME: Hardcoding the first child here is weird. Think of | |
74 // a cleaner way to get the contentBounds on the Impl side. | |
75 return scrollLayer->children()[0]->bounds(); | |
76 } | |
77 | |
78 void CCScrollbarAnimationController::updateScrollOffsetAtTime(CCLayerImpl* scrol
lLayer, double) | |
79 { | |
80 m_currentPos = scrollLayer->scrollPosition() + scrollLayer->scrollDelta(); | |
81 m_totalSize = getScrollLayerBounds(scrollLayer); | |
82 m_maximum = scrollLayer->maxScrollPosition(); | |
83 | |
84 if (m_horizontalScrollbarLayer) { | |
85 m_horizontalScrollbarLayer->setCurrentPos(m_currentPos.x()); | |
86 m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width()); | |
87 m_horizontalScrollbarLayer->setMaximum(m_maximum.width()); | |
88 } | |
89 | |
90 if (m_verticalScrollbarLayer) { | |
91 m_verticalScrollbarLayer->setCurrentPos(m_currentPos.y()); | |
92 m_verticalScrollbarLayer->setTotalSize(m_totalSize.height()); | |
93 m_verticalScrollbarLayer->setMaximum(m_maximum.height()); | |
94 } | |
95 } | |
96 | |
97 } // namespace cc | |
OLD | NEW |