Chromium Code Reviews| 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_tray_delegate.h" | 11 #include "ash/common/system/tray/system_tray_delegate.h" |
| 11 #include "ash/common/system/tray/tray_constants.h" | 12 #include "ash/common/system/tray/tray_constants.h" |
| 12 #include "ash/common/system/tray/tray_details_view.h" | 13 #include "ash/common/system/tray/tray_details_view.h" |
| 13 #include "ash/common/system/tray/tray_popup_header_button.h" | 14 #include "ash/common/system/tray/tray_popup_header_button.h" |
| 14 #include "ash/common/system/tray/tray_popup_item_style.h" | 15 #include "ash/common/system/tray/tray_popup_item_style.h" |
| 16 #include "ash/common/system/tray/tray_popup_utils.h" | |
| 17 #include "ash/common/system/tray/tri_view.h" | |
| 15 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 16 #include "grit/ash_resources.h" | 19 #include "grit/ash_resources.h" |
| 17 #include "grit/ash_strings.h" | 20 #include "grit/ash_strings.h" |
| 18 #include "ui/accessibility/ax_view_state.h" | 21 #include "ui/accessibility/ax_view_state.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/color_palette.h" | 24 #include "ui/gfx/color_palette.h" |
| 22 #include "ui/gfx/paint_vector_icon.h" | 25 #include "ui/gfx/paint_vector_icon.h" |
| 23 #include "ui/gfx/vector_icons_public.h" | 26 #include "ui/gfx/vector_icons_public.h" |
| 24 #include "ui/keyboard/keyboard_util.h" | 27 #include "ui/keyboard/keyboard_util.h" |
| 25 #include "ui/views/border.h" | 28 #include "ui/views/border.h" |
| 29 #include "ui/views/controls/button/image_button.h" | |
| 26 #include "ui/views/controls/button/label_button.h" | 30 #include "ui/views/controls/button/label_button.h" |
| 31 #include "ui/views/controls/button/toggle_button.h" | |
| 27 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/controls/separator.h" | 33 #include "ui/views/controls/separator.h" |
| 29 #include "ui/views/layout/box_layout.h" | 34 #include "ui/views/layout/fill_layout.h" |
| 35 #include "ui/views/painter.h" | |
| 36 #include "ui/views/view.h" | |
| 30 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 31 | 38 |
| 32 namespace ash { | 39 namespace ash { |
| 33 namespace { | 40 namespace { |
| 34 | 41 |
| 42 const int kKeyboardRowkVerticalInset = 4; | |
| 43 const int kKeyboardRowSeparatorThickness = 1; | |
| 44 const int kFocusBorderInset = 1; | |
| 45 | |
| 46 const SkColor kKeyboardRowSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F); | |
| 47 | |
| 35 // Creates a separator that will be used between the IME list items. | 48 // Creates a separator that will be used between the IME list items. |
| 36 views::Separator* CreateListItemSeparator() { | 49 views::Separator* CreateListItemSeparator() { |
| 37 views::Separator* separator = | 50 views::Separator* separator = |
| 38 new views::Separator(views::Separator::HORIZONTAL); | 51 new views::Separator(views::Separator::HORIZONTAL); |
| 39 separator->SetColor(kBorderLightColor); | 52 separator->SetColor(kBorderLightColor); |
| 40 separator->SetPreferredSize(kSeparatorWidth); | 53 separator->SetPreferredSize(kSeparatorWidth); |
| 41 separator->SetBorder(views::Border::CreateEmptyBorder( | 54 separator->SetBorder(views::Border::CreateEmptyBorder( |
| 42 kMenuSeparatorVerticalPadding, 0, kMenuSeparatorVerticalPadding, 0)); | 55 kMenuSeparatorVerticalPadding, 0, kMenuSeparatorVerticalPadding, 0)); |
| 43 return separator; | 56 return separator; |
| 44 } | 57 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 65 if (selected_) | 78 if (selected_) |
| 66 state->AddStateFlag(ui::AX_STATE_CHECKED); | 79 state->AddStateFlag(ui::AX_STATE_CHECKED); |
| 67 } | 80 } |
| 68 | 81 |
| 69 private: | 82 private: |
| 70 bool selected_; | 83 bool selected_; |
| 71 | 84 |
| 72 DISALLOW_COPY_AND_ASSIGN(SelectableHoverHighlightView); | 85 DISALLOW_COPY_AND_ASSIGN(SelectableHoverHighlightView); |
| 73 }; | 86 }; |
| 74 | 87 |
| 75 // The view that contains IME short name and the IME label. | 88 // The IME list item view used in the material design. It contains IME info |
| 76 class ImeInfoView : public views::View { | 89 // (name and label) and a check button if the item is selected. It's also used |
| 90 // for IME property item, which has no name but label and a gray checked icon. | |
| 91 class ImeListItemView : public ActionableView { | |
| 77 public: | 92 public: |
| 78 ImeInfoView(const base::string16& id, const base::string16& text) { | 93 ImeListItemView(SystemTrayItem* owner, |
| 79 views::BoxLayout* box_layout = | 94 ImeListView* list_view, |
| 80 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 95 const base::string16& id, |
| 81 SetLayoutManager(box_layout); | 96 const base::string16& label, |
| 97 bool selected, | |
| 98 const SkColor button_color) | |
| 99 : ActionableView(owner), ime_list_view_(list_view) { | |
| 100 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); | |
|
tdanderson
2016/11/02 18:44:36
Thanks for making use of TriView here, too.
| |
| 101 AddChildView(tri_view); | |
| 102 SetLayoutManager(new views::FillLayout); | |
| 82 | 103 |
| 83 // TODO(azurewei): Use TrayPopupItemStyle for |id_button|. | 104 // The id button shows the IME short name. |
| 84 views::LabelButton* id_button = new views::LabelButton(nullptr, id); | 105 views::LabelButton* id_button = new views::LabelButton(nullptr, id); |
|
tdanderson
2016/11/02 18:44:36
optional as follow on work in another CL: consider
Azure Wei
2016/11/03 02:06:44
Done. Updated |id_button | as a Label and |check_b
| |
| 85 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 106 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 86 id_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumBoldFont)); | 107 id_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumBoldFont)); |
| 87 id_button->SetTextColor(views::Button::STATE_NORMAL, kMenuIconColor); | 108 id_button->SetTextColor(views::Button::STATE_NORMAL, kMenuIconColor); |
| 88 id_button->SetMaxSize(gfx::Size(kMenuButtonSize, kMenuButtonSize)); | 109 id_button->SetMaxSize(gfx::Size(kMenuButtonSize, kMenuButtonSize)); |
| 89 id_button->SetMinSize(gfx::Size(kMenuButtonSize, kMenuButtonSize)); | 110 id_button->SetMinSize(gfx::Size(kMenuButtonSize, kMenuButtonSize)); |
| 90 const int button_padding = (kMenuButtonSize - kMenuIconSize) / 2; | 111 const int button_padding = (kMenuButtonSize - kMenuIconSize) / 2; |
| 91 id_button->SetBorder(views::Border::CreateEmptyBorder( | 112 id_button->SetBorder(views::Border::CreateEmptyBorder( |
| 92 button_padding, button_padding, button_padding, button_padding)); | 113 button_padding, button_padding, button_padding, button_padding)); |
| 93 AddChildView(id_button); | 114 tri_view->AddView(TriView::Container::START, id_button); |
| 94 | 115 |
| 95 views::Label* text_label = new views::Label(text); | 116 // The label shows the IME name. |
| 117 views::Label* text_label = new views::Label(label); | |
| 96 TrayPopupItemStyle style( | 118 TrayPopupItemStyle style( |
| 97 GetNativeTheme(), TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); | 119 GetNativeTheme(), TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); |
| 98 style.SetupLabel(text_label); | 120 style.SetupLabel(text_label); |
| 99 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 121 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 100 box_layout->set_cross_axis_alignment( | 122 tri_view->AddView(TriView::Container::CENTER, text_label); |
| 101 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | |
| 102 AddChildView(text_label); | |
| 103 box_layout->SetFlexForView(text_label, 1); | |
| 104 } | |
| 105 | |
| 106 private: | |
| 107 DISALLOW_COPY_AND_ASSIGN(ImeInfoView); | |
| 108 }; | |
| 109 | |
| 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 | |
| 112 // for IME property item, which has no name but label and a gray checked icon. | |
| 113 class ImeListItemView : public ActionableView { | |
| 114 public: | |
| 115 ImeListItemView(SystemTrayItem* owner, | |
| 116 ImeListView* list_view, | |
| 117 const base::string16& id, | |
| 118 const base::string16& label, | |
| 119 bool selected, | |
| 120 const SkColor button_color) | |
| 121 : ActionableView(owner), ime_list_view_(list_view) { | |
| 122 views::BoxLayout* box_layout = | |
| 123 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | |
| 124 SetLayoutManager(box_layout); | |
| 125 | |
| 126 ImeInfoView* info_view = new ImeInfoView(id, label); | |
| 127 AddChildView(info_view); | |
| 128 box_layout->SetFlexForView(info_view, 1); | |
| 129 | 123 |
| 130 if (selected) { | 124 if (selected) { |
| 125 // The checked button indicates the IME is selected. | |
| 131 views::ImageButton* check_button = new views::ImageButton(nullptr); | 126 views::ImageButton* check_button = new views::ImageButton(nullptr); |
| 132 gfx::ImageSkia icon_image = gfx::CreateVectorIcon( | 127 gfx::ImageSkia icon_image = gfx::CreateVectorIcon( |
| 133 gfx::VectorIconId::CHECK_CIRCLE, kMenuIconSize, button_color); | 128 gfx::VectorIconId::CHECK_CIRCLE, kMenuIconSize, button_color); |
| 134 check_button->SetImage(views::CustomButton::STATE_NORMAL, &icon_image); | 129 check_button->SetImage(views::CustomButton::STATE_NORMAL, &icon_image); |
| 135 const int button_padding = (kMenuButtonSize - icon_image.width()) / 2; | 130 const int button_padding = (kMenuButtonSize - icon_image.width()) / 2; |
| 136 check_button->SetBorder(views::Border::CreateEmptyBorder( | 131 check_button->SetBorder(views::Border::CreateEmptyBorder( |
| 137 button_padding, button_padding, button_padding, button_padding)); | 132 button_padding, button_padding, button_padding, button_padding)); |
| 138 AddChildView(check_button); | 133 tri_view->AddView(TriView::Container::END, check_button); |
| 139 } | 134 } |
| 140 } | 135 } |
| 141 | 136 |
| 142 ~ImeListItemView() override {} | 137 ~ImeListItemView() override {} |
| 143 | 138 |
| 144 // ActionableView: | 139 // ActionableView: |
| 145 bool PerformAction(const ui::Event& event) override { | 140 bool PerformAction(const ui::Event& event) override { |
| 146 ime_list_view_->HandleViewClicked(this); | 141 ime_list_view_->HandleViewClicked(this); |
| 147 return true; | 142 return true; |
| 148 } | 143 } |
| 149 | 144 |
| 150 private: | 145 private: |
| 151 ImeListView* ime_list_view_; | 146 ImeListView* ime_list_view_; |
| 152 DISALLOW_COPY_AND_ASSIGN(ImeListItemView); | 147 DISALLOW_COPY_AND_ASSIGN(ImeListItemView); |
| 153 }; | 148 }; |
| 154 | 149 |
| 155 } // namespace | 150 } // namespace |
| 156 | 151 |
| 152 // The view that contains a |KeyboardButtonView| and a toggle button. | |
| 153 class ImeListView::MaterialKeyboardStatusRowView : public views::View { | |
| 154 public: | |
| 155 MaterialKeyboardStatusRowView(views::ButtonListener* listener, bool enabled) | |
| 156 : views::View(), listener_(listener), toggle_(nullptr) { | |
| 157 Init(); | |
| 158 SetKeyboardStatusEnabled(enabled); | |
| 159 } | |
| 160 | |
| 161 ~MaterialKeyboardStatusRowView() override {} | |
| 162 | |
| 163 void SetKeyboardStatusEnabled(bool enabled) { | |
| 164 toggle_->SetIsOn(enabled, true); | |
| 165 } | |
| 166 | |
| 167 const views::Button* toggle() const { return toggle_; } | |
| 168 bool is_toggled() const { return toggle_->is_on(); } | |
| 169 | |
| 170 protected: | |
| 171 // views::View: | |
| 172 gfx::Size GetPreferredSize() const override { | |
| 173 gfx::Size size = views::View::GetPreferredSize(); | |
| 174 size.set_height(kMenuButtonSize + kKeyboardRowkVerticalInset * 2); | |
| 175 return size; | |
| 176 } | |
| 177 | |
| 178 int GetHeightForWidth(int w) const override { | |
| 179 return GetPreferredSize().height(); | |
| 180 } | |
| 181 | |
| 182 private: | |
| 183 void Init() { | |
| 184 SetBorder(views::Border::CreateSolidSidedBorder( | |
| 185 kKeyboardRowSeparatorThickness, 0, 0, 0, kKeyboardRowSeparatorColor)); | |
| 186 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); | |
| 187 AddChildView(tri_view); | |
| 188 SetLayoutManager(new views::FillLayout); | |
| 189 | |
| 190 // The on-screen keyboard image button. | |
| 191 ui::NativeTheme* theme = GetNativeTheme(); | |
| 192 views::ImageButton* image_button = new views::ImageButton(nullptr); | |
| 193 gfx::ImageSkia image = CreateVectorIcon(kImeMenuOnScreenKeyboardIcon, | |
| 194 kMenuIconSize, kMenuIconColor); | |
| 195 image_button->SetImage(views::CustomButton::STATE_NORMAL, &image); | |
| 196 const int horizontal_padding = (kMenuButtonSize - image.width()) / 2; | |
| 197 const int vertical_padding = (kMenuButtonSize - image.height()) / 2; | |
| 198 image_button->SetBorder(views::Border::CreateEmptyBorder( | |
| 199 gfx::Insets(vertical_padding, horizontal_padding))); | |
|
tdanderson
2016/11/02 18:44:36
For lines 192-198, I don't think this needs to be
Azure Wei
2016/11/03 02:06:44
Done. Updated as using CreateMainImageView() and i
| |
| 200 const SkColor focus_color = | |
| 201 theme->GetSystemColor(ui::NativeTheme::kColorId_FocusedBorderColor); | |
| 202 image_button->SetFocusForPlatform(); | |
|
tdanderson
2016/11/02 18:44:36
The image button shouldn't need to have system foc
Azure Wei
2016/11/03 02:06:44
Done. Removed this line.
| |
| 203 image_button->SetFocusPainter(views::Painter::CreateSolidFocusPainter( | |
| 204 focus_color, gfx::Insets(kFocusBorderInset))); | |
| 205 tri_view->AddView(TriView::Container::START, image_button); | |
| 206 | |
| 207 // The on-screen keyboard label. | |
| 208 views::Label* label = new views::Label( | |
|
tdanderson
2016/11/02 18:44:36
I think you will also need to use the TrayPopupIte
Azure Wei
2016/11/03 02:06:44
Done. Used TrayPopupItemStyle to update the label'
| |
| 209 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( | |
| 210 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD)); | |
| 211 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 212 tri_view->AddView(TriView::Container::CENTER, label); | |
| 213 | |
| 214 // The on-screen keyboard toggle button. | |
| 215 toggle_ = new views::ToggleButton(listener_); | |
| 216 toggle_->SetFocusForPlatform(); | |
| 217 toggle_->SetTooltipText(l10n_util::GetStringUTF16( | |
| 218 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD)); | |
|
tdanderson
2016/11/02 18:44:36
This lg for the time being, thanks for adding it.
Azure Wei
2016/11/03 02:06:44
Sorry, this should be 'Enable/Disable on-screen ke
| |
| 219 tri_view->AddView(TriView::Container::END, toggle_); | |
| 220 } | |
| 221 | |
| 222 // ButtonListener to notify when |toggle_| is clicked. | |
| 223 views::ButtonListener* listener_; | |
| 224 | |
| 225 // ToggleButton to toggle keyboard on or off. | |
| 226 views::ToggleButton* toggle_; | |
| 227 | |
| 228 DISALLOW_COPY_AND_ASSIGN(MaterialKeyboardStatusRowView); | |
| 229 }; | |
| 230 | |
| 157 ImeListView::ImeListView(SystemTrayItem* owner, | 231 ImeListView::ImeListView(SystemTrayItem* owner, |
| 158 bool show_keyboard_toggle, | 232 bool show_keyboard_toggle, |
| 159 SingleImeBehavior single_ime_behavior) | 233 SingleImeBehavior single_ime_behavior) |
| 160 : TrayDetailsView(owner) { | 234 : TrayDetailsView(owner) { |
| 161 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 235 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 162 IMEInfoList list; | 236 IMEInfoList list; |
| 163 delegate->GetAvailableIMEList(&list); | 237 delegate->GetAvailableIMEList(&list); |
| 164 IMEPropertyInfoList property_list; | 238 IMEPropertyInfoList property_list; |
| 165 delegate->GetCurrentIMEProperties(&property_list); | 239 delegate->GetCurrentIMEProperties(&property_list); |
| 166 Update(list, property_list, show_keyboard_toggle, single_ime_behavior); | 240 Update(list, property_list, show_keyboard_toggle, single_ime_behavior); |
| 167 } | 241 } |
| 168 | 242 |
| 169 ImeListView::~ImeListView() {} | 243 ImeListView::~ImeListView() {} |
| 170 | 244 |
| 171 void ImeListView::Update(const IMEInfoList& list, | 245 void ImeListView::Update(const IMEInfoList& list, |
| 172 const IMEPropertyInfoList& property_list, | 246 const IMEPropertyInfoList& property_list, |
| 173 bool show_keyboard_toggle, | 247 bool show_keyboard_toggle, |
| 174 SingleImeBehavior single_ime_behavior) { | 248 SingleImeBehavior single_ime_behavior) { |
| 175 Reset(); | 249 Reset(); |
| 250 if (show_keyboard_toggle && | |
| 251 MaterialDesignController::IsSystemTrayMenuMaterial()) { | |
|
tdanderson
2016/11/02 18:44:36
Should you also include a check that |material_key
Azure Wei
2016/11/03 02:06:44
Done. Added the check for |material_keyboard_statu
| |
| 252 AppendMaterialKeyboardStatus(); | |
| 253 } | |
| 254 | |
| 176 ime_map_.clear(); | 255 ime_map_.clear(); |
| 177 property_map_.clear(); | 256 property_map_.clear(); |
| 178 CreateScrollableList(); | 257 CreateScrollableList(); |
| 179 | 258 |
| 180 // Appends IME list and IME properties. | 259 // Appends IME list and IME properties. |
| 181 if (single_ime_behavior == ImeListView::SHOW_SINGLE_IME || list.size() > 1) { | 260 if (single_ime_behavior == ImeListView::SHOW_SINGLE_IME || list.size() > 1) { |
| 182 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 261 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 183 AppendImeListAndProperties(list, property_list); | 262 AppendImeListAndProperties(list, property_list); |
| 184 } else { | 263 } else { |
| 185 AppendIMEList(list); | 264 AppendIMEList(list); |
| 186 if (!property_list.empty()) | 265 if (!property_list.empty()) |
| 187 AppendIMEProperties(property_list); | 266 AppendIMEProperties(property_list); |
| 188 } | 267 } |
| 189 } | 268 } |
| 190 | 269 |
| 191 if (show_keyboard_toggle) { | 270 if (show_keyboard_toggle && |
| 271 !MaterialDesignController::IsSystemTrayMenuMaterial()) { | |
| 192 if (list.size() > 1 || !property_list.empty()) | 272 if (list.size() > 1 || !property_list.empty()) |
| 193 AddScrollSeparator(); | 273 AddScrollSeparator(); |
| 194 AppendKeyboardStatus(); | 274 AppendKeyboardStatus(); |
| 195 } | 275 } |
| 196 | 276 |
| 197 Layout(); | 277 Layout(); |
| 198 SchedulePaint(); | 278 SchedulePaint(); |
| 199 } | 279 } |
| 200 | 280 |
| 201 void ImeListView::AppendIMEList(const IMEInfoList& list) { | 281 void ImeListView::AppendIMEList(const IMEInfoList& list) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 HoverHighlightView* container = new HoverHighlightView(this); | 338 HoverHighlightView* container = new HoverHighlightView(this); |
| 259 int id = keyboard::IsKeyboardEnabled() ? IDS_ASH_STATUS_TRAY_DISABLE_KEYBOARD | 339 int id = keyboard::IsKeyboardEnabled() ? IDS_ASH_STATUS_TRAY_DISABLE_KEYBOARD |
| 260 : IDS_ASH_STATUS_TRAY_ENABLE_KEYBOARD; | 340 : IDS_ASH_STATUS_TRAY_ENABLE_KEYBOARD; |
| 261 container->AddLabel( | 341 container->AddLabel( |
| 262 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id), | 342 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id), |
| 263 gfx::ALIGN_LEFT, false /* highlight */); | 343 gfx::ALIGN_LEFT, false /* highlight */); |
| 264 scroll_content()->AddChildView(container); | 344 scroll_content()->AddChildView(container); |
| 265 keyboard_status_ = container; | 345 keyboard_status_ = container; |
| 266 } | 346 } |
| 267 | 347 |
| 348 void ImeListView::AppendMaterialKeyboardStatus() { | |
| 349 MaterialKeyboardStatusRowView* view = | |
| 350 new MaterialKeyboardStatusRowView(this, keyboard::IsKeyboardEnabled()); | |
| 351 view->SetKeyboardStatusEnabled(keyboard::IsKeyboardEnabled()); | |
| 352 AddChildView(view); | |
| 353 material_keyboard_statuts_view_ = view; | |
| 354 } | |
| 355 | |
| 268 void ImeListView::HandleViewClicked(views::View* view) { | 356 void ImeListView::HandleViewClicked(views::View* view) { |
| 269 if (view == keyboard_status_) { | 357 if (view == keyboard_status_) { |
| 270 WmShell::Get()->ToggleIgnoreExternalKeyboard(); | 358 WmShell::Get()->ToggleIgnoreExternalKeyboard(); |
| 271 return; | 359 return; |
| 272 } | 360 } |
| 273 | 361 |
| 274 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 362 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 275 std::map<views::View*, std::string>::const_iterator ime = ime_map_.find(view); | 363 std::map<views::View*, std::string>::const_iterator ime = ime_map_.find(view); |
| 276 if (ime != ime_map_.end()) { | 364 if (ime != ime_map_.end()) { |
| 277 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SWITCH_MODE); | 365 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SWITCH_MODE); |
| 278 std::string ime_id = ime->second; | 366 std::string ime_id = ime->second; |
| 279 delegate->SwitchIME(ime_id); | 367 delegate->SwitchIME(ime_id); |
| 280 } else { | 368 } else { |
| 281 std::map<views::View*, std::string>::const_iterator property = | 369 std::map<views::View*, std::string>::const_iterator property = |
| 282 property_map_.find(view); | 370 property_map_.find(view); |
| 283 if (property == property_map_.end()) | 371 if (property == property_map_.end()) |
| 284 return; | 372 return; |
| 285 const std::string key = property->second; | 373 const std::string key = property->second; |
| 286 delegate->ActivateIMEProperty(key); | 374 delegate->ActivateIMEProperty(key); |
| 287 } | 375 } |
| 288 | 376 |
| 289 GetWidget()->Close(); | 377 GetWidget()->Close(); |
| 290 } | 378 } |
| 291 | 379 |
| 380 void ImeListView::ButtonPressed(views::Button* sender, const ui::Event& event) { | |
| 381 if (material_keyboard_statuts_view_ && | |
| 382 sender == material_keyboard_statuts_view_->toggle() && | |
| 383 !material_keyboard_statuts_view_->is_toggled()) { | |
|
tdanderson
2016/11/02 18:44:36
Isn't there also a call you need to make when mate
Azure Wei
2016/11/03 02:06:44
Removed the check for material_keyboard_status_vie
tdanderson
2016/11/03 21:17:05
I went into non-MD mode on canary, plugged in an e
| |
| 384 WmShell::Get()->ToggleIgnoreExternalKeyboard(); | |
| 385 } | |
| 386 } | |
| 387 | |
| 292 } // namespace ash | 388 } // namespace ash |
| OLD | NEW |