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_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 29 matching lines...) Expand all Loading... | |
40 #include "ui/views/controls/button/button.h" | 40 #include "ui/views/controls/button/button.h" |
41 #include "ui/views/controls/label.h" | 41 #include "ui/views/controls/label.h" |
42 #include "ui/views/controls/separator.h" | 42 #include "ui/views/controls/separator.h" |
43 #include "ui/views/layout/box_layout.h" | 43 #include "ui/views/layout/box_layout.h" |
44 | 44 |
45 using chromeos::input_method::InputMethodManager; | 45 using chromeos::input_method::InputMethodManager; |
46 | 46 |
47 namespace ash { | 47 namespace ash { |
48 | 48 |
49 namespace { | 49 namespace { |
50 // The width of the IME menu in dp. | |
51 const int kImeMenuWidth = 332; | |
tdanderson
2016/11/30 23:16:01
The system menu size has since been increased to 3
Azure Wei
2016/12/01 02:55:34
Done. Move kMinimumSystemTrayMenuWidth(Md) into tr
| |
52 | |
53 // The bottom padding of the title label. | |
54 const int kTitleRowBottomPadding = 5; | |
55 | |
50 // Returns the height range of ImeListView. | 56 // Returns the height range of ImeListView. |
51 gfx::Range GetImeListViewRange() { | 57 gfx::Range GetImeListViewRange() { |
52 const int max_items = 5; | 58 const int max_items = 5; |
53 const int min_items = 2; | 59 const int min_items = 2; |
54 const int tray_item_height = GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT); | 60 const int tray_item_height = GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT); |
55 return gfx::Range(tray_item_height * min_items, tray_item_height * max_items); | 61 return gfx::Range(tray_item_height * min_items, tray_item_height * max_items); |
56 } | 62 } |
57 | 63 |
58 // Shows language and input settings page. | 64 // Shows language and input settings page. |
59 void ShowIMESettings() { | 65 void ShowIMESettings() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0, | 113 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0, |
108 kHorizontalSeparatorColor), | 114 kHorizontalSeparatorColor), |
109 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); | 115 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); |
110 auto* box_layout = | 116 auto* box_layout = |
111 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 117 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
112 box_layout->set_minimum_cross_axis_size( | 118 box_layout->set_minimum_cross_axis_size( |
113 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); | 119 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); |
114 SetLayoutManager(box_layout); | 120 SetLayoutManager(box_layout); |
115 title_label_ = | 121 title_label_ = |
116 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); | 122 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_IME)); |
117 title_label_->SetBorder( | 123 title_label_->SetBorder(views::CreateEmptyBorder( |
tdanderson
2016/11/30 23:16:01
For reference can you post a screenshot to the bug
Azure Wei
2016/12/01 02:55:34
Compared that the title row height should match. I
| |
118 views::CreateEmptyBorder(0, kMenuEdgeEffectivePadding, 0, 0)); | 124 0, kMenuEdgeEffectivePadding, kTitleRowBottomPadding, 0)); |
119 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 125 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
120 AddChildView(title_label_); | 126 AddChildView(title_label_); |
121 box_layout->SetFlexForView(title_label_, 1); | 127 box_layout->SetFlexForView(title_label_, 1); |
122 | 128 |
123 if (show_settings_button) { | 129 if (show_settings_button) { |
124 settings_button_ = CreateImeMenuButton( | 130 settings_button_ = CreateImeMenuButton( |
125 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); | 131 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); |
126 if (IsInLoginOrLockScreen()) | 132 if (IsInLoginOrLockScreen()) |
127 settings_button_->SetEnabled(false); | 133 settings_button_->SetEnabled(false); |
128 AddChildView(settings_button_); | 134 AddChildView(settings_button_); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 ImeMenuTray::~ImeMenuTray() { | 324 ImeMenuTray::~ImeMenuTray() { |
319 if (bubble_) | 325 if (bubble_) |
320 bubble_->bubble_view()->reset_delegate(); | 326 bubble_->bubble_view()->reset_delegate(); |
321 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); | 327 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); |
322 tray_notifier->RemoveIMEObserver(this); | 328 tray_notifier->RemoveIMEObserver(this); |
323 tray_notifier->RemoveVirtualKeyboardObserver(this); | 329 tray_notifier->RemoveVirtualKeyboardObserver(this); |
324 } | 330 } |
325 | 331 |
326 void ImeMenuTray::ShowImeMenuBubble() { | 332 void ImeMenuTray::ShowImeMenuBubble() { |
327 should_block_shelf_auto_hide_ = true; | 333 should_block_shelf_auto_hide_ = true; |
328 views::TrayBubbleView::InitParams init_params( | 334 views::TrayBubbleView::InitParams init_params(GetAnchorAlignment(), |
329 GetAnchorAlignment(), kTrayPopupMinWidth, kTrayPopupMaxWidth); | 335 kImeMenuWidth, kImeMenuWidth); |
330 init_params.can_activate = true; | 336 init_params.can_activate = true; |
331 init_params.close_on_deactivate = true; | 337 init_params.close_on_deactivate = true; |
332 | 338 |
333 views::TrayBubbleView* bubble_view = | 339 views::TrayBubbleView* bubble_view = |
334 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); | 340 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); |
335 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); | 341 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); |
336 | 342 |
337 // In the material design, we will add a title item with a separator on the | 343 // In the material design, we will add a title item with a separator on the |
338 // top of the IME menu. | 344 // top of the IME menu. |
339 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 345 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
(...skipping 10 matching lines...) Expand all Loading... | |
350 ImeListView::SHOW_SINGLE_IME); | 356 ImeListView::SHOW_SINGLE_IME); |
351 | 357 |
352 uint32_t current_height = ime_list_view_->scroll_content()->height(); | 358 uint32_t current_height = ime_list_view_->scroll_content()->height(); |
353 const gfx::Range height_range = GetImeListViewRange(); | 359 const gfx::Range height_range = GetImeListViewRange(); |
354 | 360 |
355 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 361 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
356 ime_list_view_->scroller()->ClipHeightTo(height_range.start(), | 362 ime_list_view_->scroller()->ClipHeightTo(height_range.start(), |
357 height_range.end()); | 363 height_range.end()); |
358 } else if (current_height > height_range.end()) { | 364 } else if (current_height > height_range.end()) { |
359 ime_list_view_->scroller()->SetFixedSize( | 365 ime_list_view_->scroller()->SetFixedSize( |
360 gfx::Size(kTrayPopupMaxWidth, height_range.end())); | 366 gfx::Size(kImeMenuWidth, height_range.end())); |
361 } else if (current_height < height_range.start()) { | 367 } else if (current_height < height_range.start()) { |
362 ime_list_view_->scroller()->SetFixedSize( | 368 ime_list_view_->scroller()->SetFixedSize( |
363 gfx::Size(kTrayPopupMaxWidth, height_range.start())); | 369 gfx::Size(kImeMenuWidth, height_range.start())); |
364 } | 370 } |
365 bubble_view->AddChildView(ime_list_view_); | 371 bubble_view->AddChildView(ime_list_view_); |
366 | 372 |
367 // The bottom view that contains buttons are not supported in login/lock | 373 // The bottom view that contains buttons are not supported in login/lock |
368 // screen. | 374 // screen. |
369 if (!IsInLoginOrLockScreen()) { | 375 if (!IsInLoginOrLockScreen()) { |
370 if (ShouldShowEmojiHandwritingVoiceButtons()) { | 376 if (ShouldShowEmojiHandwritingVoiceButtons()) { |
371 bubble_view->AddChildView( | 377 bubble_view->AddChildView( |
372 new ImeButtonsView(this, true, true, true, true)); | 378 new ImeButtonsView(this, true, true, true, true)); |
373 } else if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { | 379 } else if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 567 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
562 | 568 |
563 // Updates the tray label based on the current input method. | 569 // Updates the tray label based on the current input method. |
564 if (current_ime_.third_party) | 570 if (current_ime_.third_party) |
565 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 571 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
566 else | 572 else |
567 label_->SetText(current_ime_.short_name); | 573 label_->SetText(current_ime_.short_name); |
568 } | 574 } |
569 | 575 |
570 } // namespace ash | 576 } // namespace ash |
OLD | NEW |