| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 299 |
| 300 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); | 300 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); |
| 301 }; | 301 }; |
| 302 | 302 |
| 303 // The list view that contains the selected IME and property items. | 303 // The list view that contains the selected IME and property items. |
| 304 class ImeMenuListView : public ImeListView { | 304 class ImeMenuListView : public ImeListView { |
| 305 public: | 305 public: |
| 306 ImeMenuListView(SystemTrayItem* owner, | 306 ImeMenuListView(SystemTrayItem* owner, |
| 307 bool show_keyboard_toggle, | 307 bool show_keyboard_toggle, |
| 308 SingleImeBehavior single_ime_behavior) | 308 SingleImeBehavior single_ime_behavior) |
| 309 : ImeListView(owner, show_keyboard_toggle, ImeListView::HIDE_SINGLE_IME) { | 309 : ImeListView(owner, show_keyboard_toggle, single_ime_behavior) { |
| 310 set_should_focus_ime_after_selection_with_keyboard(true); | 310 set_should_focus_ime_after_selection_with_keyboard(true); |
| 311 } | 311 } |
| 312 | 312 |
| 313 ~ImeMenuListView() override {} | 313 ~ImeMenuListView() override {} |
| 314 | 314 |
| 315 protected: | 315 protected: |
| 316 void Layout() override { | 316 void Layout() override { |
| 317 gfx::Range height_range = GetImeListViewRange(); | 317 gfx::Range height_range = GetImeListViewRange(); |
| 318 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 318 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 319 scroller()->ClipHeightTo(height_range.start(), height_range.end()); | 319 scroller()->ClipHeightTo(height_range.start(), height_range.end()); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 587 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 588 | 588 |
| 589 // Updates the tray label based on the current input method. | 589 // Updates the tray label based on the current input method. |
| 590 if (current_ime_.third_party) | 590 if (current_ime_.third_party) |
| 591 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 591 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 592 else | 592 else |
| 593 label_->SetText(current_ime_.short_name); | 593 label_->SetText(current_ime_.short_name); |
| 594 } | 594 } |
| 595 | 595 |
| 596 } // namespace ash | 596 } // namespace ash |
| OLD | NEW |