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

Side by Side Diff: ash/common/system/status_area_widget.cc

Issue 2147143002: [Chrome OS MD] Draw a 1px separator between 2 tray items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 4 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
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/status_area_widget.h" 5 #include "ash/common/system/status_area_widget.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h"
7 #include "ash/common/shelf/wm_shelf.h" 8 #include "ash/common/shelf/wm_shelf.h"
8 #include "ash/common/shell_window_ids.h" 9 #include "ash/common/shell_window_ids.h"
9 #include "ash/common/system/overview/overview_button_tray.h" 10 #include "ash/common/system/overview/overview_button_tray.h"
10 #include "ash/common/system/status_area_widget_delegate.h" 11 #include "ash/common/system/status_area_widget_delegate.h"
11 #include "ash/common/system/tray/system_tray.h" 12 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 13 #include "ash/common/system/tray/system_tray_delegate.h"
13 #include "ash/common/system/web_notification/web_notification_tray.h" 14 #include "ash/common/system/web_notification/web_notification_tray.h"
14 #include "ash/common/wm_lookup.h" 15 #include "ash/common/wm_lookup.h"
15 #include "ash/common/wm_root_window_controller.h" 16 #include "ash/common/wm_root_window_controller.h"
16 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 182
182 void StatusAreaWidget::AddVirtualKeyboardTray() { 183 void StatusAreaWidget::AddVirtualKeyboardTray() {
183 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_); 184 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_);
184 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); 185 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_);
185 } 186 }
186 187
187 void StatusAreaWidget::AddImeMenuTray() { 188 void StatusAreaWidget::AddImeMenuTray() {
188 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); 189 ime_menu_tray_ = new ImeMenuTray(wm_shelf_);
189 status_area_widget_delegate_->AddTray(ime_menu_tray_); 190 status_area_widget_delegate_->AddTray(ime_menu_tray_);
190 } 191 }
192
193 bool StatusAreaWidget::IsNextVisibleTrayToLogout(TrayBackgroundView* tray) {
194 if (!logout_button_tray_->visible())
195 return false;
196 bool is_logout_found = false;
197 for (int c = 0; c < status_area_widget_delegate_->child_count(); c++) {
198 if (!is_logout_found) {
199 if (status_area_widget_delegate_->child_at(c) == logout_button_tray_) {
200 is_logout_found = true;
201 }
202 } else {
203 if (status_area_widget_delegate_->child_at(c)->visible())
204 return tray == status_area_widget_delegate_->child_at(c);
205 }
206 }
James Cook 2016/08/11 20:36:55 nit: I think this would be clearer if you did some
yiyix 2016/08/18 00:43:00 Yes, it makes the code easier to understand.
207 return false;
208 }
191 #endif 209 #endif
192 210
193 void StatusAreaWidget::AddOverviewButtonTray() { 211 void StatusAreaWidget::AddOverviewButtonTray() {
194 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); 212 overview_button_tray_ = new OverviewButtonTray(wm_shelf_);
195 status_area_widget_delegate_->AddTray(overview_button_tray_); 213 status_area_widget_delegate_->AddTray(overview_button_tray_);
196 } 214 }
197 215
198 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 216 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
199 status_area_widget_delegate_->set_alignment(alignment); 217 status_area_widget_delegate_->set_alignment(alignment);
200 if (system_tray_) 218 if (system_tray_)
(...skipping 24 matching lines...) Expand all
225 if (web_notification_tray_) 243 if (web_notification_tray_)
226 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 244 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
227 #if defined(OS_CHROMEOS) 245 #if defined(OS_CHROMEOS)
228 if (logout_button_tray_) 246 if (logout_button_tray_)
229 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); 247 logout_button_tray_->UpdateAfterLoginStatusChange(login_status);
230 #endif 248 #endif
231 if (overview_button_tray_) 249 if (overview_button_tray_)
232 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); 250 overview_button_tray_->UpdateAfterLoginStatusChange(login_status);
233 } 251 }
234 252
253 void StatusAreaWidget::OnTrayVisibilityChanged(TrayBackgroundView* tray) {
James Cook 2016/08/11 20:36:55 nit: move up to match function order in header
yiyix 2016/08/18 00:43:00 I moved up SetShelfAlignment, UpdateAfterLoginStat
254 if (!ash::MaterialDesignController::IsShelfMaterial()) {
255 return;
256 }
257
258 // No separator is required between |system_tray_| and |overview_button_tray_|
259 // and no separator is required for the right most tray item.
260 if (tray == overview_button_tray_ || tray == system_tray_) {
261 tray->SetSeparatorVisibility(false);
262 } else {
James Cook 2016/08/11 20:36:55 nit: early return above this line might make it ea
yiyix 2016/08/18 00:43:00 Done.
263 // If |logout_button_tray_| is visible, then no leading separator is required
varkha 2016/08/11 20:01:03 nit: indents.
yiyix 2016/08/18 00:43:00 Done.
264 // because it is red and distinct on its own. If |logout_button_tray_| is not
265 // visible, then separator should always be visible.
266 #if defined(OS_CHROMEOS)
James Cook 2016/08/11 20:36:54 nit: move this above the comment
yiyix 2016/08/18 00:43:00 Done.
267 tray->SetSeparatorVisibility(!IsNextVisibleTrayToLogout(tray) &&
268 tray != logout_button_tray_);
269 return;
270 #endif
271 tray->SetSeparatorVisibility(true);
James Cook 2016/08/11 20:36:55 maybe put this in an #else block?
yiyix 2016/08/18 00:43:00 Done.
272 }
273 }
274
235 } // namespace ash 275 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698