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 #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/material_design/material_design_controller.h" |
8 #include "ash/common/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
9 #include "ash/common/system/overview/overview_button_tray.h" | 9 #include "ash/common/system/overview/overview_button_tray.h" |
10 #include "ash/common/system/status_area_widget_delegate.h" | 10 #include "ash/common/system/status_area_widget_delegate.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 if (web_notification_tray_) | 139 if (web_notification_tray_) |
140 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); | 140 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); |
141 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
142 if (logout_button_tray_) | 142 if (logout_button_tray_) |
143 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); | 143 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); |
144 #endif | 144 #endif |
145 if (overview_button_tray_) | 145 if (overview_button_tray_) |
146 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); | 146 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); |
147 } | 147 } |
148 | 148 |
149 void StatusAreaWidget::OnTrayVisibilityChanged(TrayBackgroundView* tray) { | |
150 if (!ash::MaterialDesignController::IsShelfMaterial()) | |
151 return; | |
152 | |
153 // No separator is required between |system_tray_| and |overview_button_tray_| | |
154 // and no separator is required for the right most tray item. | |
155 if (tray == overview_button_tray_ || tray == system_tray_) { | |
156 tray->SetSeparatorVisibility(false); | |
157 return; | |
158 } | |
159 #if defined(OS_CHROMEOS) | |
160 // If |logout_button_tray_| is visible, check if |tray| is visible and to | |
161 // the left of |logout_button_tray_|. If it is the case, then no separator | |
162 // is required between |tray| and |logout_button_tray_|. If | |
163 // |logout_button_tray_| is not visible, then separator should always be | |
164 // visible. | |
165 tray->SetSeparatorVisibility(!IsNextVisibleTrayToLogout(tray) && | |
166 tray != logout_button_tray_); | |
167 #else | |
168 tray->SetSeparatorVisibility(true); | |
169 #endif | |
170 } | |
171 | |
172 bool StatusAreaWidget::ShouldShowShelf() const { | 149 bool StatusAreaWidget::ShouldShowShelf() const { |
173 if ((system_tray_ && system_tray_->ShouldShowShelf()) || | 150 if ((system_tray_ && system_tray_->ShouldShowShelf()) || |
174 (web_notification_tray_ && | 151 (web_notification_tray_ && |
175 web_notification_tray_->ShouldBlockShelfAutoHide())) | 152 web_notification_tray_->ShouldBlockShelfAutoHide())) |
176 return true; | 153 return true; |
177 | 154 |
178 #if defined(OS_CHROMEOS) | 155 #if defined(OS_CHROMEOS) |
179 if (palette_tray_ && palette_tray_->ShouldBlockShelfAutoHide()) | 156 if (palette_tray_ && palette_tray_->ShouldBlockShelfAutoHide()) |
180 return true; | 157 return true; |
181 | 158 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 251 |
275 void StatusAreaWidget::AddVirtualKeyboardTray() { | 252 void StatusAreaWidget::AddVirtualKeyboardTray() { |
276 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_); | 253 virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_); |
277 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); | 254 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); |
278 } | 255 } |
279 | 256 |
280 void StatusAreaWidget::AddImeMenuTray() { | 257 void StatusAreaWidget::AddImeMenuTray() { |
281 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); | 258 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); |
282 status_area_widget_delegate_->AddTray(ime_menu_tray_); | 259 status_area_widget_delegate_->AddTray(ime_menu_tray_); |
283 } | 260 } |
284 | |
285 bool StatusAreaWidget::IsNextVisibleTrayToLogout( | |
286 TrayBackgroundView* tray) const { | |
287 int logout_button_index = | |
288 status_area_widget_delegate_->GetIndexOf(logout_button_tray_); | |
289 // Logout button should always exist. | |
290 DCHECK_NE(-1, logout_button_index); | |
291 if (!logout_button_tray_->visible()) | |
292 return false; | |
293 | |
294 for (int c = logout_button_index + 1; | |
295 c < status_area_widget_delegate_->child_count(); c++) { | |
296 if (status_area_widget_delegate_->child_at(c)->visible()) | |
297 return tray == status_area_widget_delegate_->child_at(c); | |
298 } | |
299 return false; | |
300 } | |
301 #endif | 261 #endif |
302 | 262 |
303 void StatusAreaWidget::AddOverviewButtonTray() { | 263 void StatusAreaWidget::AddOverviewButtonTray() { |
304 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); | 264 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); |
305 status_area_widget_delegate_->AddTray(overview_button_tray_); | 265 status_area_widget_delegate_->AddTray(overview_button_tray_); |
306 } | 266 } |
307 | 267 |
308 } // namespace ash | 268 } // namespace ash |
OLD | NEW |