OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/system/virtual_keyboard/virtual_keyboard_tray.h" | 5 #include "ash/system/virtual_keyboard/virtual_keyboard_tray.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/keyboard/keyboard_ui.h" | 9 #include "ash/keyboard/keyboard_ui.h" |
10 #include "ash/resources/vector_icons/vector_icons.h" | 10 #include "ash/resources/vector_icons/vector_icons.h" |
| 11 #include "ash/shelf/shelf.h" |
11 #include "ash/shelf/shelf_constants.h" | 12 #include "ash/shelf/shelf_constants.h" |
12 #include "ash/shelf/wm_shelf.h" | |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/strings/grit/ash_strings.h" | 14 #include "ash/strings/grit/ash_strings.h" |
15 #include "ash/system/tray/tray_constants.h" | 15 #include "ash/system/tray/tray_constants.h" |
16 #include "ash/system/tray/tray_container.h" | 16 #include "ash/system/tray/tray_container.h" |
17 #include "ash/wm_window.h" | 17 #include "ash/wm_window.h" |
18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
20 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
21 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
22 #include "ui/gfx/paint_vector_icon.h" | 22 #include "ui/gfx/paint_vector_icon.h" |
23 #include "ui/keyboard/keyboard_controller.h" | 23 #include "ui/keyboard/keyboard_controller.h" |
24 #include "ui/views/controls/image_view.h" | 24 #include "ui/views/controls/image_view.h" |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 | 27 |
28 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf) | 28 VirtualKeyboardTray::VirtualKeyboardTray(Shelf* shelf) |
29 : TrayBackgroundView(wm_shelf), | 29 : TrayBackgroundView(shelf), icon_(new views::ImageView), shelf_(shelf) { |
30 icon_(new views::ImageView), | |
31 wm_shelf_(wm_shelf) { | |
32 SetInkDropMode(InkDropMode::ON); | 30 SetInkDropMode(InkDropMode::ON); |
33 | 31 |
34 gfx::ImageSkia image = | 32 gfx::ImageSkia image = |
35 gfx::CreateVectorIcon(kShelfKeyboardIcon, kShelfIconColor); | 33 gfx::CreateVectorIcon(kShelfKeyboardIcon, kShelfIconColor); |
36 icon_->SetImage(image); | 34 icon_->SetImage(image); |
37 const int vertical_padding = (kTrayItemSize - image.height()) / 2; | 35 const int vertical_padding = (kTrayItemSize - image.height()) / 2; |
38 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; | 36 const int horizontal_padding = (kTrayItemSize - image.width()) / 2; |
39 icon_->SetBorder(views::CreateEmptyBorder( | 37 icon_->SetBorder(views::CreateEmptyBorder( |
40 gfx::Insets(vertical_padding, horizontal_padding))); | 38 gfx::Insets(vertical_padding, horizontal_padding))); |
41 tray_container()->AddChildView(icon_); | 39 tray_container()->AddChildView(icon_); |
(...skipping 18 matching lines...) Expand all Loading... |
60 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); | 58 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); |
61 } | 59 } |
62 | 60 |
63 void VirtualKeyboardTray::HideBubbleWithView( | 61 void VirtualKeyboardTray::HideBubbleWithView( |
64 const views::TrayBubbleView* bubble_view) {} | 62 const views::TrayBubbleView* bubble_view) {} |
65 | 63 |
66 void VirtualKeyboardTray::ClickedOutsideBubble() {} | 64 void VirtualKeyboardTray::ClickedOutsideBubble() {} |
67 | 65 |
68 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { | 66 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { |
69 const int64_t display_id = | 67 const int64_t display_id = |
70 wm_shelf_->GetWindow()->GetDisplayNearestWindow().id(); | 68 shelf_->GetWindow()->GetDisplayNearestWindow().id(); |
71 Shell::Get()->keyboard_ui()->ShowInDisplay(display_id); | 69 Shell::Get()->keyboard_ui()->ShowInDisplay(display_id); |
72 // Normally, active status is set when virtual keyboard is shown/hidden, | 70 // Normally, active status is set when virtual keyboard is shown/hidden, |
73 // however, showing virtual keyboard happens asynchronously and, especially | 71 // however, showing virtual keyboard happens asynchronously and, especially |
74 // the first time, takes some time. We need to set active status here to | 72 // the first time, takes some time. We need to set active status here to |
75 // prevent bad things happening if user clicked the button before keyboard is | 73 // prevent bad things happening if user clicked the button before keyboard is |
76 // shown. | 74 // shown. |
77 SetIsActive(true); | 75 SetIsActive(true); |
78 return true; | 76 return true; |
79 } | 77 } |
80 | 78 |
(...skipping 24 matching lines...) Expand all Loading... |
105 } | 103 } |
106 | 104 |
107 void VirtualKeyboardTray::UnobserveKeyboardController() { | 105 void VirtualKeyboardTray::UnobserveKeyboardController() { |
108 keyboard::KeyboardController* keyboard_controller = | 106 keyboard::KeyboardController* keyboard_controller = |
109 keyboard::KeyboardController::GetInstance(); | 107 keyboard::KeyboardController::GetInstance(); |
110 if (keyboard_controller) | 108 if (keyboard_controller) |
111 keyboard_controller->RemoveObserver(this); | 109 keyboard_controller->RemoveObserver(this); |
112 } | 110 } |
113 | 111 |
114 } // namespace ash | 112 } // namespace ash |
OLD | NEW |