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( | 254 UpdateAfterShelfAlignmentChange( |
252 views::Border::CreateEmptyBorder(0, 2, 0, 2)); | 255 ash::Shell::GetInstance()->system_tray()->shelf_alignment()); |
sadrul
2012/07/19 16:46:28
Looks like this is necessary in all CreateTrayView
jennyz
2012/07/19 18:33:33
Done.
| |
253 return tray_label_; | 256 return tray_label_; |
254 } | 257 } |
255 | 258 |
256 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { | 259 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { |
257 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 260 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
258 IMEInfoList list; | 261 IMEInfoList list; |
259 IMEPropertyInfoList property_list; | 262 IMEPropertyInfoList property_list; |
260 delegate->GetAvailableIMEList(&list); | 263 delegate->GetAvailableIMEList(&list); |
261 delegate->GetCurrentIMEProperties(&property_list); | 264 delegate->GetCurrentIMEProperties(&property_list); |
262 if (list.size() <= 1 && property_list.size() <= 1) | 265 if (list.size() <= 1 && property_list.size() <= 1) |
(...skipping 28 matching lines...) Expand all Loading... | |
291 detailed_ = NULL; | 294 detailed_ = NULL; |
292 } | 295 } |
293 | 296 |
294 void TrayIME::DestroyNotificationView() { | 297 void TrayIME::DestroyNotificationView() { |
295 notification_ = NULL; | 298 notification_ = NULL; |
296 } | 299 } |
297 | 300 |
298 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 301 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
299 } | 302 } |
300 | 303 |
304 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | |
305 SetTrayLabelItemBorder(tray_label_, alignment); | |
sadrul
2012/07/19 16:46:28
This also seems to be necessary for all items. So
jennyz
2012/07/19 18:33:33
This may require some more refactoring, since Syst
| |
306 } | |
307 | |
301 void TrayIME::OnIMERefresh(bool show_message) { | 308 void TrayIME::OnIMERefresh(bool show_message) { |
302 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 309 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
303 IMEInfoList list; | 310 IMEInfoList list; |
304 IMEInfo current; | 311 IMEInfo current; |
305 IMEPropertyInfoList property_list; | 312 IMEPropertyInfoList property_list; |
306 delegate->GetCurrentIME(¤t); | 313 delegate->GetCurrentIME(¤t); |
307 delegate->GetAvailableIMEList(&list); | 314 delegate->GetAvailableIMEList(&list); |
308 delegate->GetCurrentIMEProperties(&property_list); | 315 delegate->GetCurrentIMEProperties(&property_list); |
309 | 316 |
310 UpdateTrayLabel(current, list.size()); | 317 UpdateTrayLabel(current, list.size()); |
311 | 318 |
312 if (default_) | 319 if (default_) |
313 default_->UpdateLabel(current); | 320 default_->UpdateLabel(current); |
314 if (detailed_) | 321 if (detailed_) |
315 detailed_->Update(list, property_list); | 322 detailed_->Update(list, property_list); |
316 | 323 |
317 if (list.size() > 1 && show_message && !message_shown_) { | 324 if (list.size() > 1 && show_message && !message_shown_) { |
318 if (!notification_) { | 325 if (!notification_) { |
319 ShowNotificationView(); | 326 ShowNotificationView(); |
320 message_shown_ = true; | 327 message_shown_ = true; |
321 } | 328 } |
322 } | 329 } |
323 } | 330 } |
324 | 331 |
325 } // namespace internal | 332 } // namespace internal |
326 } // namespace ash | 333 } // namespace ash |
OLD | NEW |