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/system/ime/tray_ime.h" | 5 #include "ash/system/ime/tray_ime.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 233 } |
234 | 234 |
235 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) { | 235 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) { |
236 if (tray_label_) { | 236 if (tray_label_) { |
237 if (current.third_party) { | 237 if (current.third_party) { |
238 tray_label_->label()->SetText(current.short_name + UTF8ToUTF16("*")); | 238 tray_label_->label()->SetText(current.short_name + UTF8ToUTF16("*")); |
239 } else { | 239 } else { |
240 tray_label_->label()->SetText(current.short_name); | 240 tray_label_->label()->SetText(current.short_name); |
241 } | 241 } |
242 tray_label_->SetVisible(count > 1); | 242 tray_label_->SetVisible(count > 1); |
| 243 SetTrayLabelItemBorder(tray_label_, |
| 244 ash::Shell::GetInstance()->system_tray()->shelf_alignment()); |
| 245 tray_label_->Layout(); |
243 } | 246 } |
244 } | 247 } |
245 | 248 |
246 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { | 249 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { |
247 CHECK(tray_label_ == NULL); | 250 CHECK(tray_label_ == NULL); |
248 tray_label_ = new TrayItemView; | 251 tray_label_ = new TrayItemView; |
249 tray_label_->CreateLabel(); | 252 tray_label_->CreateLabel(); |
250 SetupLabelForTray(tray_label_->label()); | 253 SetupLabelForTray(tray_label_->label()); |
251 tray_label_->label()->set_border( | |
252 views::Border::CreateEmptyBorder(0, 2, 0, 2)); | |
253 return tray_label_; | 254 return tray_label_; |
254 } | 255 } |
255 | 256 |
256 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { | 257 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { |
257 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 258 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
258 IMEInfoList list; | 259 IMEInfoList list; |
259 IMEPropertyInfoList property_list; | 260 IMEPropertyInfoList property_list; |
260 delegate->GetAvailableIMEList(&list); | 261 delegate->GetAvailableIMEList(&list); |
261 delegate->GetCurrentIMEProperties(&property_list); | 262 delegate->GetCurrentIMEProperties(&property_list); |
262 if (list.size() <= 1 && property_list.size() <= 1) | 263 if (list.size() <= 1 && property_list.size() <= 1) |
(...skipping 28 matching lines...) Expand all Loading... |
291 detailed_ = NULL; | 292 detailed_ = NULL; |
292 } | 293 } |
293 | 294 |
294 void TrayIME::DestroyNotificationView() { | 295 void TrayIME::DestroyNotificationView() { |
295 notification_ = NULL; | 296 notification_ = NULL; |
296 } | 297 } |
297 | 298 |
298 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 299 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
299 } | 300 } |
300 | 301 |
| 302 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 303 SetTrayLabelItemBorder(tray_label_, alignment); |
| 304 } |
| 305 |
301 void TrayIME::OnIMERefresh(bool show_message) { | 306 void TrayIME::OnIMERefresh(bool show_message) { |
302 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 307 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
303 IMEInfoList list; | 308 IMEInfoList list; |
304 IMEInfo current; | 309 IMEInfo current; |
305 IMEPropertyInfoList property_list; | 310 IMEPropertyInfoList property_list; |
306 delegate->GetCurrentIME(¤t); | 311 delegate->GetCurrentIME(¤t); |
307 delegate->GetAvailableIMEList(&list); | 312 delegate->GetAvailableIMEList(&list); |
308 delegate->GetCurrentIMEProperties(&property_list); | 313 delegate->GetCurrentIMEProperties(&property_list); |
309 | 314 |
310 UpdateTrayLabel(current, list.size()); | 315 UpdateTrayLabel(current, list.size()); |
311 | 316 |
312 if (default_) | 317 if (default_) |
313 default_->UpdateLabel(current); | 318 default_->UpdateLabel(current); |
314 if (detailed_) | 319 if (detailed_) |
315 detailed_->Update(list, property_list); | 320 detailed_->Update(list, property_list); |
316 | 321 |
317 if (list.size() > 1 && show_message && !message_shown_) { | 322 if (list.size() > 1 && show_message && !message_shown_) { |
318 if (!notification_) { | 323 if (!notification_) { |
319 ShowNotificationView(); | 324 ShowNotificationView(); |
320 message_shown_ = true; | 325 message_shown_ = true; |
321 } | 326 } |
322 } | 327 } |
323 } | 328 } |
324 | 329 |
325 } // namespace internal | 330 } // namespace internal |
326 } // namespace ash | 331 } // namespace ash |
OLD | NEW |