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_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 5 #ifndef ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/shelf/background_animator.h" | 9 #include "ash/shelf/background_animator.h" |
10 #include "ash/shelf/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
11 #include "ash/system/tray/actionable_view.h" | 11 #include "ash/system/tray/actionable_view.h" |
| 12 #include "ui/gfx/animation/animation_delegate.h" |
12 #include "ui/views/bubble/tray_bubble_view.h" | 13 #include "ui/views/bubble/tray_bubble_view.h" |
13 | 14 |
| 15 namespace gfx { |
| 16 class SlideAnimation; |
| 17 } // namespace gfx |
| 18 |
14 namespace ash { | 19 namespace ash { |
15 class ShelfLayoutManager; | 20 class ShelfLayoutManager; |
16 class StatusAreaWidget; | 21 class StatusAreaWidget; |
17 class TrayEventFilter; | 22 class TrayEventFilter; |
18 class TrayBackground; | 23 class TrayBackground; |
19 | 24 |
20 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, | 25 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, |
21 // LogoutButtonTray. | 26 // LogoutButtonTray, OverviewButtonTray. |
22 // This class handles setting and animating the background when the Launcher | 27 // This class handles setting and animating the background when the Launcher |
23 // his shown/hidden. It also inherits from ActionableView so that the tray | 28 // his shown/hidden. It also inherits from ActionableView so that the tray |
24 // items can override PerformAction when clicked on. | 29 // items can override PerformAction when clicked on. |
25 class ASH_EXPORT TrayBackgroundView : public ActionableView, | 30 class ASH_EXPORT TrayBackgroundView : public ActionableView, |
26 public BackgroundAnimatorDelegate { | 31 public BackgroundAnimatorDelegate, |
| 32 public gfx::AnimationDelegate { |
27 public: | 33 public: |
28 static const char kViewClassName[]; | 34 static const char kViewClassName[]; |
29 | 35 |
30 // Base class for tray containers. Sets the border and layout. The container | 36 // Base class for tray containers. Sets the border and layout. The container |
31 // auto-resizes the widget when necessary. | 37 // auto-resizes the widget when necessary. |
32 class TrayContainer : public views::View { | 38 class TrayContainer : public views::View { |
33 public: | 39 public: |
34 explicit TrayContainer(ShelfAlignment alignment); | 40 explicit TrayContainer(ShelfAlignment alignment); |
35 virtual ~TrayContainer() {} | 41 virtual ~TrayContainer() {} |
36 | 42 |
37 void SetAlignment(ShelfAlignment alignment); | 43 void SetAlignment(ShelfAlignment alignment); |
38 | 44 |
39 void set_size(const gfx::Size& size) { size_ = size; } | 45 void set_size(const gfx::Size& size) { size_ = size; } |
40 | 46 |
41 // Overridden from views::View. | 47 // views::View: |
42 virtual gfx::Size GetPreferredSize() OVERRIDE; | 48 virtual gfx::Size GetPreferredSize() OVERRIDE; |
43 | 49 |
44 protected: | 50 protected: |
45 // Overridden from views::View. | 51 // views::View: |
46 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | 52 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
47 virtual void ChildVisibilityChanged(View* child) OVERRIDE; | 53 virtual void ChildVisibilityChanged(View* child) OVERRIDE; |
48 virtual void ViewHierarchyChanged( | 54 virtual void ViewHierarchyChanged( |
49 const ViewHierarchyChangedDetails& details) OVERRIDE; | 55 const ViewHierarchyChangedDetails& details) OVERRIDE; |
50 | 56 |
51 private: | 57 private: |
52 void UpdateLayout(); | 58 void UpdateLayout(); |
53 | 59 |
54 ShelfAlignment alignment_; | 60 ShelfAlignment alignment_; |
55 gfx::Size size_; | 61 gfx::Size size_; |
56 | 62 |
57 DISALLOW_COPY_AND_ASSIGN(TrayContainer); | 63 DISALLOW_COPY_AND_ASSIGN(TrayContainer); |
58 }; | 64 }; |
59 | 65 |
60 explicit TrayBackgroundView(StatusAreaWidget* status_area_widget); | 66 explicit TrayBackgroundView(StatusAreaWidget* status_area_widget); |
61 virtual ~TrayBackgroundView(); | 67 virtual ~TrayBackgroundView(); |
62 | 68 |
63 // Called after the tray has been added to the widget containing it. | 69 // Called after the tray has been added to the widget containing it. |
64 virtual void Initialize(); | 70 virtual void Initialize(); |
65 | 71 |
66 // Overridden from views::View. | 72 // views::View: |
| 73 virtual void SetVisible(bool visible) OVERRIDE; |
| 74 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 75 virtual int GetHeightForWidth(int width) OVERRIDE; |
67 virtual const char* GetClassName() const OVERRIDE; | 76 virtual const char* GetClassName() const OVERRIDE; |
68 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 77 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
69 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 78 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
70 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | 79 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
71 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 80 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
72 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 81 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
73 | 82 |
74 // Overridden from ActionableView. | 83 // ActionableView: |
75 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 84 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
76 virtual gfx::Rect GetFocusBounds() OVERRIDE; | 85 virtual gfx::Rect GetFocusBounds() OVERRIDE; |
77 | 86 |
78 // Overridden from BackgroundAnimatorDelegate. | 87 // BackgroundAnimatorDelegate: |
79 virtual void UpdateBackground(int alpha) OVERRIDE; | 88 virtual void UpdateBackground(int alpha) OVERRIDE; |
80 | 89 |
81 // Called whenever the shelf alignment changes. | 90 // Called whenever the shelf alignment changes. |
82 virtual void SetShelfAlignment(ShelfAlignment alignment); | 91 virtual void SetShelfAlignment(ShelfAlignment alignment); |
83 | 92 |
84 // Called when the anchor (tray or bubble) may have moved or changed. | 93 // Called when the anchor (tray or bubble) may have moved or changed. |
85 virtual void AnchorUpdated() {} | 94 virtual void AnchorUpdated() {} |
86 | 95 |
87 // Called from GetAccessibleState, must return a valid accessible name. | 96 // Called from GetAccessibleState, must return a valid accessible name. |
88 virtual base::string16 GetAccessibleNameForTray() = 0; | 97 virtual base::string16 GetAccessibleNameForTray() = 0; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } | 150 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } |
142 | 151 |
143 ShelfLayoutManager* GetShelfLayoutManager(); | 152 ShelfLayoutManager* GetShelfLayoutManager(); |
144 | 153 |
145 // Updates the arrow visibility based on the launcher visibility. | 154 // Updates the arrow visibility based on the launcher visibility. |
146 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); | 155 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); |
147 | 156 |
148 private: | 157 private: |
149 class TrayWidgetObserver; | 158 class TrayWidgetObserver; |
150 | 159 |
| 160 friend class OverviewButtonTrayTest; |
| 161 friend class SystemTrayTest; |
| 162 friend class WebNotificationTrayTest; |
| 163 |
151 // Called from Initialize after all status area trays have been created. | 164 // Called from Initialize after all status area trays have been created. |
152 // Sets the border based on the position of the view. | 165 // Sets the border based on the position of the view. |
153 void SetTrayBorder(); | 166 void SetTrayBorder(); |
154 | 167 |
| 168 static void DisableAnimationsForTest(); |
| 169 |
| 170 // gfx::AnimationDelegate: |
| 171 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 172 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 173 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; |
| 174 |
155 // Unowned pointer to parent widget. | 175 // Unowned pointer to parent widget. |
156 StatusAreaWidget* status_area_widget_; | 176 StatusAreaWidget* status_area_widget_; |
157 | 177 |
158 // Convenience pointer to the contents view. | 178 // Convenience pointer to the contents view. |
159 TrayContainer* tray_container_; | 179 TrayContainer* tray_container_; |
160 | 180 |
161 // Shelf alignment. | 181 // Shelf alignment. |
162 ShelfAlignment shelf_alignment_; | 182 ShelfAlignment shelf_alignment_; |
163 | 183 |
164 // Owned by the view passed to SetContents(). | 184 // Owned by the view passed to SetContents(). |
165 TrayBackground* background_; | 185 TrayBackground* background_; |
166 | 186 |
167 // Animators for the background. They are only used for the old shelf layout. | 187 // Animators for the background. They are only used for the old shelf layout. |
168 BackgroundAnimator hide_background_animator_; | 188 BackgroundAnimator hide_background_animator_; |
169 BackgroundAnimator hover_background_animator_; | 189 BackgroundAnimator hover_background_animator_; |
170 | 190 |
171 // True if the background gets hovered. | 191 // True if the background gets hovered. |
172 bool hovered_; | 192 bool hovered_; |
173 | 193 |
174 // This variable stores the activation override which will tint the background | 194 // This variable stores the activation override which will tint the background |
175 // differently if set to true. | 195 // differently if set to true. |
176 bool draw_background_as_active_; | 196 bool draw_background_as_active_; |
177 | 197 |
178 scoped_ptr<TrayWidgetObserver> widget_observer_; | 198 scoped_ptr<TrayWidgetObserver> widget_observer_; |
179 scoped_ptr<TrayEventFilter> tray_event_filter_; | 199 scoped_ptr<TrayEventFilter> tray_event_filter_; |
| 200 scoped_ptr<gfx::SlideAnimation> animation_; |
180 | 201 |
181 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); | 202 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); |
182 }; | 203 }; |
183 | 204 |
184 } // namespace ash | 205 } // namespace ash |
185 | 206 |
186 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 207 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
OLD | NEW |