OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | |
6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | |
7 | |
8 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | |
9 #include "content/common/content_export.h" | |
10 #include "ui/compositor/layer_animation_observer.h" | |
11 | |
12 namespace ui { | |
13 class Layer; | |
14 class LayerAnimator; | |
15 } | |
16 | |
17 namespace content { | |
18 | |
19 class OverscrollLayerWrapper; | |
20 | |
21 // Manages the animations during an overscroll navigation by handling overscroll | |
22 // events. | |
23 class CONTENT_EXPORT OverscrollWindowAnimation | |
24 : ui::ImplicitAnimationObserver, | |
25 public OverscrollControllerDelegate { | |
26 public: | |
27 enum Direction { FORWARD, BACKWARD, NONE }; | |
28 | |
29 // Delegate class that interfaces with the window animation, responsible for | |
30 // navigation. | |
31 class Delegate { | |
32 public: | |
33 virtual ~Delegate() {} | |
34 | |
35 // The following two functions create a layer wrapper and transfer back its | |
36 // ownership. | |
37 virtual scoped_ptr<OverscrollLayerWrapper> CreateFrontLayer() = 0; | |
38 virtual scoped_ptr<OverscrollLayerWrapper> CreateBackLayer() = 0; | |
39 | |
40 // Called when the animation has been completed. The delagate can then | |
41 // dismiss the overlay layer, or wait for the page to load first. | |
42 virtual void OnOverscrollCompleted() = 0; | |
mfomitchev
2015/02/27 21:33:42
consider passing the scoped ptr to the wrapper her
| |
43 | |
44 // Called when we know the animation is going to complete. This should start | |
45 // the navigation. | |
46 virtual void OnOverscrollCompleting() = 0; | |
47 }; | |
48 | |
49 OverscrollWindowAnimation(); | |
50 | |
51 ~OverscrollWindowAnimation() override; | |
52 | |
53 // Returns true if there is a slide animation currently in progress. | |
54 bool is_animation_in_progress() const { return animation_active_; } | |
55 | |
56 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | |
57 | |
58 // Overridden from OverscrollControllerDelegate: | |
59 gfx::Rect GetVisibleBounds() const override; | |
60 | |
61 bool OnOverscrollUpdate(float delta_x, float delta_y) override; | |
62 | |
63 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; | |
64 | |
65 void OnOverscrollModeChange(OverscrollMode old_mode, | |
66 OverscrollMode new_mode) override; | |
67 | |
68 private: | |
69 // Starts the overscroll cancelled animation. | |
70 void CancelOverscroll(); | |
71 | |
72 // Moves the animated window according to the given scroll deltas. Returns | |
73 // true if the update moved the window. | |
74 bool UpdateForScroll(float delta_x); | |
75 | |
76 // Returns a translation for the given overscroll. | |
77 gfx::Vector2dF GetTranslationForOverscroll(float delta_x); | |
78 | |
79 // Overridden from ui::ImplicitAnimationObserver: | |
80 void OnImplicitAnimationsCompleted() override; | |
81 | |
82 // Wrapper that owns the overscroll window. | |
83 scoped_ptr<OverscrollLayerWrapper> layer_wrapper_; | |
84 | |
85 // Delegate that provides the animation target and handles navigation. | |
86 Delegate* delegate_; | |
87 | |
88 // The current overscroll direction. | |
89 Direction direction_; | |
90 | |
91 // True if the overscroll animation is happening right now. | |
92 bool animation_active_; | |
mfomitchev
2015/02/27 21:33:42
nit: may be a bit ambiguous: active_ instead of an
Nina
2015/03/09 15:54:52
Done.
| |
93 }; | |
94 | |
95 } // namespace content | |
96 | |
97 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ | |
OLD | NEW |