Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/compositor/layer.h" | |
| 12 #include "ui/gfx/animation/animation_delegate.h" | |
| 13 #include "ui/gfx/animation/slide_animation.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 gfx::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 // gfx::AnimationDelegate overrides: | |
| 35 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | |
| 36 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | |
| 37 | |
| 19 private: | 38 private: |
| 39 friend class ScrollEndEffectControllerAshTest; | |
| 40 | |
| 41 // Sets up the layer hierarchy for showing the effect. This involves making | |
| 42 // sure everything is on a layer and inserting clipping layers into the | |
| 43 // hierarchy. | |
| 44 void ActivateEffect(); | |
| 45 | |
| 46 // Restores the layer hierarchy and states to what they were before the effect | |
| 47 // was actived. | |
| 48 void DeactivateEffect(); | |
| 49 | |
| 50 // Computes the transforms and counter transforms that are needed to produce | |
| 51 // the desired effect then applies them. The bounds of the layers may be | |
| 52 // adjusted due to a call to SetBoundsForEffect, so need to be stored before | |
| 53 // calling. The entire window is scaled and possibly translated to produce the | |
| 54 // squishing effect. The non-client area and the content are counter scaled to | |
| 55 // preserve their size and translated/clipped to fit in the smaller window. | |
| 56 void ApplyDelta(int delta_y); | |
| 57 | |
| 58 ScrollEndEffectControllerDelegate* delegate_; // non-owned | |
| 59 bool is_effect_active_; | |
| 60 | |
| 61 // The size of the frame at the size of the effect, so that the effect can | |
|
sadrul
2013/10/25 18:28:25
'at the beginning/start of the effect'?
rharrison
2013/11/18 21:52:26
Done.
| |
| 62 // scale relative to that and it can be restored at the end. | |
| 63 gfx::Rect frame_bounds_; | |
| 64 | |
| 65 // Control variables related to the current delta_y being applied for the | |
| 66 // effect and used when animating. | |
| 67 int start_delta_y_; | |
| 68 int current_delta_y_; | |
| 69 int end_delta_y_; | |
| 70 | |
| 71 scoped_ptr<gfx::SlideAnimation> animation_; | |
| 72 | |
| 20 DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectControllerAsh); | 73 DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectControllerAsh); |
| 21 }; | 74 }; |
| 22 | 75 |
| 23 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_ | 76 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_ |
| OLD | NEW |