| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Returns the height range of ImeListView. | 50 // Returns the height range of ImeListView. |
| 51 gfx::Range GetImeListViewRange() { | 51 gfx::Range GetImeListViewRange() { |
| 52 const int max_items = 5; | 52 const int max_items = 5; |
| 53 const int min_items = 2; | 53 const int min_items = 1; |
| 54 const int tray_item_height = GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT); | 54 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); | 55 return gfx::Range(tray_item_height * min_items, tray_item_height * max_items); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Returns the minimum with of IME menu. | 58 // Returns the minimum with of IME menu. |
| 59 int GetMinimumMenuWidth() { | 59 int GetMinimumMenuWidth() { |
| 60 return MaterialDesignController::IsSystemTrayMenuMaterial() | 60 return MaterialDesignController::IsSystemTrayMenuMaterial() |
| 61 ? kTrayMenuMinimumWidthMd | 61 ? kTrayMenuMinimumWidthMd |
| 62 : kTrayMenuMinimumWidth; | 62 : kTrayMenuMinimumWidth; |
| 63 } | 63 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); | 313 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); |
| 314 }; | 314 }; |
| 315 | 315 |
| 316 // The list view that contains the selected IME and property items. | 316 // The list view that contains the selected IME and property items. |
| 317 class ImeMenuListView : public ImeListView { | 317 class ImeMenuListView : public ImeListView { |
| 318 public: | 318 public: |
| 319 ImeMenuListView(SystemTrayItem* owner, | 319 ImeMenuListView(SystemTrayItem* owner, |
| 320 bool show_keyboard_toggle, | 320 bool show_keyboard_toggle, |
| 321 SingleImeBehavior single_ime_behavior) | 321 SingleImeBehavior single_ime_behavior) |
| 322 : ImeListView(owner, show_keyboard_toggle, ImeListView::HIDE_SINGLE_IME) { | 322 : ImeListView(owner, show_keyboard_toggle, single_ime_behavior) { |
| 323 set_should_focus_ime_after_selection_with_keyboard(true); | 323 set_should_focus_ime_after_selection_with_keyboard(true); |
| 324 } | 324 } |
| 325 | 325 |
| 326 ~ImeMenuListView() override {} | 326 ~ImeMenuListView() override {} |
| 327 | 327 |
| 328 protected: | 328 protected: |
| 329 void Layout() override { | 329 void Layout() override { |
| 330 gfx::Range height_range = GetImeListViewRange(); | 330 gfx::Range height_range = GetImeListViewRange(); |
| 331 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 331 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 332 scroller()->ClipHeightTo(height_range.start(), height_range.end()); | 332 scroller()->ClipHeightTo(height_range.start(), height_range.end()); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 600 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 601 | 601 |
| 602 // Updates the tray label based on the current input method. | 602 // Updates the tray label based on the current input method. |
| 603 if (current_ime_.third_party) | 603 if (current_ime_.third_party) |
| 604 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 604 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 605 else | 605 else |
| 606 label_->SetText(current_ime_.short_name); | 606 label_->SetText(current_ime_.short_name); |
| 607 } | 607 } |
| 608 | 608 |
| 609 } // namespace ash | 609 } // namespace ash |
| OLD | NEW |