OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 11 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
12 #include "ui/compositor/layer_animation_observer.h" | 13 #include "ui/compositor/layer_animation_observer.h" |
13 | 14 |
14 namespace aura { | 15 namespace aura { |
15 class Window; | 16 class Window; |
16 } | 17 } |
17 | 18 |
18 namespace ui { | 19 namespace ui { |
19 class Layer; | 20 class Layer; |
(...skipping 21 matching lines...) Expand all Loading... |
41 // creating a parallax scrolling effect. Left and right are reversed for RTL | 42 // creating a parallax scrolling effect. Left and right are reversed for RTL |
42 // languages, but stack order remains unchanged. | 43 // languages, but stack order remains unchanged. |
43 enum Direction { SLIDE_FRONT, SLIDE_BACK, SLIDE_NONE }; | 44 enum Direction { SLIDE_FRONT, SLIDE_BACK, SLIDE_NONE }; |
44 | 45 |
45 // Delegate class that interfaces with the window animation. | 46 // Delegate class that interfaces with the window animation. |
46 class CONTENT_EXPORT Delegate { | 47 class CONTENT_EXPORT Delegate { |
47 public: | 48 public: |
48 virtual ~Delegate() {} | 49 virtual ~Delegate() {} |
49 | 50 |
50 // Create a slide window with the given |bounds| relative to its parent. | 51 // Create a slide window with the given |bounds| relative to its parent. |
51 virtual scoped_ptr<aura::Window> CreateFrontWindow( | 52 virtual std::unique_ptr<aura::Window> CreateFrontWindow( |
52 const gfx::Rect& bounds) = 0; | 53 const gfx::Rect& bounds) = 0; |
53 virtual scoped_ptr<aura::Window> CreateBackWindow( | 54 virtual std::unique_ptr<aura::Window> CreateBackWindow( |
54 const gfx::Rect& bounds) = 0; | 55 const gfx::Rect& bounds) = 0; |
55 | 56 |
56 // Returns the main window that participates in the animation. The delegate | 57 // Returns the main window that participates in the animation. The delegate |
57 // does not own this window. | 58 // does not own this window. |
58 virtual aura::Window* GetMainWindow() const = 0; | 59 virtual aura::Window* GetMainWindow() const = 0; |
59 | 60 |
60 // Called when we know the animation is going to complete successfully, but | 61 // Called when we know the animation is going to complete successfully, but |
61 // before it actually completes. | 62 // before it actually completes. |
62 virtual void OnOverscrollCompleting() = 0; | 63 virtual void OnOverscrollCompleting() = 0; |
63 | 64 |
64 // Called when the animation has been completed. The slide window is | 65 // Called when the animation has been completed. The slide window is |
65 // transferred to the delegate. | 66 // transferred to the delegate. |
66 virtual void OnOverscrollCompleted(scoped_ptr<aura::Window> window) = 0; | 67 virtual void OnOverscrollCompleted( |
| 68 std::unique_ptr<aura::Window> window) = 0; |
67 | 69 |
68 // Called when the overscroll gesture has been cancelled, after the cancel | 70 // Called when the overscroll gesture has been cancelled, after the cancel |
69 // animation finishes. | 71 // animation finishes. |
70 virtual void OnOverscrollCancelled() = 0; | 72 virtual void OnOverscrollCancelled() = 0; |
71 }; | 73 }; |
72 | 74 |
73 explicit OverscrollWindowAnimation(Delegate* delegate); | 75 explicit OverscrollWindowAnimation(Delegate* delegate); |
74 | 76 |
75 ~OverscrollWindowAnimation() override; | 77 ~OverscrollWindowAnimation() override; |
76 | 78 |
(...skipping 23 matching lines...) Expand all Loading... |
100 | 102 |
101 // Return the front/back layer that is involved in the animation. The caller | 103 // Return the front/back layer that is involved in the animation. The caller |
102 // does not own it. | 104 // does not own it. |
103 ui::Layer* GetFrontLayer() const; | 105 ui::Layer* GetFrontLayer() const; |
104 ui::Layer* GetBackLayer() const; | 106 ui::Layer* GetBackLayer() const; |
105 | 107 |
106 // ui::ImplicitAnimationObserver: | 108 // ui::ImplicitAnimationObserver: |
107 void OnImplicitAnimationsCompleted() override; | 109 void OnImplicitAnimationsCompleted() override; |
108 | 110 |
109 // We own the window created for the animation. | 111 // We own the window created for the animation. |
110 scoped_ptr<aura::Window> slide_window_; | 112 std::unique_ptr<aura::Window> slide_window_; |
111 | 113 |
112 // Shadow shown under the animated layer. | 114 // Shadow shown under the animated layer. |
113 scoped_ptr<ShadowLayerDelegate> shadow_; | 115 std::unique_ptr<ShadowLayerDelegate> shadow_; |
114 | 116 |
115 // Delegate that provides the animation target and is notified of the | 117 // Delegate that provides the animation target and is notified of the |
116 // animation state. | 118 // animation state. |
117 Delegate* delegate_; | 119 Delegate* delegate_; |
118 | 120 |
119 // The current animation direction. | 121 // The current animation direction. |
120 Direction direction_; | 122 Direction direction_; |
121 | 123 |
122 // Indicates if the current slide has been cancelled. True while the cancel | 124 // Indicates if the current slide has been cancelled. True while the cancel |
123 // animation is in progress. | 125 // animation is in progress. |
124 bool overscroll_cancelled_; | 126 bool overscroll_cancelled_; |
125 | 127 |
126 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowAnimation); | 128 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowAnimation); |
127 }; | 129 }; |
128 | 130 |
129 } // namespace content | 131 } // namespace content |
130 | 132 |
131 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | 133 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ |
OLD | NEW |