OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_ | 5 #ifndef CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_ |
6 #define CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_ | 6 #define CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "ui/base/animation/animation_delegate.h" | 12 #include "ui/base/animation/animation_delegate.h" |
13 #include "ui/gfx/compositor/compositor_observer.h" | 13 #include "ui/gfx/compositor/compositor_observer.h" |
14 #include "ui/gfx/point.h" | 14 #include "ui/gfx/point.h" |
15 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 class InterpolatedTransform; | 18 class InterpolatedTransform; |
19 class Layer; | 19 class Layer; |
| 20 class LayerAnimationDelegate; |
20 class SlideAnimation; | 21 class SlideAnimation; |
21 class Transform; | 22 class Transform; |
22 } | 23 } |
23 | 24 |
24 namespace gfx { | 25 namespace gfx { |
25 class Rect; | 26 class Rect; |
26 } | 27 } |
27 | 28 |
28 namespace views { | 29 namespace views { |
29 class PaintLock; | 30 class PaintLock; |
(...skipping 14 matching lines...) Expand all Loading... |
44 // A screen rotation represents a single transition from one screen orientation | 45 // A screen rotation represents a single transition from one screen orientation |
45 // to another. The intended usage is that a new instance of the class is | 46 // to another. The intended usage is that a new instance of the class is |
46 // created for every transition. It is possible to update the target orientation | 47 // created for every transition. It is possible to update the target orientation |
47 // in the middle of a transition. | 48 // in the middle of a transition. |
48 class ScreenRotation : public ui::AnimationDelegate, | 49 class ScreenRotation : public ui::AnimationDelegate, |
49 public ui::CompositorObserver { | 50 public ui::CompositorObserver { |
50 public: | 51 public: |
51 // The screen rotation does not own the view or the listener, and these | 52 // The screen rotation does not own the view or the listener, and these |
52 // objects are required to outlive the Screen rotation object. | 53 // objects are required to outlive the Screen rotation object. |
53 ScreenRotation(views::View* view, | 54 ScreenRotation(views::View* view, |
| 55 ui::LayerAnimationDelegate* delegate, |
54 ScreenRotationListener* listener, | 56 ScreenRotationListener* listener, |
55 float old_degrees, | 57 float old_degrees, |
56 float new_degrees); | 58 float new_degrees); |
57 virtual ~ScreenRotation(); | 59 virtual ~ScreenRotation(); |
58 | 60 |
59 // Aborts the animation by skipping to the end and applying the final | 61 // Aborts the animation by skipping to the end and applying the final |
60 // transform before calling |Finalize|. | 62 // transform before calling |Finalize|. |
61 void Stop(); | 63 void Stop(); |
62 | 64 |
63 private: | 65 private: |
(...skipping 21 matching lines...) Expand all Loading... |
85 // We occasionally need to wait for a paint to finish before progressing. | 87 // We occasionally need to wait for a paint to finish before progressing. |
86 // This function (which is triggered by OnPainted and OnComposited) does | 88 // This function (which is triggered by OnPainted and OnComposited) does |
87 // any pending work. | 89 // any pending work. |
88 void DoPendingWork(); | 90 void DoPendingWork(); |
89 | 91 |
90 // This is the view that will be animated. The animation will operate mainly | 92 // This is the view that will be animated. The animation will operate mainly |
91 // on |view_|'s layer, but it is used upon completion of the rotation to | 93 // on |view_|'s layer, but it is used upon completion of the rotation to |
92 // update the bounds. | 94 // update the bounds. |
93 views::View* view_; | 95 views::View* view_; |
94 | 96 |
| 97 // This is the delegate that will be modified during the rotation. It is |
| 98 // important not to modify the rotation directly, otherwise we will cause |
| 99 // other, implicit animations. |
| 100 ui::LayerAnimationDelegate* delegate_; |
| 101 |
95 // This widget will be used for scheduling paints. | 102 // This widget will be used for scheduling paints. |
96 views::Widget* widget_; | 103 views::Widget* widget_; |
97 | 104 |
98 // A ScreenRotation may be associated with a listener that is notified when | 105 // A ScreenRotation may be associated with a listener that is notified when |
99 // the screen rotation completes. | 106 // the screen rotation completes. |
100 ScreenRotationListener* listener_; | 107 ScreenRotationListener* listener_; |
101 | 108 |
102 // The animation object that instigates stepping of the animation. | 109 // The animation object that instigates stepping of the animation. |
103 scoped_ptr<ui::SlideAnimation> animation_; | 110 scoped_ptr<ui::SlideAnimation> animation_; |
104 | 111 |
(...skipping 20 matching lines...) Expand all Loading... |
125 int duration_; | 132 int duration_; |
126 | 133 |
127 // These are used by DoPendingWork to decide what needs to be done. | 134 // These are used by DoPendingWork to decide what needs to be done. |
128 bool animation_started_; | 135 bool animation_started_; |
129 bool animation_stopped_; | 136 bool animation_stopped_; |
130 | 137 |
131 DISALLOW_COPY_AND_ASSIGN(ScreenRotation); | 138 DISALLOW_COPY_AND_ASSIGN(ScreenRotation); |
132 }; | 139 }; |
133 | 140 |
134 #endif // CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_ | 141 #endif // CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_ |
OLD | NEW |