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.
5 #ifndef CC_SCROLLBAR_ANIMATION_CONTROLLER_H_
6 #define CC_SCROLLBAR_ANIMATION_CONTROLLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/cc_export.h"
10 #include "ui/gfx/size.h"
11 #include "ui/gfx/vector2d.h"
12 #include "ui/gfx/vector2d_f.h"
17 class ScrollbarLayerImpl
;
19 // This abstract class represents the compositor-side analogy of ScrollbarAnimator.
20 // Individual platforms should subclass it to provide specialized implementation.
21 class CC_EXPORT ScrollbarAnimationController
{
23 static scoped_ptr
<ScrollbarAnimationController
> create(LayerImpl
* scrollLayer
);
25 virtual ~ScrollbarAnimationController();
27 virtual bool animate(double monotonicTime
);
28 void didPinchGestureBegin();
29 void didPinchGestureUpdate();
30 void didPinchGestureEnd();
31 void updateScrollOffset(LayerImpl
* scrollLayer
);
33 void setHorizontalScrollbarLayer(ScrollbarLayerImpl
* layer
) { m_horizontalScrollbarLayer
= layer
; }
34 ScrollbarLayerImpl
* horizontalScrollbarLayer() const { return m_horizontalScrollbarLayer
; }
36 void setVerticalScrollbarLayer(ScrollbarLayerImpl
* layer
) { m_verticalScrollbarLayer
= layer
; }
37 ScrollbarLayerImpl
* verticalScrollbarLayer() const { return m_verticalScrollbarLayer
; }
39 gfx::Vector2dF
currentOffset() const { return m_currentOffset
; }
40 gfx::Size
totalSize() const { return m_totalSize
; }
41 gfx::Vector2d
maximum() const { return m_maximum
; }
43 virtual void didPinchGestureBeginAtTime(double monotonicTime
) { }
44 virtual void didPinchGestureUpdateAtTime(double monotonicTime
) { }
45 virtual void didPinchGestureEndAtTime(double monotonicTime
) { }
46 virtual void updateScrollOffsetAtTime(LayerImpl
* scrollLayer
, double monotonicTime
);
49 explicit ScrollbarAnimationController(LayerImpl
* scrollLayer
);
52 static gfx::Size
getScrollLayerBounds(const LayerImpl
*);
54 // Beware of dangling pointer. Always update these during tree synchronization.
55 ScrollbarLayerImpl
* m_horizontalScrollbarLayer
;
56 ScrollbarLayerImpl
* m_verticalScrollbarLayer
;
58 gfx::Vector2dF m_currentOffset
;
59 gfx::Size m_totalSize
;
60 gfx::Vector2d m_maximum
;
65 #endif // CC_SCROLLBAR_ANIMATION_CONTROLLER_H_