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