OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include "ui/aura/layout_manager.h" | 12 #include "ui/aura/layout_manager.h" |
12 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
13 #include "ui/gfx/compositor/layer_animation_observer.h" | 14 #include "ash/wm/shelf_animation_observer_client.h" |
14 #include "ui/gfx/insets.h" | 15 #include "ui/gfx/insets.h" |
15 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
16 | 17 |
17 namespace views { | 18 namespace views { |
18 class Widget; | 19 class Widget; |
19 } | 20 } |
20 | 21 |
21 namespace ash { | 22 namespace ash { |
22 namespace internal { | 23 namespace internal { |
23 | 24 |
24 // ShelfLayoutManager is the layout manager responsible for the launcher and | 25 // ShelfLayoutManager is the layout manager responsible for the launcher and |
25 // status widgets. The launcher is given the total available width and told the | 26 // status widgets. The launcher is given the total available width and told the |
26 // width of the status area. This allows the launcher to draw the background and | 27 // width of the status area. This allows the launcher to draw the background and |
27 // layout to the status area. | 28 // layout to the status area. |
28 // To respond to bounds changes in the status area StatusAreaLayoutManager works | 29 // To respond to bounds changes in the status area StatusAreaLayoutManager works |
29 // closely with ShelfLayoutManager. | 30 // closely with ShelfLayoutManager. |
30 class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager, | 31 class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager, |
31 public ui::LayerAnimationObserver { | 32 public ShelfAnimationObserverClient { |
32 public: | 33 public: |
33 ShelfLayoutManager(views::Widget* launcher, views::Widget* status); | 34 ShelfLayoutManager(views::Widget* launcher, views::Widget* status); |
34 virtual ~ShelfLayoutManager(); | 35 virtual ~ShelfLayoutManager(); |
35 | 36 |
36 bool in_layout() const { return in_layout_; } | 37 bool in_layout() const { return in_layout_; } |
37 | 38 |
38 // Stops any animations and sets the bounds of the launcher and status | 39 // Stops any animations and sets the bounds of the launcher and status |
39 // widgets. | 40 // widgets. |
40 void LayoutShelf(); | 41 void LayoutShelf(); |
41 | 42 |
42 // Sets the visibility of the shelf to |visible|. | 43 // Sets the visibility of the shelf to |visible|. |
43 void SetVisible(bool visible); | 44 void SetVisible(bool visible); |
44 bool visible() const { return animating_ ? !visible_ : visible_; } | 45 bool visible() const { return visible_; } |
45 | 46 |
46 views::Widget* launcher() { return launcher_; } | 47 views::Widget* launcher() { return launcher_; } |
47 views::Widget* status() { return status_; } | 48 views::Widget* status() { return status_; } |
48 | 49 |
49 // See description above field. | 50 // See description above field. |
50 int max_height() const { return max_height_; } | 51 int max_height() const { return max_height_; } |
51 | 52 |
52 // Overridden from aura::LayoutManager: | 53 // Overridden from aura::LayoutManager: |
53 virtual void OnWindowResized() OVERRIDE; | 54 virtual void OnWindowResized() OVERRIDE; |
54 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; | 55 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
67 | 68 |
68 // Stops any animations. | 69 // Stops any animations. |
69 void StopAnimating(); | 70 void StopAnimating(); |
70 | 71 |
71 // Calculates the target bounds assuming visibility of |visible|. | 72 // Calculates the target bounds assuming visibility of |visible|. |
72 void CalculateTargetBounds(bool visible, | 73 void CalculateTargetBounds(bool visible, |
73 TargetBounds* target_bounds); | 74 TargetBounds* target_bounds); |
74 | 75 |
75 // Animates |widget| to the specified bounds and opacity. | 76 // Animates |widget| to the specified bounds and opacity. |
76 void AnimateWidgetTo(views::Widget* widget, | 77 void AnimateWidgetTo(views::Widget* widget, |
| 78 ui::ImplicitAnimationObserver* observer, |
77 const gfx::Rect& target_bounds, | 79 const gfx::Rect& target_bounds, |
78 float target_opacity); | 80 float target_opacity); |
79 | 81 |
80 // LayerAnimationObserver overrides: | 82 // ShelfAnimationObserverClient overrides: |
81 virtual void OnLayerAnimationEnded( | 83 virtual void OnShelfAnimationsCompleted( |
82 const ui::LayerAnimationSequence* sequence) OVERRIDE; | 84 ui::ImplicitAnimationObserver*) OVERRIDE; |
83 virtual void OnLayerAnimationAborted( | |
84 const ui::LayerAnimationSequence* sequence) OVERRIDE {} | |
85 virtual void OnLayerAnimationScheduled( | |
86 const ui::LayerAnimationSequence* sequence) OVERRIDE {} | |
87 | |
88 // Are we animating? | |
89 bool animating_; | |
90 | 85 |
91 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf | 86 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf |
92 // again from SetChildBounds(). | 87 // again from SetChildBounds(). |
93 bool in_layout_; | 88 bool in_layout_; |
94 | 89 |
95 // Current visibility. When the visibility changes this field is reset once | 90 // Current visibility. When the visibility changes this field is reset once |
96 // the animation completes. | 91 // the animation completes. |
97 bool visible_; | 92 bool visible_; |
98 | 93 |
99 // Max height needed. | 94 // Max height needed. |
100 int max_height_; | 95 int max_height_; |
101 | 96 |
| 97 // The live observers. When the manager is destroyed, they are |
| 98 // removed and deleted. The shelf layout manager owns the observers. |
| 99 scoped_ptr<ui::ImplicitAnimationObserver> launcher_animation_observer_; |
| 100 scoped_ptr<ui::ImplicitAnimationObserver> status_animation_observer_; |
| 101 |
102 views::Widget* launcher_; | 102 views::Widget* launcher_; |
103 views::Widget* status_; | 103 views::Widget* status_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 105 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace internal | 108 } // namespace internal |
109 } // namespace ash | 109 } // namespace ash |
110 | 110 |
111 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 111 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
OLD | NEW |