| 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_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 DISALLOW_COPY_AND_ASSIGN(ImeInfoView); | 107 DISALLOW_COPY_AND_ASSIGN(ImeInfoView); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 // The IME list item view used in the material design. It contains IME info | 110 // The IME list item view used in the material design. It contains IME info |
| 111 // (name and label) and a check button if the item is selected. It's also used | 111 // (name and label) and a check button if the item is selected. It's also used |
| 112 // for IME property item, which has no name but label and a gray checked icon. | 112 // for IME property item, which has no name but label and a gray checked icon. |
| 113 class ImeListItemView : public ActionableView { | 113 class ImeListItemView : public ActionableView { |
| 114 public: | 114 public: |
| 115 ImeListItemView(ImeListView* list_view, | 115 ImeListItemView(SystemTrayItem* owner, |
| 116 ImeListView* list_view, |
| 116 const base::string16& id, | 117 const base::string16& id, |
| 117 const base::string16& label, | 118 const base::string16& label, |
| 118 bool selected, | 119 bool selected, |
| 119 const SkColor button_color) | 120 const SkColor button_color) |
| 120 : ime_list_view_(list_view) { | 121 : ActionableView(owner), ime_list_view_(list_view) { |
| 121 views::BoxLayout* box_layout = | 122 views::BoxLayout* box_layout = |
| 122 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 123 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 123 SetLayoutManager(box_layout); | 124 SetLayoutManager(box_layout); |
| 124 | 125 |
| 125 ImeInfoView* info_view = new ImeInfoView(id, label); | 126 ImeInfoView* info_view = new ImeInfoView(id, label); |
| 126 AddChildView(info_view); | 127 AddChildView(info_view); |
| 127 box_layout->SetFlexForView(info_view, 1); | 128 box_layout->SetFlexForView(info_view, 1); |
| 128 | 129 |
| 129 if (selected) { | 130 if (selected) { |
| 130 views::ImageButton* check_button = new views::ImageButton(nullptr); | 131 views::ImageButton* check_button = new views::ImageButton(nullptr); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 property_map_[container] = property_list[i].key; | 221 property_map_[container] = property_list[i].key; |
| 221 } | 222 } |
| 222 } | 223 } |
| 223 | 224 |
| 224 void ImeListView::AppendImeListAndProperties( | 225 void ImeListView::AppendImeListAndProperties( |
| 225 const IMEInfoList& list, | 226 const IMEInfoList& list, |
| 226 const IMEPropertyInfoList& property_list) { | 227 const IMEPropertyInfoList& property_list) { |
| 227 DCHECK(ime_map_.empty()); | 228 DCHECK(ime_map_.empty()); |
| 228 for (size_t i = 0; i < list.size(); i++) { | 229 for (size_t i = 0; i < list.size(); i++) { |
| 229 views::View* ime_view = | 230 views::View* ime_view = |
| 230 new ImeListItemView(this, list[i].short_name, list[i].name, | 231 new ImeListItemView(owner(), this, list[i].short_name, list[i].name, |
| 231 list[i].selected, gfx::kGoogleGreen700); | 232 list[i].selected, gfx::kGoogleGreen700); |
| 232 scroll_content()->AddChildView(ime_view); | 233 scroll_content()->AddChildView(ime_view); |
| 233 ime_map_[ime_view] = list[i].id; | 234 ime_map_[ime_view] = list[i].id; |
| 234 | 235 |
| 235 // In material design, the property items will be added after the current | 236 // In material design, the property items will be added after the current |
| 236 // selected IME item. | 237 // selected IME item. |
| 237 if (list[i].selected && !property_list.empty()) { | 238 if (list[i].selected && !property_list.empty()) { |
| 238 // Adds a separator on the top of property items. | 239 // Adds a separator on the top of property items. |
| 239 scroll_content()->AddChildView(CreateListItemSeparator()); | 240 scroll_content()->AddChildView(CreateListItemSeparator()); |
| 240 | 241 |
| 241 // Adds the property items. | 242 // Adds the property items. |
| 242 for (size_t i = 0; i < property_list.size(); i++) { | 243 for (size_t i = 0; i < property_list.size(); i++) { |
| 243 ImeListItemView* property_view = | 244 ImeListItemView* property_view = new ImeListItemView( |
| 244 new ImeListItemView(this, base::string16(), property_list[i].name, | 245 owner(), this, base::string16(), property_list[i].name, |
| 245 property_list[i].selected, kMenuIconColor); | 246 property_list[i].selected, kMenuIconColor); |
| 246 scroll_content()->AddChildView(property_view); | 247 scroll_content()->AddChildView(property_view); |
| 247 property_map_[property_view] = property_list[i].key; | 248 property_map_[property_view] = property_list[i].key; |
| 248 } | 249 } |
| 249 | 250 |
| 250 // Adds a separator on the bottom of property items. | 251 // Adds a separator on the bottom of property items. |
| 251 scroll_content()->AddChildView(CreateListItemSeparator()); | 252 scroll_content()->AddChildView(CreateListItemSeparator()); |
| 252 } | 253 } |
| 253 } | 254 } |
| 254 } | 255 } |
| 255 | 256 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 282 if (property == property_map_.end()) | 283 if (property == property_map_.end()) |
| 283 return; | 284 return; |
| 284 const std::string key = property->second; | 285 const std::string key = property->second; |
| 285 delegate->ActivateIMEProperty(key); | 286 delegate->ActivateIMEProperty(key); |
| 286 } | 287 } |
| 287 | 288 |
| 288 GetWidget()->Close(); | 289 GetWidget()->Close(); |
| 289 } | 290 } |
| 290 | 291 |
| 291 } // namespace ash | 292 } // namespace ash |
| OLD | NEW |