Chromium Code Reviews| 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_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| 6 #define ASH_COMMON_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_background_animator_observer.h" | 11 #include "ash/common/shelf/shelf_background_animator_observer.h" |
| 12 #include "ash/common/shelf/shelf_types.h" | 12 #include "ash/common/shelf/shelf_types.h" |
| 13 #include "ash/common/system/tray/actionable_view.h" | 13 #include "ash/common/system/tray/actionable_view.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 TrayEventFilter; | 20 class TrayEventFilter; |
| 21 class TrayBackground; | 21 class TrayBackground; |
| 22 class WmShelf; | 22 class WmShelf; |
| 23 | 23 |
| 24 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, | 24 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, |
| 25 // LogoutButtonTray, OverviewButtonTray. | 25 // LogoutButtonTray, OverviewButtonTray. |
| 26 // This class handles setting and animating the background when the Launcher | 26 // This class handles setting and animating the background when the Launcher |
| 27 // his shown/hidden. It also inherits from ActionableView so that the tray | 27 // is shown/hidden. It also inherits from ActionableView so that the tray |
| 28 // items can override PerformAction when clicked on. | 28 // items can override PerformAction when clicked on. |
| 29 class ASH_EXPORT TrayBackgroundView : public ActionableView, | 29 class ASH_EXPORT TrayBackgroundView : public ActionableView, |
| 30 public ui::ImplicitAnimationObserver, | 30 public ui::ImplicitAnimationObserver, |
| 31 public ShelfBackgroundAnimatorObserver { | 31 public ShelfBackgroundAnimatorObserver { |
| 32 public: | 32 public: |
| 33 static const char kViewClassName[]; | 33 static const char kViewClassName[]; |
| 34 | 34 |
| 35 // Base class for tray containers. Sets the border and layout. The container | 35 // Base class for tray containers. Sets the border and layout. The container |
| 36 // auto-resizes the widget when necessary. | 36 // auto-resizes the widget when necessary. |
| 37 class TrayContainer : public views::View { | 37 class TrayContainer : public views::View { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 58 private: | 58 private: |
| 59 void UpdateLayout(); | 59 void UpdateLayout(); |
| 60 | 60 |
| 61 ShelfAlignment alignment_; | 61 ShelfAlignment alignment_; |
| 62 gfx::Size size_; | 62 gfx::Size size_; |
| 63 gfx::Insets margin_; | 63 gfx::Insets margin_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(TrayContainer); | 65 DISALLOW_COPY_AND_ASSIGN(TrayContainer); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 explicit TrayBackgroundView(WmShelf* wm_shelf); | 68 TrayBackgroundView(WmShelf* wm_shelf); |
|
James Cook
2016/08/19 00:55:50
nit: keep explicit, since there is one parameter
yiyix
2016/08/19 19:07:56
Done.
| |
| 69 ~TrayBackgroundView() override; | 69 ~TrayBackgroundView() override; |
| 70 | 70 |
| 71 // Called after the tray has been added to the widget containing it. | 71 // Called after the tray has been added to the widget containing it. |
| 72 virtual void Initialize(); | 72 virtual void Initialize(); |
| 73 | 73 |
| 74 // Initializes animations for the bubble. | 74 // Initializes animations for the bubble. |
| 75 static void InitializeBubbleAnimations(views::Widget* bubble_widget); | 75 static void InitializeBubbleAnimations(views::Widget* bubble_widget); |
| 76 | 76 |
| 77 // views::View: | 77 // views::View: |
| 78 void SetVisible(bool visible) override; | 78 void SetVisible(bool visible) override; |
| 79 const char* GetClassName() const override; | 79 const char* GetClassName() const override; |
| 80 void ChildPreferredSizeChanged(views::View* child) override; | 80 void ChildPreferredSizeChanged(views::View* child) override; |
| 81 void GetAccessibleState(ui::AXViewState* state) override; | 81 void GetAccessibleState(ui::AXViewState* state) override; |
| 82 void AboutToRequestFocusFromTabTraversal(bool reverse) override; | 82 void AboutToRequestFocusFromTabTraversal(bool reverse) override; |
| 83 void OnPaint(gfx::Canvas* canvas) override; | |
| 83 | 84 |
| 84 // ActionableView: | 85 // ActionableView: |
| 85 bool PerformAction(const ui::Event& event) override; | 86 bool PerformAction(const ui::Event& event) override; |
| 86 gfx::Rect GetFocusBounds() override; | 87 gfx::Rect GetFocusBounds() override; |
| 87 void OnGestureEvent(ui::GestureEvent* event) override; | 88 void OnGestureEvent(ui::GestureEvent* event) override; |
| 88 | 89 |
| 89 // Called whenever the shelf alignment changes. | 90 // Called whenever the shelf alignment changes. |
| 90 virtual void SetShelfAlignment(ShelfAlignment alignment); | 91 virtual void SetShelfAlignment(ShelfAlignment alignment); |
| 91 | 92 |
| 92 // 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. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } | 132 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } |
| 132 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } | 133 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } |
| 133 WmShelf* shelf() { return wm_shelf_; } | 134 WmShelf* shelf() { return wm_shelf_; } |
| 134 | 135 |
| 135 // Updates the arrow visibility based on the launcher visibility. | 136 // Updates the arrow visibility based on the launcher visibility. |
| 136 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); | 137 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); |
| 137 | 138 |
| 138 // ShelfBackgroundAnimatorObserver: | 139 // ShelfBackgroundAnimatorObserver: |
| 139 void UpdateShelfItemBackground(int alpha) override; | 140 void UpdateShelfItemBackground(int alpha) override; |
| 140 | 141 |
| 142 // Updates the visibility of this tray's separator. | |
| 143 void SetSeparatorVisibility(bool is_show); | |
| 144 | |
| 141 private: | 145 private: |
| 142 class TrayWidgetObserver; | 146 class TrayWidgetObserver; |
| 143 | 147 |
| 144 // Called from Initialize after all status area trays have been created. | |
| 145 // Sets the border based on the position of the view. | |
| 146 void SetTrayBorder(); | |
| 147 | |
| 148 // ui::ImplicitAnimationObserver: | 148 // ui::ImplicitAnimationObserver: |
| 149 void OnImplicitAnimationsCompleted() override; | 149 void OnImplicitAnimationsCompleted() override; |
| 150 bool RequiresNotificationWhenAnimatorDestroyed() const override; | 150 bool RequiresNotificationWhenAnimatorDestroyed() const override; |
| 151 | 151 |
| 152 // Applies transformations to the |layer()| to animate the view when | 152 // Applies transformations to the |layer()| to animate the view when |
| 153 // SetVisible(false) is called. | 153 // SetVisible(false) is called. |
| 154 void HideTransformation(); | 154 void HideTransformation(); |
| 155 | 155 |
| 156 // The shelf containing the system tray for this view. | 156 // The shelf containing the system tray for this view. |
| 157 WmShelf* wm_shelf_; | 157 WmShelf* wm_shelf_; |
| 158 | 158 |
| 159 // Convenience pointer to the contents view. | 159 // Convenience pointer to the contents view. |
| 160 TrayContainer* tray_container_; | 160 TrayContainer* tray_container_; |
| 161 | 161 |
| 162 // Shelf alignment. | 162 // Shelf alignment. |
| 163 // TODO(jamescook): Don't cache this, get it from WmShelf. | 163 // TODO(jamescook): Don't cache this, get it from WmShelf. |
| 164 ShelfAlignment shelf_alignment_; | 164 ShelfAlignment shelf_alignment_; |
| 165 | 165 |
| 166 // Owned by the view passed to SetContents(). | 166 // Owned by the view passed to SetContents(). |
| 167 TrayBackground* background_; | 167 TrayBackground* background_; |
| 168 | 168 |
| 169 // This variable stores the activation override which will tint the background | 169 // This variable stores the activation override which will tint the background |
| 170 // differently if set to true. | 170 // differently if set to true. |
| 171 bool draw_background_as_active_; | 171 bool draw_background_as_active_; |
| 172 | 172 |
| 173 // This variable stores the visibility of this tray's separator. | |
|
varkha
2016/08/19 16:33:39
nit: Maybe just "Visibility of this tray's separat
yiyix
2016/08/19 19:07:56
Done.
| |
| 174 bool is_separator_visible_; | |
|
yoshiki
2016/08/19 03:45:31
nit: please add a blank line after this to keep co
yiyix
2016/08/19 19:07:56
Done.
| |
| 173 std::unique_ptr<TrayWidgetObserver> widget_observer_; | 175 std::unique_ptr<TrayWidgetObserver> widget_observer_; |
| 174 std::unique_ptr<TrayEventFilter> tray_event_filter_; | 176 std::unique_ptr<TrayEventFilter> tray_event_filter_; |
| 175 | 177 |
| 176 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); | 178 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); |
| 177 }; | 179 }; |
| 178 | 180 |
| 179 } // namespace ash | 181 } // namespace ash |
| 180 | 182 |
| 181 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 183 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| OLD | NEW |