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/launcher/background_animator.h" | 9 #include "ash/launcher/background_animator.h" |
10 #include "ash/system/tray/tray_views.h" | 10 #include "ash/system/tray/tray_views.h" |
11 #include "ash/wm/shelf_types.h" | 11 #include "ash/wm/shelf_types.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 class StatusAreaWidget; | 16 class StatusAreaWidget; |
17 class TrayBackground; | 17 class TrayBackground; |
| 18 class TrayLayerAnimationObserver; |
18 | 19 |
19 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray. | 20 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray. |
20 // This class handles setting and animating the background when the Launcher | 21 // This class handles setting and animating the background when the Launcher |
21 // his shown/hidden. It also inherits from ActionableView so that the tray | 22 // his shown/hidden. It also inherits from ActionableView so that the tray |
22 // items can override PerformAction when clicked on. | 23 // items can override PerformAction when clicked on. |
23 | 24 |
24 class ASH_EXPORT TrayBackgroundView : public internal::ActionableView, | 25 class ASH_EXPORT TrayBackgroundView : public internal::ActionableView, |
25 public BackgroundAnimatorDelegate { | 26 public BackgroundAnimatorDelegate { |
26 public: | 27 public: |
27 // Base class for tray containers. Sets the border and layout. The container | 28 // Base class for tray containers. Sets the border and layout. The container |
(...skipping 23 matching lines...) Expand all Loading... |
51 | 52 |
52 ShelfAlignment alignment_; | 53 ShelfAlignment alignment_; |
53 gfx::Size size_; | 54 gfx::Size size_; |
54 | 55 |
55 DISALLOW_COPY_AND_ASSIGN(TrayContainer); | 56 DISALLOW_COPY_AND_ASSIGN(TrayContainer); |
56 }; | 57 }; |
57 | 58 |
58 explicit TrayBackgroundView(internal::StatusAreaWidget* status_area_widget); | 59 explicit TrayBackgroundView(internal::StatusAreaWidget* status_area_widget); |
59 virtual ~TrayBackgroundView(); | 60 virtual ~TrayBackgroundView(); |
60 | 61 |
| 62 // Called after the tray has been added to the widget containing it. |
| 63 virtual void Initialize(); |
| 64 |
61 // Overridden from views::View. | 65 // Overridden from views::View. |
62 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 66 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
63 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 67 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
64 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | 68 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
| 69 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
| 70 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
65 | 71 |
66 // Overridden from internal::ActionableView. | 72 // Overridden from internal::ActionableView. |
67 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 73 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
68 | 74 |
69 // Overridden from internal::BackgroundAnimatorDelegate. | 75 // Overridden from internal::BackgroundAnimatorDelegate. |
70 virtual void UpdateBackground(int alpha) OVERRIDE; | 76 virtual void UpdateBackground(int alpha) OVERRIDE; |
71 | 77 |
72 // Called whenever the shelf alignment changes. | 78 // Called whenever the shelf alignment changes. |
73 virtual void SetShelfAlignment(ShelfAlignment alignment); | 79 virtual void SetShelfAlignment(ShelfAlignment alignment); |
74 | 80 |
| 81 // Called when the anchor (tray or bubble) may have moved or changed. |
| 82 virtual void AnchorUpdated() {} |
| 83 |
75 // Sets |contents| as a child and sets its background to |background_|. | 84 // Sets |contents| as a child and sets its background to |background_|. |
76 void SetContents(views::View* contents); | 85 void SetContents(views::View* contents); |
77 | 86 |
78 // Sets whether the tray paints a background. Default is true, but is set to | 87 // Sets whether the tray paints a background. Default is true, but is set to |
79 // false if a window overlaps the shelf. | 88 // false if a window overlaps the shelf. |
80 void SetPaintsBackground( | 89 void SetPaintsBackground( |
81 bool value, | 90 bool value, |
82 internal::BackgroundAnimator::ChangeType change_type); | 91 internal::BackgroundAnimator::ChangeType change_type); |
83 | 92 |
84 // Called after all status area trays have been created. Sets the border | |
85 // based on the position of the view. | |
86 void SetBorder(); | |
87 | |
88 StatusAreaWidget* status_area_widget() { | 93 StatusAreaWidget* status_area_widget() { |
89 return status_area_widget_; | 94 return status_area_widget_; |
90 } | 95 } |
91 TrayContainer* tray_container() const { return tray_container_; } | 96 TrayContainer* tray_container() const { return tray_container_; } |
92 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } | 97 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } |
93 | 98 |
94 private: | 99 private: |
| 100 friend class TrayLayerAnimationObserver; |
| 101 |
| 102 // Called from Initialize after all status area trays have been created. |
| 103 // Sets the border based on the position of the view. |
| 104 void SetBorder(); |
| 105 |
95 // Unowned pointer to parent widget. | 106 // Unowned pointer to parent widget. |
96 StatusAreaWidget* status_area_widget_; | 107 StatusAreaWidget* status_area_widget_; |
97 | 108 |
98 // Convenience pointer to the contents view. | 109 // Convenience pointer to the contents view. |
99 TrayContainer* tray_container_; | 110 TrayContainer* tray_container_; |
100 | 111 |
101 // Shelf alignment. | 112 // Shelf alignment. |
102 ShelfAlignment shelf_alignment_; | 113 ShelfAlignment shelf_alignment_; |
103 | 114 |
104 // Owned by the view passed to SetContents(). | 115 // Owned by the view passed to SetContents(). |
105 internal::TrayBackground* background_; | 116 internal::TrayBackground* background_; |
106 | 117 |
107 internal::BackgroundAnimator hide_background_animator_; | 118 internal::BackgroundAnimator hide_background_animator_; |
108 internal::BackgroundAnimator hover_background_animator_; | 119 internal::BackgroundAnimator hover_background_animator_; |
| 120 scoped_ptr<internal::TrayLayerAnimationObserver> |
| 121 layer_animation_observer_; |
109 | 122 |
110 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); | 123 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); |
111 }; | 124 }; |
112 | 125 |
113 } // namespace internal | 126 } // namespace internal |
114 } // namespace ash | 127 } // namespace ash |
115 | 128 |
116 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 129 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
OLD | NEW |