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

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

Issue 2540103003: Update the layout of opt-in IME menu. (Closed)
Patch Set: Addressed comments. Created 4 years 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
« no previous file with comments | « no previous file | ash/common/system/tray/system_tray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0, 107 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0,
108 kHorizontalSeparatorColor), 108 kHorizontalSeparatorColor),
109 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); 109 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0)));
110 auto* box_layout = 110 auto* box_layout =
111 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 111 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
112 box_layout->set_minimum_cross_axis_size( 112 box_layout->set_minimum_cross_axis_size(
113 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); 113 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
114 SetLayoutManager(box_layout); 114 SetLayoutManager(box_layout);
115 title_label_ = 115 title_label_ =
116 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); 116 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME));
117 title_label_->SetBorder( 117 title_label_->SetBorder(views::CreateEmptyBorder(
118 views::CreateEmptyBorder(0, kMenuEdgeEffectivePadding, 0, 0)); 118 0, kMenuEdgeEffectivePadding, kTrayMenuBottomRowPadding, 0));
119 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 119 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
120 AddChildView(title_label_); 120 AddChildView(title_label_);
121 box_layout->SetFlexForView(title_label_, 1); 121 box_layout->SetFlexForView(title_label_, 1);
122 122
123 if (show_settings_button) { 123 if (show_settings_button) {
124 settings_button_ = CreateImeMenuButton( 124 settings_button_ = CreateImeMenuButton(
125 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); 125 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0);
126 if (IsInLoginOrLockScreen()) 126 if (IsInLoginOrLockScreen())
127 settings_button_->SetEnabled(false); 127 settings_button_->SetEnabled(false);
128 AddChildView(settings_button_); 128 AddChildView(settings_button_);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 ImeMenuTray::~ImeMenuTray() { 318 ImeMenuTray::~ImeMenuTray() {
319 if (bubble_) 319 if (bubble_)
320 bubble_->bubble_view()->reset_delegate(); 320 bubble_->bubble_view()->reset_delegate();
321 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); 321 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier();
322 tray_notifier->RemoveIMEObserver(this); 322 tray_notifier->RemoveIMEObserver(this);
323 tray_notifier->RemoveVirtualKeyboardObserver(this); 323 tray_notifier->RemoveVirtualKeyboardObserver(this);
324 } 324 }
325 325
326 void ImeMenuTray::ShowImeMenuBubble() { 326 void ImeMenuTray::ShowImeMenuBubble() {
327 int minimum_menu_width = MaterialDesignController::IsSystemTrayMenuMaterial()
328 ? kTrayMenuMinimumWidthMd
329 : kTrayMenuMinimumWidth;
327 should_block_shelf_auto_hide_ = true; 330 should_block_shelf_auto_hide_ = true;
328 views::TrayBubbleView::InitParams init_params( 331 views::TrayBubbleView::InitParams init_params(
329 GetAnchorAlignment(), kTrayPopupMinWidth, kTrayPopupMaxWidth); 332 GetAnchorAlignment(), minimum_menu_width, minimum_menu_width);
330 init_params.can_activate = true; 333 init_params.can_activate = true;
331 init_params.close_on_deactivate = true; 334 init_params.close_on_deactivate = true;
332 335
333 views::TrayBubbleView* bubble_view = 336 views::TrayBubbleView* bubble_view =
334 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); 337 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params);
335 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); 338 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets());
336 339
337 // In the material design, we will add a title item with a separator on the 340 // In the material design, we will add a title item with a separator on the
338 // top of the IME menu. 341 // top of the IME menu.
339 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 342 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
(...skipping 10 matching lines...) Expand all
350 ImeListView::SHOW_SINGLE_IME); 353 ImeListView::SHOW_SINGLE_IME);
351 354
352 uint32_t current_height = ime_list_view_->scroll_content()->height(); 355 uint32_t current_height = ime_list_view_->scroll_content()->height();
353 const gfx::Range height_range = GetImeListViewRange(); 356 const gfx::Range height_range = GetImeListViewRange();
354 357
355 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 358 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
356 ime_list_view_->scroller()->ClipHeightTo(height_range.start(), 359 ime_list_view_->scroller()->ClipHeightTo(height_range.start(),
357 height_range.end()); 360 height_range.end());
358 } else if (current_height > height_range.end()) { 361 } else if (current_height > height_range.end()) {
359 ime_list_view_->scroller()->SetFixedSize( 362 ime_list_view_->scroller()->SetFixedSize(
360 gfx::Size(kTrayPopupMaxWidth, height_range.end())); 363 gfx::Size(minimum_menu_width, height_range.end()));
361 } else if (current_height < height_range.start()) { 364 } else if (current_height < height_range.start()) {
362 ime_list_view_->scroller()->SetFixedSize( 365 ime_list_view_->scroller()->SetFixedSize(
363 gfx::Size(kTrayPopupMaxWidth, height_range.start())); 366 gfx::Size(minimum_menu_width, height_range.start()));
364 } 367 }
365 bubble_view->AddChildView(ime_list_view_); 368 bubble_view->AddChildView(ime_list_view_);
366 369
367 // The bottom view that contains buttons are not supported in login/lock 370 // The bottom view that contains buttons are not supported in login/lock
368 // screen. 371 // screen.
369 if (!IsInLoginOrLockScreen()) { 372 if (!IsInLoginOrLockScreen()) {
370 if (ShouldShowEmojiHandwritingVoiceButtons()) { 373 if (ShouldShowEmojiHandwritingVoiceButtons()) {
371 bubble_view->AddChildView( 374 bubble_view->AddChildView(
372 new ImeButtonsView(this, true, true, true, true)); 375 new ImeButtonsView(this, true, true, true, true));
373 } else if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { 376 } else if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 564 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
562 565
563 // Updates the tray label based on the current input method. 566 // Updates the tray label based on the current input method.
564 if (current_ime_.third_party) 567 if (current_ime_.third_party)
565 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 568 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
566 else 569 else
567 label_->SetText(current_ime_.short_name); 570 label_->SetText(current_ime_.short_name);
568 } 571 }
569 572
570 } // namespace ash 573 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698