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/rect.h" |
| 13 #include "ui/gfx/transform.h" |
10 | 14 |
| 15 namespace views { |
| 16 class View; |
| 17 } |
| 18 |
| 19 // Class that implements the scroll end effect by controlling the layout of |
| 20 // layers and the transforms applied to them. This class depends heavily on |
| 21 // ScrollEndEffectControllerDelegate, which is implemented in BrowserView. |
11 class ScrollEndEffectControllerAsh : public ScrollEndEffectController { | 22 class ScrollEndEffectControllerAsh : public ScrollEndEffectController { |
12 public: | 23 public: |
13 ScrollEndEffectControllerAsh(); | 24 explicit ScrollEndEffectControllerAsh( |
| 25 ScrollEndEffectControllerDelegate* delegate); |
14 virtual ~ScrollEndEffectControllerAsh(); | 26 virtual ~ScrollEndEffectControllerAsh(); |
15 | 27 |
16 // ScrollEndEffectController overides: | 28 // ScrollEndEffectController overides: |
17 virtual void OverscrollUpdate(int delta_y) OVERRIDE; | 29 virtual void OverscrollUpdate(int delta_y) OVERRIDE; |
18 | 30 |
19 private: | 31 private: |
| 32 // Sets up the layer hierarchy for showing the effect. This involves making |
| 33 // sure everything is on a layer and inserting clipping layers into the |
| 34 // hierarchy. |
| 35 void ActivateEffect(); |
| 36 |
| 37 // Utility methods used to create needed layers. |
| 38 ui::Layer* CreateClippingLayer(std::string name); |
| 39 ui::Layer* CreateViewLayer(views::View* view); |
| 40 |
| 41 // Restores the layer hierarchy and states to what they were before the effect |
| 42 // was actived. |
| 43 void DeactivateEffect(); |
| 44 |
| 45 // Computes the transforms and counter transforms that are needed to produce |
| 46 // the desired effect then applies them. The bounds of the layers may be |
| 47 // adjusted due to a call to SetBoundsForEffect, so need to be stored before |
| 48 // calling. The entire window is scaled and possibly translated to produce the |
| 49 // squishing effect. The non-client area and the content are counter scaled to |
| 50 // preserve their size and translated/clipped to fit in the smaller window. |
| 51 void ApplyDelta(int delta_y); |
| 52 |
| 53 // Adjusts the bounds for the layers of interest, so that the scroll end |
| 54 // effect appears correctly. It is the responsibility of the caller to save |
| 55 // and restore the bounds as needed. |
| 56 void SetBoundsForEffect(); |
| 57 |
| 58 // For layers not at the origin they need to be translated to/from the origin |
| 59 // in the transform for the simple inverse transform to be the correct counter |
| 60 // tranformation. This is a utility method encapsulates this operation. |
| 61 gfx::Transform CounterTransfromAboutPoint(int x, int y); |
| 62 |
| 63 ScrollEndEffectControllerDelegate* delegate_; // non-owned |
| 64 bool is_effect_active_; |
| 65 |
| 66 scoped_ptr<ui::Layer> frame_clipping_layer_; |
| 67 scoped_ptr<ui::Layer> web_clipping_layer_; |
| 68 ui::Layer* non_client_layer_; |
| 69 ui::Layer* web_contents_layer_; // non-owned |
| 70 ui::Layer* devtools_layer_; // non-owned |
| 71 ui::Layer* download_layer_; |
| 72 |
| 73 // Used to reparent |web_contents_layer_| when deactivating the effect. |
| 74 ui::Layer* web_contents_parent_; // non-owned |
| 75 |
| 76 // Used to reparent |devtools_layer_| when deactivating the effect. |
| 77 ui::Layer* devtools_parent_; // non-owned |
| 78 |
| 79 // Saved when the effect is activated, so it can be restored when the |
| 80 // effect is deactivated. |
| 81 gfx::Rect web_contents_bounds_; |
| 82 |
| 83 // Saved when the effect is activated, so it can be restored when the |
| 84 // effect is deactivated. |
| 85 gfx::Rect devtools_bounds_; |
| 86 |
| 87 // Used to turn off being on a layer when deactivating the effect. |
| 88 views::View* non_client_view_; // non-owned |
| 89 |
| 90 // Used to turn off being on a layer when deactivating the effect. |
| 91 views::View* download_view_; // non-owned |
| 92 |
| 93 // Inverse of the transform that is being applied at the top of the hiearchy |
| 94 // for the effect. |
| 95 gfx::Transform counter_transform_; |
| 96 |
20 DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectControllerAsh); | 97 DISALLOW_COPY_AND_ASSIGN(ScrollEndEffectControllerAsh); |
21 }; | 98 }; |
22 | 99 |
23 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_ | 100 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_SCROLL_END_EFFECT_CONTROLLER_ASH_H_ |
OLD | NEW |