Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Side by Side Diff: chrome/browser/ui/touch/animation/screen_rotation.h

Issue 7273073: Animated Rotation (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Moved screen rotation code under touch; use lock object to disable painting Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_
6 #define CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/task.h"
12 #include "ui/base/animation/animation_delegate.h"
13 #include "ui/gfx/point.h"
14 #include "ui/gfx/size.h"
15
16 namespace ui {
17 class SlideAnimation;
sky 2011/08/25 21:10:12 nit: sort these
18 class InterpolatedTransform;
19 class Layer;
20 class Transform;
21 }
22
23 namespace gfx {
24 class Rect;
25 }
26
27 namespace views {
28 class View;
29 class PaintLock;
30 }
31
32 // Classes that wish to be notified when a screen rotation completes must
33 // implement the screen rotation listener interface.
34 class ScreenRotationListenerInterface {
sky 2011/08/25 21:10:12 Nuke the interface, eg ScreenRotationListener, or
35 public:
36 virtual void OnScreenRotationCompleted(const ui::Transform& target_transform,
37 const gfx::Rect& target_bounds) = 0;
38 virtual ~ScreenRotationListenerInterface();
39 };
sky 2011/08/25 21:10:12 Add a virtual protected destructor
40
41 // A screen rotation represents a single transition from one screen orientation
42 // to another. The intended usage is that a new instance of the class is
43 // created for every transition. It is possible to update the target orientation
44 // in the middle of a transition.
45 class ScreenRotation : public ui::AnimationDelegate {
46 public:
47 // The screen rotation does not own the view or the listener, and these
48 // objects are required to outlive the Screen rotation object.
49 ScreenRotation(views::View* view,
50 ScreenRotationListenerInterface* listener,
51 float old_degrees,
52 float new_degrees);
53 virtual ~ScreenRotation();
54
55 // Initializes the screen rotation and starts |animation_|.
56 void Start();
57
58 // Called after the animation is finished and the view has completed painting
59 // in its final state.
60 void Finalize();
61
62 // Use this function to change the target orientation mid animation. The
63 // currently running transition will complete at the same time as it was going
64 // to originally, but in a different orientation.
65 void SetTarget(float degrees);
66
67 private:
68 // Implementation of ui::AnimationDelegate
69 virtual void AnimationEnded(const ui::Animation* anim) OVERRIDE;
70 virtual void AnimationProgressed(const ui::Animation* anim) OVERRIDE;
71
72 // Initializes |interpolated_transform_|, |new_origin_|, |new_size_|, and
73 // (if it has not already been initialized) |old_transform_|
74 void Init();
75
76 // Converts degrees to an angle in the range [-180, 180).
77 int NormalizeAngle(int degrees);
78
79 // This is the view that will be animated. The animation will operate mainly
80 // on |view_|'s layer, but it is used upon completion of the rotation to
81 // update the bounds.
82 views::View* view_;
83
84 // A ScreenRotation may be associated with a listener that is notified when
85 // the screen rotation completes.
86 ScreenRotationListenerInterface* listener_;
87
88 // The animation object that instigates stepping of the animation.
89 scoped_ptr<ui::SlideAnimation> animation_;
90
91 // Generates the intermediate transformation matrices used during the
92 // animation.
93 scoped_ptr<ui::InterpolatedTransform> interpolated_transform_;
94
95 // Ensures that the view is not repainted during the screen rotation.
96 scoped_ptr<views::PaintLock> paint_lock_;
97
98 // The original orientation (not updated by |SetTarget|.
99 float old_degrees_;
100
101 // The target orientation.
102 float new_degrees_;
103
104 // We keep track of the last step of the animation in case we change our
105 // target in the middle and have to create a new transition from last_t_ to 1
106 float last_t_;
107
108 // The target size for |view_|
109 gfx::Size new_size_;
110
111 // The target origin for |view_|
112 gfx::Point new_origin_;
113
114 // This is the duration of the transition in milliseconds
115 int duration_;
116
117 // This is used to post a task to update the bounds after the final call to
118 // SchedulePaint completes.
119 ScopedRunnableMethodFactory<ScreenRotation> method_factory_;
120
121 DISALLOW_COPY_AND_ASSIGN(ScreenRotation);
122 };
123
124 #endif // CHROME_BROWSER_UI_TOUCH_ANIMATION_SCREEN_ROTATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698