| 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/compositor/layer_animation_observer.h" | |
| 13 #include "ui/views/bubble/tray_bubble_view.h" | 12 #include "ui/views/bubble/tray_bubble_view.h" |
| 14 | 13 |
| 15 namespace ash { | 14 namespace ash { |
| 16 class ShelfLayoutManager; | 15 class ShelfLayoutManager; |
| 17 class StatusAreaWidget; | 16 class StatusAreaWidget; |
| 18 class TrayEventFilter; | 17 class TrayEventFilter; |
| 19 class TrayBackground; | 18 class TrayBackground; |
| 20 | 19 |
| 21 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, | 20 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, |
| 22 // LogoutButtonTray, OverviewButtonTray. | 21 // LogoutButtonTray. |
| 23 // This class handles setting and animating the background when the Launcher | 22 // This class handles setting and animating the background when the Launcher |
| 24 // his shown/hidden. It also inherits from ActionableView so that the tray | 23 // his shown/hidden. It also inherits from ActionableView so that the tray |
| 25 // items can override PerformAction when clicked on. | 24 // items can override PerformAction when clicked on. |
| 26 class ASH_EXPORT TrayBackgroundView : public ActionableView, | 25 class ASH_EXPORT TrayBackgroundView : public ActionableView, |
| 27 public BackgroundAnimatorDelegate, | 26 public BackgroundAnimatorDelegate { |
| 28 public ui::ImplicitAnimationObserver { | |
| 29 public: | 27 public: |
| 30 static const char kViewClassName[]; | 28 static const char kViewClassName[]; |
| 31 | 29 |
| 32 // Base class for tray containers. Sets the border and layout. The container | 30 // Base class for tray containers. Sets the border and layout. The container |
| 33 // auto-resizes the widget when necessary. | 31 // auto-resizes the widget when necessary. |
| 34 class TrayContainer : public views::View { | 32 class TrayContainer : public views::View { |
| 35 public: | 33 public: |
| 36 explicit TrayContainer(ShelfAlignment alignment); | 34 explicit TrayContainer(ShelfAlignment alignment); |
| 37 virtual ~TrayContainer() {} | 35 virtual ~TrayContainer() {} |
| 38 | 36 |
| 39 void SetAlignment(ShelfAlignment alignment); | 37 void SetAlignment(ShelfAlignment alignment); |
| 40 | 38 |
| 41 void set_size(const gfx::Size& size) { size_ = size; } | 39 void set_size(const gfx::Size& size) { size_ = size; } |
| 42 | 40 |
| 43 // views::View: | 41 // Overridden from views::View. |
| 44 virtual gfx::Size GetPreferredSize() OVERRIDE; | 42 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 45 | 43 |
| 46 protected: | 44 protected: |
| 47 // views::View: | 45 // Overridden from views::View. |
| 48 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | 46 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
| 49 virtual void ChildVisibilityChanged(View* child) OVERRIDE; | 47 virtual void ChildVisibilityChanged(View* child) OVERRIDE; |
| 50 virtual void ViewHierarchyChanged( | 48 virtual void ViewHierarchyChanged( |
| 51 const ViewHierarchyChangedDetails& details) OVERRIDE; | 49 const ViewHierarchyChangedDetails& details) OVERRIDE; |
| 52 | 50 |
| 53 private: | 51 private: |
| 54 void UpdateLayout(); | 52 void UpdateLayout(); |
| 55 | 53 |
| 56 ShelfAlignment alignment_; | 54 ShelfAlignment alignment_; |
| 57 gfx::Size size_; | 55 gfx::Size size_; |
| 58 | 56 |
| 59 DISALLOW_COPY_AND_ASSIGN(TrayContainer); | 57 DISALLOW_COPY_AND_ASSIGN(TrayContainer); |
| 60 }; | 58 }; |
| 61 | 59 |
| 62 explicit TrayBackgroundView(StatusAreaWidget* status_area_widget); | 60 explicit TrayBackgroundView(StatusAreaWidget* status_area_widget); |
| 63 virtual ~TrayBackgroundView(); | 61 virtual ~TrayBackgroundView(); |
| 64 | 62 |
| 65 // Called after the tray has been added to the widget containing it. | 63 // Called after the tray has been added to the widget containing it. |
| 66 virtual void Initialize(); | 64 virtual void Initialize(); |
| 67 | 65 |
| 68 // views::View: | 66 // Overridden from views::View. |
| 69 virtual void SetVisible(bool visible) OVERRIDE; | |
| 70 virtual const char* GetClassName() const OVERRIDE; | 67 virtual const char* GetClassName() const OVERRIDE; |
| 71 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 68 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| 72 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 69 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
| 73 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | 70 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
| 74 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 71 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
| 75 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 72 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
| 76 | 73 |
| 77 // ActionableView: | 74 // Overridden from ActionableView. |
| 78 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 75 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
| 79 virtual gfx::Rect GetFocusBounds() OVERRIDE; | 76 virtual gfx::Rect GetFocusBounds() OVERRIDE; |
| 80 | 77 |
| 81 // BackgroundAnimatorDelegate: | 78 // Overridden from BackgroundAnimatorDelegate. |
| 82 virtual void UpdateBackground(int alpha) OVERRIDE; | 79 virtual void UpdateBackground(int alpha) OVERRIDE; |
| 83 | 80 |
| 84 // Called whenever the shelf alignment changes. | 81 // Called whenever the shelf alignment changes. |
| 85 virtual void SetShelfAlignment(ShelfAlignment alignment); | 82 virtual void SetShelfAlignment(ShelfAlignment alignment); |
| 86 | 83 |
| 87 // Called when the anchor (tray or bubble) may have moved or changed. | 84 // Called when the anchor (tray or bubble) may have moved or changed. |
| 88 virtual void AnchorUpdated() {} | 85 virtual void AnchorUpdated() {} |
| 89 | 86 |
| 90 // Called from GetAccessibleState, must return a valid accessible name. | 87 // Called from GetAccessibleState, must return a valid accessible name. |
| 91 virtual base::string16 GetAccessibleNameForTray() = 0; | 88 virtual base::string16 GetAccessibleNameForTray() = 0; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Updates the arrow visibility based on the launcher visibility. | 145 // Updates the arrow visibility based on the launcher visibility. |
| 149 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); | 146 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); |
| 150 | 147 |
| 151 private: | 148 private: |
| 152 class TrayWidgetObserver; | 149 class TrayWidgetObserver; |
| 153 | 150 |
| 154 // Called from Initialize after all status area trays have been created. | 151 // Called from Initialize after all status area trays have been created. |
| 155 // Sets the border based on the position of the view. | 152 // Sets the border based on the position of the view. |
| 156 void SetTrayBorder(); | 153 void SetTrayBorder(); |
| 157 | 154 |
| 158 // ui::ImplicitAnimationObserver: | |
| 159 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | |
| 160 | |
| 161 // Applies transformations to the |layer()| to animate the view when | |
| 162 // SetVisible(false) is called. | |
| 163 void HideTransformation(); | |
| 164 | |
| 165 // Unowned pointer to parent widget. | 155 // Unowned pointer to parent widget. |
| 166 StatusAreaWidget* status_area_widget_; | 156 StatusAreaWidget* status_area_widget_; |
| 167 | 157 |
| 168 // Convenience pointer to the contents view. | 158 // Convenience pointer to the contents view. |
| 169 TrayContainer* tray_container_; | 159 TrayContainer* tray_container_; |
| 170 | 160 |
| 171 // Shelf alignment. | 161 // Shelf alignment. |
| 172 ShelfAlignment shelf_alignment_; | 162 ShelfAlignment shelf_alignment_; |
| 173 | 163 |
| 174 // Owned by the view passed to SetContents(). | 164 // Owned by the view passed to SetContents(). |
| (...skipping 12 matching lines...) Expand all Loading... |
| 187 | 177 |
| 188 scoped_ptr<TrayWidgetObserver> widget_observer_; | 178 scoped_ptr<TrayWidgetObserver> widget_observer_; |
| 189 scoped_ptr<TrayEventFilter> tray_event_filter_; | 179 scoped_ptr<TrayEventFilter> tray_event_filter_; |
| 190 | 180 |
| 191 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); | 181 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); |
| 192 }; | 182 }; |
| 193 | 183 |
| 194 } // namespace ash | 184 } // namespace ash |
| 195 | 185 |
| 196 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 186 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| OLD | NEW |