| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ime_list_view_(list_view), | 87 ime_list_view_(list_view), |
| 88 selected_(selected) { | 88 selected_(selected) { |
| 89 if (MaterialDesignController::IsSystemTrayMenuMaterial()) | 89 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 90 SetInkDropMode(InkDropHostView::InkDropMode::ON); | 90 SetInkDropMode(InkDropHostView::InkDropMode::ON); |
| 91 | 91 |
| 92 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); | 92 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); |
| 93 AddChildView(tri_view); | 93 AddChildView(tri_view); |
| 94 SetLayoutManager(new views::FillLayout); | 94 SetLayoutManager(new views::FillLayout); |
| 95 | 95 |
| 96 // The id button shows the IME short name. | 96 // The id button shows the IME short name. |
| 97 views::Label* id_label = new views::Label(id); | 97 views::Label* id_label = TrayPopupUtils::CreateDefaultLabel(); |
| 98 id_label->SetText(id); |
| 98 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 99 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 99 const gfx::FontList& base_font_list = | 100 const gfx::FontList& base_font_list = |
| 100 rb.GetFontList(ui::ResourceBundle::MediumBoldFont); | 101 rb.GetFontList(ui::ResourceBundle::MediumBoldFont); |
| 101 id_label->SetFontList(base_font_list); | 102 id_label->SetFontList(base_font_list); |
| 102 | 103 |
| 103 // TODO(bruthig): Fix this so that |label| uses the kBackgroundColor to | |
| 104 // perform subpixel rendering instead of disabling subpixel rendering. | |
| 105 // | |
| 106 // Text rendered on a non-opaque background looks ugly and it is possible | |
| 107 // for labels to given a a clear canvas at paint time when an ink drop is | |
| 108 // visible. See http://crbug.com/661714. | |
| 109 id_label->SetSubpixelRenderingEnabled(false); | |
| 110 | |
| 111 // 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.), |
| 112 // |kMenuIconSize| is not enough. The label will trigger eliding as "I..." | 105 // |kMenuIconSize| is not enough. The label will trigger eliding as "I..." |
| 113 // 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. |
| 114 int size_delta = -1; | 107 int size_delta = -1; |
| 115 while (id_label->GetPreferredSize().width() > kMenuIconSize && | 108 while (id_label->GetPreferredSize().width() > kMenuIconSize && |
| 116 size_delta >= kMinFontSizeDelta) { | 109 size_delta >= kMinFontSizeDelta) { |
| 117 id_label->SetFontList(base_font_list.DeriveWithSizeDelta(size_delta)); | 110 id_label->SetFontList(base_font_list.DeriveWithSizeDelta(size_delta)); |
| 118 --size_delta; | 111 --size_delta; |
| 119 } | 112 } |
| 120 tri_view->AddView(TriView::Container::START, id_label); | 113 tri_view->AddView(TriView::Container::START, id_label); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 472 |
| 480 for (auto property_map : property_map_) { | 473 for (auto property_map : property_map_) { |
| 481 if (property_map.second == last_selected_item_id_) { | 474 if (property_map.second == last_selected_item_id_) { |
| 482 (property_map.first)->RequestFocus(); | 475 (property_map.first)->RequestFocus(); |
| 483 return; | 476 return; |
| 484 } | 477 } |
| 485 } | 478 } |
| 486 } | 479 } |
| 487 | 480 |
| 488 } // namespace ash | 481 } // namespace ash |
| OLD | NEW |