Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: ash/common/system/chromeos/ime_menu/ime_menu_tray.cc

Issue 2673333002: Fix regression where no IMEs appear in the opt-in IME menu (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_menu_tray.h" 5 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h"
6 6
7 #include "ash/common/accessibility_delegate.h" 7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/ash_constants.h" 8 #include "ash/common/ash_constants.h"
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 kHorizontalSeparatorColor), 146 kHorizontalSeparatorColor),
147 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); 147 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0)));
148 auto* box_layout = 148 auto* box_layout =
149 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 149 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
150 box_layout->set_minimum_cross_axis_size( 150 box_layout->set_minimum_cross_axis_size(
151 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); 151 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
152 SetLayoutManager(box_layout); 152 SetLayoutManager(box_layout);
153 auto title_label = 153 auto title_label =
154 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); 154 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME));
155 title_label->SetBorder(views::CreateEmptyBorder( 155 title_label->SetBorder(views::CreateEmptyBorder(
156 0, kMenuEdgeEffectivePadding, kTrayMenuBottomRowPadding, 0)); 156 0, kMenuEdgeEffectivePadding,
157 kTrayImageItemHorizontalPaddingVerticalAlignment, 0));
tdanderson 2017/02/06 22:41:35 This constant is unrelated to what you're doing he
Azure Wei 2017/02/07 01:06:07 Done. Updated as hard-coding of '1'.
157 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 158 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
158 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE); 159 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE);
159 style.SetupLabel(title_label); 160 style.SetupLabel(title_label);
160 161
161 AddChildView(title_label); 162 AddChildView(title_label);
162 box_layout->SetFlexForView(title_label, 1); 163 box_layout->SetFlexForView(title_label, 1);
163 164
164 if (show_settings_button) { 165 if (show_settings_button) {
165 settings_button_ = CreateImeMenuButton( 166 settings_button_ = CreateImeMenuButton(
166 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); 167 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 SystemMenuButton* voice_button_; 330 SystemMenuButton* voice_button_;
330 SystemMenuButton* settings_button_; 331 SystemMenuButton* settings_button_;
331 HoverHighlightView* one_settings_button_view_; 332 HoverHighlightView* one_settings_button_view_;
332 333
333 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); 334 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView);
334 }; 335 };
335 336
336 // The list view that contains the selected IME and property items. 337 // The list view that contains the selected IME and property items.
337 class ImeMenuListView : public ImeListView { 338 class ImeMenuListView : public ImeListView {
338 public: 339 public:
339 ImeMenuListView(SystemTrayItem* owner, 340 ImeMenuListView(SystemTrayItem* owner) : ImeListView(owner) {
340 bool show_keyboard_toggle,
341 SingleImeBehavior single_ime_behavior)
342 : ImeListView(owner, show_keyboard_toggle, single_ime_behavior) {
343 set_should_focus_ime_after_selection_with_keyboard(true); 341 set_should_focus_ime_after_selection_with_keyboard(true);
344 } 342 }
345 343
346 ~ImeMenuListView() override {} 344 ~ImeMenuListView() override {}
347 345
348 protected: 346 protected:
349 void Layout() override { 347 void Layout() override {
350 gfx::Range height_range = GetImeListViewRange(); 348 gfx::Range height_range = GetImeListViewRange();
351 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 349 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
352 scroller()->ClipHeightTo(height_range.start(), height_range.end()); 350 scroller()->ClipHeightTo(height_range.start(), height_range.end());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // In the material design, we will add a title item with a separator on the 428 // In the material design, we will add a title item with a separator on the
431 // top of the IME menu. 429 // top of the IME menu.
432 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 430 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
433 bubble_view->AddChildView( 431 bubble_view->AddChildView(
434 new ImeTitleView(!ShouldShowEmojiHandwritingVoiceButtons())); 432 new ImeTitleView(!ShouldShowEmojiHandwritingVoiceButtons()));
435 } else { 433 } else {
436 bubble_view->set_margins(gfx::Insets(7, 0, 0, 0)); 434 bubble_view->set_margins(gfx::Insets(7, 0, 0, 0));
437 } 435 }
438 436
439 // Adds IME list to the bubble. 437 // Adds IME list to the bubble.
440 ime_list_view_ = new ImeMenuListView(nullptr, ShouldShowKeyboardToggle(), 438 ime_list_view_ = new ImeMenuListView(nullptr);
441 ImeListView::SHOW_SINGLE_IME); 439 ime_list_view_->Init(ShouldShowKeyboardToggle(),
440 ImeListView::SHOW_SINGLE_IME);
442 bubble_view->AddChildView(ime_list_view_); 441 bubble_view->AddChildView(ime_list_view_);
443 442
444 if (ShouldShowEmojiHandwritingVoiceButtons()) { 443 if (ShouldShowEmojiHandwritingVoiceButtons()) {
445 bubble_view->AddChildView(new ImeButtonsView(this, true, true, true, true)); 444 bubble_view->AddChildView(new ImeButtonsView(this, true, true, true, true));
446 } else if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { 445 } else if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
447 // For MD, we don't need |ImeButtonsView| as the settings button will be 446 // For MD, we don't need |ImeButtonsView| as the settings button will be
448 // shown in the title row. 447 // shown in the title row.
449 bubble_view->AddChildView( 448 bubble_view->AddChildView(
450 new ImeButtonsView(this, false, false, false, true)); 449 new ImeButtonsView(this, false, false, false, true));
451 } 450 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 661 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
663 662
664 // Updates the tray label based on the current input method. 663 // Updates the tray label based on the current input method.
665 if (current_ime_.third_party) 664 if (current_ime_.third_party)
666 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 665 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
667 else 666 else
668 label_->SetText(current_ime_.short_name); 667 label_->SetText(current_ime_.short_name);
669 } 668 }
670 669
671 } // namespace ash 670 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698