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

Side by Side Diff: chrome/browser/ui/views/frame/scroll_end_effect_controller_ash.h

Issue 22265009: Implement initial version of scroll end effect Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code cleanup for sadrul@ Created 7 years, 3 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/views/frame/scroll_end_effect_controller.h" 10 #include "chrome/browser/ui/views/frame/scroll_end_effect_controller.h"
11 #include "ui/base/animation/animation_delegate.h"
12 #include "ui/base/animation/slide_animation.h"
13 #include "ui/compositor/layer.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/transform.h"
10 16
11 class ScrollEndEffectControllerAsh : public ScrollEndEffectController { 17 namespace views {
18 class View;
19 }
20
21 // Class that implements the scroll end effect by controlling the layout of
22 // layers and the transforms applied to them. This class depends heavily on
23 // ScrollEndEffectControllerDelegate, which is implemented in BrowserView.
24 class ScrollEndEffectControllerAsh : public ScrollEndEffectController,
25 public ui::AnimationDelegate {
12 public: 26 public:
13 ScrollEndEffectControllerAsh(); 27 explicit ScrollEndEffectControllerAsh(
28 ScrollEndEffectControllerDelegate* delegate);
14 virtual ~ScrollEndEffectControllerAsh(); 29 virtual ~ScrollEndEffectControllerAsh();
15 30
16 // ScrollEndEffectController overides: 31 // ScrollEndEffectController overrides:
17 virtual void OverscrollUpdate(int delta_y) OVERRIDE; 32 virtual void OverscrollUpdate(int delta_y) OVERRIDE;
18 33
34 // ui::AnimationDelegate overrides:
35 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
36 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
37
19 private: 38 private:
39 // Sets up the layer hierarchy for showing the effect. This involves making
40 // sure everything is on a layer and inserting clipping layers into the
41 // hierarchy.
42 void ActivateEffect();
43
44 // Restores the layer hierarchy and states to what they were before the effect
45 // was actived.
46 void DeactivateEffect();
47
48 // Computes the transforms and counter transforms that are needed to produce
49 // the desired effect then applies them. The bounds of the layers may be
50 // adjusted due to a call to SetBoundsForEffect, so need to be stored before
51 // calling. The entire window is scaled and possibly translated to produce the
52 // squishing effect. The non-client area and the content are counter scaled to
53 // preserve their size and translated/clipped to fit in the smaller window.
54 void ApplyDelta(int delta_y);
55
56 // Adjusts the bounds for the layers of interest, so that the scroll end
57 // effect appears correctly. It is the responsibility of the caller to save
58 // and restore the bounds as needed.
59 void SetBoundsForEffect();
60
61 int GetDownloadHeight() const;
62
63 // For layers not at the origin they need to be translated to/from the origin
64 // in the transform for the simple inverse transform to be the correct counter
65 // tranformation. This is a utility method encapsulates this operation.
66 gfx::Transform CounterTransfromAboutPoint(int x, int y);
67
68 ScrollEndEffectControllerDelegate* delegate_; // non-owned
69 bool is_effect_active_;
70
71 // Layers in scoper_ptr<>s are owned by this class. All other layers are not
72 // owned by this class.
73 scoped_ptr<ui::Layer> frame_clipping_layer_;
74 scoped_ptr<ui::Layer> web_clipping_layer_;
75 ui::Layer* frame_layer_;
76 ui::Layer* non_client_layer_;
77 ui::Layer* web_contents_layer_;
78 ui::Layer* devtools_layer_;
79 ui::Layer* download_layer_;
80
81 // Used to reparent |web_contents_layer_| when deactivating the effect.
82 ui::Layer* web_contents_parent_;
83
84 // Used to reparent |devtools_layer_| when deactivating the effect.
85 ui::Layer* devtools_parent_;
86
87 // Saved when the effect is activated, so it can be restored when the
88 // effect is deactivated.
89 gfx::Rect web_contents_bounds_;
90
91 // Saved when the effect is activated, so it can be restored when the
92 // effect is deactivated.
93 gfx::Rect devtools_bounds_;
94
95 // Used to turn off being on a layer when deactivating the effect.
96 views::View* non_client_view_; // non-owned
97
98 // Used to turn off being on a layer when deactivating the effect.
99 views::View* download_view_; // non-owned
100
101 // Inverse of the transform that is being applied at the top of the hiearchy
102 // for the effect.
103 gfx::Transform counter_transform_;
104
105 int start_delta_y_;
106 int current_delta_y_;
107 int end_delta_y_;
108
109 scoped_ptr<ui::SlideAnimation> animation_;
110
20 DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectControllerAsh); 111 DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectControllerAsh);
21 }; 112 };
22 113
23 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_ 114 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698