| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/ime_menu/ime_list_view.h" | 5 #include "ash/common/system/chromeos/ime_menu/ime_list_view.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/system/tray/hover_highlight_view.h" | 8 #include "ash/common/system/tray/hover_highlight_view.h" |
| 9 #include "ash/common/system/tray/ime_info.h" | 9 #include "ash/common/system/tray/ime_info.h" |
| 10 #include "ash/common/system/tray/system_menu_button.h" | 10 #include "ash/common/system/tray/system_menu_button.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 id_label->SetText(id); | 98 id_label->SetText(id); |
| 99 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 99 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 100 const gfx::FontList& base_font_list = | 100 const gfx::FontList& base_font_list = |
| 101 rb.GetFontList(ui::ResourceBundle::MediumBoldFont); | 101 rb.GetFontList(ui::ResourceBundle::MediumBoldFont); |
| 102 id_label->SetFontList(base_font_list); | 102 id_label->SetFontList(base_font_list); |
| 103 | 103 |
| 104 // For IMEs whose short name are more than 2 characters (INTL, EXTD, etc.), | 104 // For IMEs whose short name are more than 2 characters (INTL, EXTD, etc.), |
| 105 // |kMenuIconSize| is not enough. The label will trigger eliding as "I..." | 105 // |kMenuIconSize| is not enough. The label will trigger eliding as "I..." |
| 106 // or "...". So we shrink the font size until it fits within the bounds. | 106 // or "...". So we shrink the font size until it fits within the bounds. |
| 107 int size_delta = -1; | 107 int size_delta = -1; |
| 108 while (id_label->GetPreferredSize().width() > kMenuIconSize && | 108 while ((id_label->GetPreferredSize().width() - |
| 109 id_label->GetInsets().width()) > kMenuIconSize && |
| 109 size_delta >= kMinFontSizeDelta) { | 110 size_delta >= kMinFontSizeDelta) { |
| 110 id_label->SetFontList(base_font_list.DeriveWithSizeDelta(size_delta)); | 111 id_label->SetFontList(base_font_list.DeriveWithSizeDelta(size_delta)); |
| 111 --size_delta; | 112 --size_delta; |
| 112 } | 113 } |
| 113 tri_view->AddView(TriView::Container::START, id_label); | 114 tri_view->AddView(TriView::Container::START, id_label); |
| 114 | 115 |
| 115 // The label shows the IME name. | 116 // The label shows the IME name. |
| 116 auto label_view = TrayPopupUtils::CreateDefaultLabel(); | 117 auto label_view = TrayPopupUtils::CreateDefaultLabel(); |
| 117 label_view->SetText(label); | 118 label_view->SetText(label); |
| 118 TrayPopupItemStyle style( | 119 TrayPopupItemStyle style( |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 ImeListViewTestApi::ImeListViewTestApi(ImeListView* ime_list_view) | 460 ImeListViewTestApi::ImeListViewTestApi(ImeListView* ime_list_view) |
| 460 : ime_list_view_(ime_list_view) {} | 461 : ime_list_view_(ime_list_view) {} |
| 461 | 462 |
| 462 ImeListViewTestApi::~ImeListViewTestApi() {} | 463 ImeListViewTestApi::~ImeListViewTestApi() {} |
| 463 | 464 |
| 464 views::View* ImeListViewTestApi::GetToggleView() const { | 465 views::View* ImeListViewTestApi::GetToggleView() const { |
| 465 return ime_list_view_->material_keyboard_status_view_->toggle(); | 466 return ime_list_view_->material_keyboard_status_view_->toggle(); |
| 466 } | 467 } |
| 467 | 468 |
| 468 } // namespace ash | 469 } // namespace ash |
| OLD | NEW |