| 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_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| 6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/common/shelf/shelf_types.h" | 11 #include "ash/common/shelf/shelf_types.h" |
| 12 #include "ash/common/system/tray/actionable_view.h" | 12 #include "ash/common/system/tray/actionable_view.h" |
| 13 #include "ash/common/wm/background_animator.h" | 13 #include "ash/common/wm/background_animator.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
| 16 #include "ui/views/bubble/tray_bubble_view.h" | 16 #include "ui/views/bubble/tray_bubble_view.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 class ShelfLayoutManager; | 19 class ShelfLayoutManager; |
| 20 class StatusAreaWidget; | |
| 21 class TrayEventFilter; | 20 class TrayEventFilter; |
| 22 class TrayBackground; | 21 class TrayBackground; |
| 23 class WmShelf; | 22 class WmShelf; |
| 24 | 23 |
| 25 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, | 24 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, |
| 26 // LogoutButtonTray, OverviewButtonTray. | 25 // LogoutButtonTray, OverviewButtonTray. |
| 27 // This class handles setting and animating the background when the Launcher | 26 // This class handles setting and animating the background when the Launcher |
| 28 // his shown/hidden. It also inherits from ActionableView so that the tray | 27 // his shown/hidden. It also inherits from ActionableView so that the tray |
| 29 // items can override PerformAction when clicked on. | 28 // items can override PerformAction when clicked on. |
| 30 class ASH_EXPORT TrayBackgroundView : public ActionableView, | 29 class ASH_EXPORT TrayBackgroundView : public ActionableView, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 56 | 55 |
| 57 private: | 56 private: |
| 58 void UpdateLayout(); | 57 void UpdateLayout(); |
| 59 | 58 |
| 60 ShelfAlignment alignment_; | 59 ShelfAlignment alignment_; |
| 61 gfx::Size size_; | 60 gfx::Size size_; |
| 62 | 61 |
| 63 DISALLOW_COPY_AND_ASSIGN(TrayContainer); | 62 DISALLOW_COPY_AND_ASSIGN(TrayContainer); |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 explicit TrayBackgroundView(StatusAreaWidget* status_area_widget); | 65 explicit TrayBackgroundView(WmShelf* wm_shelf); |
| 67 ~TrayBackgroundView() override; | 66 ~TrayBackgroundView() override; |
| 68 | 67 |
| 69 // Called after the tray has been added to the widget containing it. | 68 // Called after the tray has been added to the widget containing it. |
| 70 virtual void Initialize(); | 69 virtual void Initialize(); |
| 71 | 70 |
| 72 // Initializes animations for the bubble. | 71 // Initializes animations for the bubble. |
| 73 static void InitializeBubbleAnimations(views::Widget* bubble_widget); | 72 static void InitializeBubbleAnimations(views::Widget* bubble_widget); |
| 74 | 73 |
| 75 // views::View: | 74 // views::View: |
| 76 void SetVisible(bool visible) override; | 75 void SetVisible(bool visible) override; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 120 |
| 122 // Returns the bubble anchor alignment based on |shelf_alignment_|. | 121 // Returns the bubble anchor alignment based on |shelf_alignment_|. |
| 123 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const; | 122 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const; |
| 124 | 123 |
| 125 // Forces the background to be drawn active if set to true. | 124 // Forces the background to be drawn active if set to true. |
| 126 void SetDrawBackgroundAsActive(bool visible); | 125 void SetDrawBackgroundAsActive(bool visible); |
| 127 | 126 |
| 128 // Returns true when the the background was overridden to be drawn as active. | 127 // Returns true when the the background was overridden to be drawn as active. |
| 129 bool draw_background_as_active() const {return draw_background_as_active_; } | 128 bool draw_background_as_active() const {return draw_background_as_active_; } |
| 130 | 129 |
| 131 StatusAreaWidget* status_area_widget() { | |
| 132 return status_area_widget_; | |
| 133 } | |
| 134 const StatusAreaWidget* status_area_widget() const { | |
| 135 return status_area_widget_; | |
| 136 } | |
| 137 TrayContainer* tray_container() const { return tray_container_; } | 130 TrayContainer* tray_container() const { return tray_container_; } |
| 138 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } | 131 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } |
| 139 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } | 132 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } |
| 140 | 133 WmShelf* shelf() { return wm_shelf_; } |
| 141 WmShelf* GetShelf(); | |
| 142 | 134 |
| 143 // Updates the arrow visibility based on the launcher visibility. | 135 // Updates the arrow visibility based on the launcher visibility. |
| 144 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); | 136 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); |
| 145 | 137 |
| 146 private: | 138 private: |
| 147 class TrayWidgetObserver; | 139 class TrayWidgetObserver; |
| 148 | 140 |
| 149 // Called from Initialize after all status area trays have been created. | 141 // Called from Initialize after all status area trays have been created. |
| 150 // Sets the border based on the position of the view. | 142 // Sets the border based on the position of the view. |
| 151 void SetTrayBorder(); | 143 void SetTrayBorder(); |
| 152 | 144 |
| 153 // ui::ImplicitAnimationObserver: | 145 // ui::ImplicitAnimationObserver: |
| 154 void OnImplicitAnimationsCompleted() override; | 146 void OnImplicitAnimationsCompleted() override; |
| 155 bool RequiresNotificationWhenAnimatorDestroyed() const override; | 147 bool RequiresNotificationWhenAnimatorDestroyed() const override; |
| 156 | 148 |
| 157 // Applies transformations to the |layer()| to animate the view when | 149 // Applies transformations to the |layer()| to animate the view when |
| 158 // SetVisible(false) is called. | 150 // SetVisible(false) is called. |
| 159 void HideTransformation(); | 151 void HideTransformation(); |
| 160 | 152 |
| 161 // Unowned pointer to parent widget. | 153 // The shelf containing the system tray for this view. |
| 162 StatusAreaWidget* status_area_widget_; | 154 WmShelf* wm_shelf_; |
| 163 | 155 |
| 164 // Convenience pointer to the contents view. | 156 // Convenience pointer to the contents view. |
| 165 TrayContainer* tray_container_; | 157 TrayContainer* tray_container_; |
| 166 | 158 |
| 167 // Shelf alignment. | 159 // Shelf alignment. |
| 168 // TODO(jamescook): Don't cache this, get it from WmShelf. | 160 // TODO(jamescook): Don't cache this, get it from WmShelf. |
| 169 ShelfAlignment shelf_alignment_; | 161 ShelfAlignment shelf_alignment_; |
| 170 | 162 |
| 171 // Owned by the view passed to SetContents(). | 163 // Owned by the view passed to SetContents(). |
| 172 TrayBackground* background_; | 164 TrayBackground* background_; |
| 173 | 165 |
| 174 // This variable stores the activation override which will tint the background | 166 // This variable stores the activation override which will tint the background |
| 175 // differently if set to true. | 167 // differently if set to true. |
| 176 bool draw_background_as_active_; | 168 bool draw_background_as_active_; |
| 177 | 169 |
| 178 std::unique_ptr<TrayWidgetObserver> widget_observer_; | 170 std::unique_ptr<TrayWidgetObserver> widget_observer_; |
| 179 std::unique_ptr<TrayEventFilter> tray_event_filter_; | 171 std::unique_ptr<TrayEventFilter> tray_event_filter_; |
| 180 | 172 |
| 181 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); | 173 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); |
| 182 }; | 174 }; |
| 183 | 175 |
| 184 } // namespace ash | 176 } // namespace ash |
| 185 | 177 |
| 186 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 178 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| OLD | NEW |