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/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" | 5 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/common/keyboard/keyboard_ui.h" | 9 #include "ash/common/keyboard/keyboard_ui.h" |
10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 const gfx::Rect& new_bounds) { | 96 const gfx::Rect& new_bounds) { |
97 SetDrawBackgroundAsActive(!new_bounds.IsEmpty()); | 97 SetDrawBackgroundAsActive(!new_bounds.IsEmpty()); |
98 } | 98 } |
99 | 99 |
100 void VirtualKeyboardTray::OnKeyboardClosed() {} | 100 void VirtualKeyboardTray::OnKeyboardClosed() {} |
101 | 101 |
102 void VirtualKeyboardTray::SetIconBorderForShelfAlignment() { | 102 void VirtualKeyboardTray::SetIconBorderForShelfAlignment() { |
103 // Every time shelf alignment is updated, StatusAreaWidgetDelegate resets the | 103 // Every time shelf alignment is updated, StatusAreaWidgetDelegate resets the |
104 // border to a non-null border. So, we need to remove it. | 104 // border to a non-null border. So, we need to remove it. |
105 if (!ash::MaterialDesignController::IsShelfMaterial()) | 105 if (!ash::MaterialDesignController::IsShelfMaterial()) |
106 tray_container()->SetBorder(views::Border::NullBorder()); | 106 tray_container()->SetBorder(views::NullBorder()); |
107 const gfx::ImageSkia& image = icon_->GetImage(); | 107 const gfx::ImageSkia& image = icon_->GetImage(); |
108 const int size = GetTrayConstant(VIRTUAL_KEYBOARD_BUTTON_SIZE); | 108 const int size = GetTrayConstant(VIRTUAL_KEYBOARD_BUTTON_SIZE); |
109 const int vertical_padding = (size - image.height()) / 2; | 109 const int vertical_padding = (size - image.height()) / 2; |
110 int horizontal_padding = (size - image.width()) / 2; | 110 int horizontal_padding = (size - image.width()) / 2; |
111 if (!ash::MaterialDesignController::IsShelfMaterial() && | 111 if (!ash::MaterialDesignController::IsShelfMaterial() && |
112 IsHorizontalAlignment(shelf_alignment())) { | 112 IsHorizontalAlignment(shelf_alignment())) { |
113 // Square up the padding if horizontally aligned. Avoid extra padding when | 113 // Square up the padding if horizontally aligned. Avoid extra padding when |
114 // vertically aligned as the button would violate the width constraint on | 114 // vertically aligned as the button would violate the width constraint on |
115 // the shelf. | 115 // the shelf. |
116 horizontal_padding += std::max(0, vertical_padding - horizontal_padding); | 116 horizontal_padding += std::max(0, vertical_padding - horizontal_padding); |
117 } | 117 } |
118 icon_->SetBorder(views::Border::CreateEmptyBorder( | 118 icon_->SetBorder(views::CreateEmptyBorder( |
119 gfx::Insets(vertical_padding, horizontal_padding))); | 119 gfx::Insets(vertical_padding, horizontal_padding))); |
120 } | 120 } |
121 | 121 |
122 void VirtualKeyboardTray::ObserveKeyboardController() { | 122 void VirtualKeyboardTray::ObserveKeyboardController() { |
123 keyboard::KeyboardController* keyboard_controller = | 123 keyboard::KeyboardController* keyboard_controller = |
124 keyboard::KeyboardController::GetInstance(); | 124 keyboard::KeyboardController::GetInstance(); |
125 if (keyboard_controller) | 125 if (keyboard_controller) |
126 keyboard_controller->AddObserver(this); | 126 keyboard_controller->AddObserver(this); |
127 } | 127 } |
128 | 128 |
129 void VirtualKeyboardTray::UnobserveKeyboardController() { | 129 void VirtualKeyboardTray::UnobserveKeyboardController() { |
130 keyboard::KeyboardController* keyboard_controller = | 130 keyboard::KeyboardController* keyboard_controller = |
131 keyboard::KeyboardController::GetInstance(); | 131 keyboard::KeyboardController::GetInstance(); |
132 if (keyboard_controller) | 132 if (keyboard_controller) |
133 keyboard_controller->RemoveObserver(this); | 133 keyboard_controller->RemoveObserver(this); |
134 } | 134 } |
135 | 135 |
136 } // namespace ash | 136 } // namespace ash |
OLD | NEW |