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

Side by Side Diff: ash/common/system/tray/system_tray.cc

Issue 2461693003: MD cros - Fix padding in system tray (Closed)
Patch Set: self review Created 4 years, 1 month 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
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 #include "ash/common/system/tray/system_tray.h" 5 #include "ash/common/system/tray/system_tray.h"
6 6
7 #include "ash/common/key_event_watcher.h" 7 #include "ash/common/key_event_watcher.h"
8 #include "ash/common/login_status.h" 8 #include "ash/common/login_status.h"
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "ash/common/system/chromeos/tray_caps_lock.h" 67 #include "ash/common/system/chromeos/tray_caps_lock.h"
68 #include "ash/common/system/chromeos/tray_tracing.h" 68 #include "ash/common/system/chromeos/tray_tracing.h"
69 #include "ash/common/system/ime/tray_ime_chromeos.h" 69 #include "ash/common/system/ime/tray_ime_chromeos.h"
70 #include "ui/message_center/message_center.h" 70 #include "ui/message_center/message_center.h"
71 #endif 71 #endif
72 72
73 using views::TrayBubbleView; 73 using views::TrayBubbleView;
74 74
75 namespace ash { 75 namespace ash {
76 76
77 namespace {
78
79 // A tray item that just reserves space in the tray.
80 class PaddingTrayItem : public SystemTrayItem {
81 public:
82 PaddingTrayItem() : SystemTrayItem(nullptr, UMA_NOT_RECORDED) {}
83 ~PaddingTrayItem() override {}
84
85 // Overridden from SystemTrayItem.
tdanderson 2016/10/31 21:29:09 nit: just "SystemTrayItem:"
Evan Stade 2016/10/31 22:11:56 I will make this change, but don't want to switch
tdanderson 2016/11/01 00:00:35 Acknowledged.
86 views::View* CreateTrayView(LoginStatus status) override {
87 return new PaddingView();
88 }
89
90 private:
91 class PaddingView : public views::View {
92 public:
93 PaddingView() {}
94 ~PaddingView() override {}
95
96 private:
97 gfx::Size GetPreferredSize() const override {
98 return gfx::Size(GetTrayConstant(TRAY_IMAGE_ITEM_PADDING),
99 GetTrayConstant(TRAY_IMAGE_ITEM_PADDING));
100 }
101
102 DISALLOW_COPY_AND_ASSIGN(PaddingView);
103 };
104
105 DISALLOW_COPY_AND_ASSIGN(PaddingTrayItem);
106 };
107
108 } // namespace
109
77 // The minimum width of the system tray menu. 110 // The minimum width of the system tray menu.
78 const int kMinimumSystemTrayMenuWidth = 300; 111 const int kMinimumSystemTrayMenuWidth = 300;
79 const int kMinimumSystemTrayMenuWidthMd = 332; 112 const int kMinimumSystemTrayMenuWidthMd = 332;
80 113
81 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper 114 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper
82 // instances for a bubble. 115 // instances for a bubble.
83 116
84 class SystemBubbleWrapper { 117 class SystemBubbleWrapper {
85 public: 118 public:
86 // Takes ownership of |bubble|. 119 // Takes ownership of |bubble|.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 hide_notifications_(false), 208 hide_notifications_(false),
176 full_system_tray_menu_(false), 209 full_system_tray_menu_(false),
177 tray_accessibility_(nullptr), 210 tray_accessibility_(nullptr),
178 tray_audio_(nullptr), 211 tray_audio_(nullptr),
179 tray_cast_(nullptr), 212 tray_cast_(nullptr),
180 tray_date_(nullptr), 213 tray_date_(nullptr),
181 tray_update_(nullptr), 214 tray_update_(nullptr),
182 screen_capture_tray_item_(nullptr), 215 screen_capture_tray_item_(nullptr),
183 screen_share_tray_item_(nullptr) { 216 screen_share_tray_item_(nullptr) {
184 SetContentsBackground(); 217 SetContentsBackground();
185 if (MaterialDesignController::IsSystemTrayMenuMaterial())
186 tray_container()->SetMargin(GetTrayConstant(TRAY_IMAGE_ITEM_PADDING), 0);
187 } 218 }
188 219
189 SystemTray::~SystemTray() { 220 SystemTray::~SystemTray() {
190 // Destroy any child views that might have back pointers before ~View(). 221 // Destroy any child views that might have back pointers before ~View().
191 activation_observer_.reset(); 222 activation_observer_.reset();
192 key_event_watcher_.reset(); 223 key_event_watcher_.reset();
193 system_bubble_.reset(); 224 system_bubble_.reset();
194 notification_bubble_.reset(); 225 notification_bubble_.reset();
195 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 226 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
196 it != items_.end(); ++it) { 227 it != items_.end(); ++it) {
(...skipping 17 matching lines...) Expand all
214 245
215 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { 246 void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
216 #if !defined(OS_WIN) 247 #if !defined(OS_WIN)
217 // Create user items for each possible user. 248 // Create user items for each possible user.
218 int maximum_user_profiles = WmShell::Get() 249 int maximum_user_profiles = WmShell::Get()
219 ->GetSessionStateDelegate() 250 ->GetSessionStateDelegate()
220 ->GetMaximumNumberOfLoggedInUsers(); 251 ->GetMaximumNumberOfLoggedInUsers();
221 for (int i = 0; i < maximum_user_profiles; i++) 252 for (int i = 0; i < maximum_user_profiles; i++)
222 AddTrayItem(new TrayUser(this, i)); 253 AddTrayItem(new TrayUser(this, i));
223 254
255 // Crucially, this trailing padding has to be inside the user item(s).
256 // Otherwise it could be a main axis margin on the tray's box layout.
257 if (MaterialDesignController::IsSystemTrayMenuMaterial())
258 AddTrayItem(new PaddingTrayItem());
259
224 if (maximum_user_profiles > 1) { 260 if (maximum_user_profiles > 1) {
225 // Add a special double line separator between users and the rest of the 261 // Add a special double line separator between users and the rest of the
226 // menu if more than one user is logged in. 262 // menu if more than one user is logged in.
227 AddTrayItem(new TrayUserSeparator(this)); 263 AddTrayItem(new TrayUserSeparator(this));
228 } 264 }
229 #endif 265 #endif
230 266
231 tray_accessibility_ = new TrayAccessibility(this); 267 tray_accessibility_ = new TrayAccessibility(this);
232 tray_date_ = new TrayDate(this); 268 tray_date_ = new TrayDate(this);
233 tray_update_ = new TrayUpdate(this); 269 tray_update_ = new TrayUpdate(this);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 AddTrayItem(tray_update_); 301 AddTrayItem(tray_update_);
266 if (MaterialDesignController::IsSystemTrayMenuMaterial()) 302 if (MaterialDesignController::IsSystemTrayMenuMaterial())
267 AddTrayItem(new TrayTiles(this)); 303 AddTrayItem(new TrayTiles(this));
268 // TODO(tdanderson): Do not add |tray_date_| in material design. 304 // TODO(tdanderson): Do not add |tray_date_| in material design.
269 AddTrayItem(tray_date_); 305 AddTrayItem(tray_date_);
270 #elif defined(OS_WIN) 306 #elif defined(OS_WIN)
271 AddTrayItem(tray_accessibility_); 307 AddTrayItem(tray_accessibility_);
272 AddTrayItem(tray_update_); 308 AddTrayItem(tray_update_);
273 AddTrayItem(tray_date_); 309 AddTrayItem(tray_date_);
274 #endif 310 #endif
311 // Leading padding.
312 if (MaterialDesignController::IsSystemTrayMenuMaterial())
313 AddTrayItem(new PaddingTrayItem());
275 } 314 }
276 315
277 void SystemTray::AddTrayItem(SystemTrayItem* item) { 316 void SystemTray::AddTrayItem(SystemTrayItem* item) {
278 items_.push_back(item); 317 items_.push_back(item);
279 318
280 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 319 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
281 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); 320 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus());
282 item->UpdateAfterShelfAlignmentChange(shelf_alignment()); 321 item->UpdateAfterShelfAlignmentChange(shelf_alignment());
283 322
284 if (tray_item) { 323 if (tray_item) {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 .work_area() 930 .work_area()
892 .height(); 931 .height();
893 if (work_area_height > 0) { 932 if (work_area_height > 0) {
894 UMA_HISTOGRAM_CUSTOM_COUNTS( 933 UMA_HISTOGRAM_CUSTOM_COUNTS(
895 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 934 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
896 100 * bubble_view->height() / work_area_height, 1, 300, 100); 935 100 * bubble_view->height() / work_area_height, 1, 300, 100);
897 } 936 }
898 } 937 }
899 938
900 } // namespace ash 939 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/system/tray/tray_background_view.h » ('j') | ash/common/system/user/tray_user.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698