Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: ash/system/tray/tray_background_view.h

Issue 2036353002: mash: Move ash/common/wm/shelf to ash/common/shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/tray/system_tray_unittest.cc ('k') | ash/system/tray/tray_background_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <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/wm/background_animator.h" 12 #include "ash/common/wm/background_animator.h"
12 #include "ash/shelf/shelf_types.h"
13 #include "ash/system/tray/actionable_view.h" 13 #include "ash/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 StatusAreaWidget; 20 class StatusAreaWidget;
21 class TrayEventFilter; 21 class TrayEventFilter;
22 class TrayBackground; 22 class TrayBackground;
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 // his 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 BackgroundAnimatorDelegate, 30 public BackgroundAnimatorDelegate,
31 public ui::ImplicitAnimationObserver { 31 public ui::ImplicitAnimationObserver {
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 {
38 public: 38 public:
39 explicit TrayContainer(wm::ShelfAlignment alignment); 39 explicit TrayContainer(ShelfAlignment alignment);
40 ~TrayContainer() override {} 40 ~TrayContainer() override {}
41 41
42 void SetAlignment(wm::ShelfAlignment alignment); 42 void SetAlignment(ShelfAlignment alignment);
43 43
44 void set_size(const gfx::Size& size) { size_ = size; } 44 void set_size(const gfx::Size& size) { size_ = size; }
45 45
46 // views::View: 46 // views::View:
47 gfx::Size GetPreferredSize() const override; 47 gfx::Size GetPreferredSize() const override;
48 48
49 protected: 49 protected:
50 // views::View: 50 // views::View:
51 void ChildPreferredSizeChanged(views::View* child) override; 51 void ChildPreferredSizeChanged(views::View* child) override;
52 void ChildVisibilityChanged(View* child) override; 52 void ChildVisibilityChanged(View* child) override;
53 void ViewHierarchyChanged( 53 void ViewHierarchyChanged(
54 const ViewHierarchyChangedDetails& details) override; 54 const ViewHierarchyChangedDetails& details) override;
55 55
56 private: 56 private:
57 void UpdateLayout(); 57 void UpdateLayout();
58 58
59 wm::ShelfAlignment alignment_; 59 ShelfAlignment alignment_;
60 gfx::Size size_; 60 gfx::Size size_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(TrayContainer); 62 DISALLOW_COPY_AND_ASSIGN(TrayContainer);
63 }; 63 };
64 64
65 explicit TrayBackgroundView(StatusAreaWidget* status_area_widget); 65 explicit TrayBackgroundView(StatusAreaWidget* status_area_widget);
66 ~TrayBackgroundView() override; 66 ~TrayBackgroundView() override;
67 67
68 // 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.
69 virtual void Initialize(); 69 virtual void Initialize();
(...skipping 12 matching lines...) Expand all
82 82
83 // ActionableView: 83 // ActionableView:
84 bool PerformAction(const ui::Event& event) override; 84 bool PerformAction(const ui::Event& event) override;
85 gfx::Rect GetFocusBounds() override; 85 gfx::Rect GetFocusBounds() override;
86 void OnGestureEvent(ui::GestureEvent* event) override; 86 void OnGestureEvent(ui::GestureEvent* event) override;
87 87
88 // BackgroundAnimatorDelegate: 88 // BackgroundAnimatorDelegate:
89 void UpdateBackground(int alpha) override; 89 void UpdateBackground(int alpha) override;
90 90
91 // Called whenever the shelf alignment changes. 91 // Called whenever the shelf alignment changes.
92 virtual void SetShelfAlignment(wm::ShelfAlignment alignment); 92 virtual void SetShelfAlignment(ShelfAlignment alignment);
93 93
94 // Called when the anchor (tray or bubble) may have moved or changed. 94 // Called when the anchor (tray or bubble) may have moved or changed.
95 virtual void AnchorUpdated() {} 95 virtual void AnchorUpdated() {}
96 96
97 // Called from GetAccessibleState, must return a valid accessible name. 97 // Called from GetAccessibleState, must return a valid accessible name.
98 virtual base::string16 GetAccessibleNameForTray() = 0; 98 virtual base::string16 GetAccessibleNameForTray() = 0;
99 99
100 // Called when the bubble is resized. 100 // Called when the bubble is resized.
101 virtual void BubbleResized(const views::TrayBubbleView* bubble_view) {} 101 virtual void BubbleResized(const views::TrayBubbleView* bubble_view) {}
102 102
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Returns true when the the background was overridden to be drawn as active. 137 // Returns true when the the background was overridden to be drawn as active.
138 bool draw_background_as_active() const {return draw_background_as_active_; } 138 bool draw_background_as_active() const {return draw_background_as_active_; }
139 139
140 StatusAreaWidget* status_area_widget() { 140 StatusAreaWidget* status_area_widget() {
141 return status_area_widget_; 141 return status_area_widget_;
142 } 142 }
143 const StatusAreaWidget* status_area_widget() const { 143 const StatusAreaWidget* status_area_widget() const {
144 return status_area_widget_; 144 return status_area_widget_;
145 } 145 }
146 TrayContainer* tray_container() const { return tray_container_; } 146 TrayContainer* tray_container() const { return tray_container_; }
147 wm::ShelfAlignment shelf_alignment() const { return shelf_alignment_; } 147 ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
148 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } 148 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); }
149 149
150 ShelfLayoutManager* GetShelfLayoutManager(); 150 ShelfLayoutManager* GetShelfLayoutManager();
151 151
152 // Updates the arrow visibility based on the launcher visibility. 152 // Updates the arrow visibility based on the launcher visibility.
153 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); 153 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view);
154 154
155 private: 155 private:
156 class TrayWidgetObserver; 156 class TrayWidgetObserver;
157 157
158 // Called from Initialize after all status area trays have been created. 158 // Called from Initialize after all status area trays have been created.
159 // Sets the border based on the position of the view. 159 // Sets the border based on the position of the view.
160 void SetTrayBorder(); 160 void SetTrayBorder();
161 161
162 // ui::ImplicitAnimationObserver: 162 // ui::ImplicitAnimationObserver:
163 void OnImplicitAnimationsCompleted() override; 163 void OnImplicitAnimationsCompleted() override;
164 bool RequiresNotificationWhenAnimatorDestroyed() const override; 164 bool RequiresNotificationWhenAnimatorDestroyed() const override;
165 165
166 // Applies transformations to the |layer()| to animate the view when 166 // Applies transformations to the |layer()| to animate the view when
167 // SetVisible(false) is called. 167 // SetVisible(false) is called.
168 void HideTransformation(); 168 void HideTransformation();
169 169
170 // Unowned pointer to parent widget. 170 // Unowned pointer to parent widget.
171 StatusAreaWidget* status_area_widget_; 171 StatusAreaWidget* status_area_widget_;
172 172
173 // Convenience pointer to the contents view. 173 // Convenience pointer to the contents view.
174 TrayContainer* tray_container_; 174 TrayContainer* tray_container_;
175 175
176 // Shelf alignment. 176 // Shelf alignment.
177 wm::ShelfAlignment shelf_alignment_; 177 ShelfAlignment shelf_alignment_;
178 178
179 // Owned by the view passed to SetContents(). 179 // Owned by the view passed to SetContents().
180 TrayBackground* background_; 180 TrayBackground* background_;
181 181
182 // Animators for the background. They are only used for the old shelf layout. 182 // Animators for the background. They are only used for the old shelf layout.
183 BackgroundAnimator hide_background_animator_; 183 BackgroundAnimator hide_background_animator_;
184 BackgroundAnimator hover_background_animator_; 184 BackgroundAnimator hover_background_animator_;
185 185
186 // True if the background gets hovered. 186 // True if the background gets hovered.
187 bool hovered_; 187 bool hovered_;
188 188
189 // This variable stores the activation override which will tint the background 189 // This variable stores the activation override which will tint the background
190 // differently if set to true. 190 // differently if set to true.
191 bool draw_background_as_active_; 191 bool draw_background_as_active_;
192 192
193 std::unique_ptr<TrayWidgetObserver> widget_observer_; 193 std::unique_ptr<TrayWidgetObserver> widget_observer_;
194 std::unique_ptr<TrayEventFilter> tray_event_filter_; 194 std::unique_ptr<TrayEventFilter> tray_event_filter_;
195 195
196 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); 196 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView);
197 }; 197 };
198 198
199 } // namespace ash 199 } // namespace ash
200 200
201 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 201 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray_unittest.cc ('k') | ash/system/tray/tray_background_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698