OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ash/accelerators/accelerator_table.h" | 11 #include "ash/accelerators/accelerator_table.h" |
12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
13 #include "ash/caps_lock_delegate.h" | 13 #include "ash/caps_lock_delegate.h" |
14 #include "ash/desktop_background/desktop_background_controller.h" | 14 #include "ash/desktop_background/desktop_background_controller.h" |
15 #include "ash/display/display_controller.h" | 15 #include "ash/display/display_controller.h" |
16 #include "ash/display/multi_display_manager.h" | 16 #include "ash/display/multi_display_manager.h" |
17 #include "ash/focus_cycler.h" | 17 #include "ash/focus_cycler.h" |
18 #include "ash/ime_control_delegate.h" | 18 #include "ash/ime_control_delegate.h" |
19 #include "ash/launcher/launcher.h" | 19 #include "ash/launcher/launcher.h" |
20 #include "ash/launcher/launcher_delegate.h" | 20 #include "ash/launcher/launcher_delegate.h" |
21 #include "ash/launcher/launcher_model.h" | 21 #include "ash/launcher/launcher_model.h" |
22 #include "ash/magnifier/magnification_controller.h" | 22 #include "ash/magnifier/magnification_controller.h" |
| 23 #include "ash/magnifier/partial_magnification_controller.h" |
23 #include "ash/root_window_controller.h" | 24 #include "ash/root_window_controller.h" |
24 #include "ash/rotator/screen_rotation.h" | 25 #include "ash/rotator/screen_rotation.h" |
25 #include "ash/screen_ash.h" | 26 #include "ash/screen_ash.h" |
26 #include "ash/screenshot_delegate.h" | 27 #include "ash/screenshot_delegate.h" |
27 #include "ash/shell.h" | 28 #include "ash/shell.h" |
28 #include "ash/shell_delegate.h" | 29 #include "ash/shell_delegate.h" |
29 #include "ash/shell_window_ids.h" | 30 #include "ash/shell_window_ids.h" |
30 #include "ash/system/brightness/brightness_control_delegate.h" | 31 #include "ash/system/brightness/brightness_control_delegate.h" |
31 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" | 32 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" |
32 #include "ash/system/tray/system_tray.h" | 33 #include "ash/system/tray/system_tray.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return true; | 245 return true; |
245 } | 246 } |
246 | 247 |
247 bool HandleToggleRootWindowFullScreen() { | 248 bool HandleToggleRootWindowFullScreen() { |
248 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); | 249 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); |
249 return true; | 250 return true; |
250 } | 251 } |
251 | 252 |
252 // Magnify the screen | 253 // Magnify the screen |
253 bool HandleMagnifyScreen(int delta_index) { | 254 bool HandleMagnifyScreen(int delta_index) { |
254 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and | 255 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { |
255 // move the following scale control to it. | 256 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and |
256 float scale = | 257 // move the following scale control to it. |
257 ash::Shell::GetInstance()->magnification_controller()->GetScale(); | 258 float scale = |
258 // Calculate rounded logarithm (base kMagnificationFactor) of scale. | 259 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
259 int scale_index = | 260 // Calculate rounded logarithm (base kMagnificationFactor) of scale. |
260 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); | 261 int scale_index = |
| 262 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); |
261 | 263 |
262 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); | 264 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
263 | 265 |
264 ash::Shell::GetInstance()->magnification_controller()-> | 266 ash::Shell::GetInstance()->magnification_controller()-> |
265 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); | 267 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); |
| 268 } else if (ash::Shell::GetInstance() |
| 269 ->partial_magnification_controller()->IsEnabled()) { |
| 270 float scale = delta_index > 0 ? internal::kDefaultPartialMagnifiedScale : 1; |
| 271 ash::Shell::GetInstance()->partial_magnification_controller()-> |
| 272 SetScale(scale); |
| 273 } |
266 | 274 |
267 return true; | 275 return true; |
268 } | 276 } |
269 | 277 |
270 bool HandleMediaNextTrack() { | 278 bool HandleMediaNextTrack() { |
271 Shell::GetInstance()->delegate()->HandleMediaNextTrack(); | 279 Shell::GetInstance()->delegate()->HandleMediaNextTrack(); |
272 return true; | 280 return true; |
273 } | 281 } |
274 | 282 |
275 bool HandleMediaPlayPause() { | 283 bool HandleMediaPlayPause() { |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 accelerators_.insert( | 896 accelerators_.insert( |
889 std::make_pair(accelerator, accelerators[i].action)); | 897 std::make_pair(accelerator, accelerators[i].action)); |
890 } | 898 } |
891 } | 899 } |
892 | 900 |
893 bool AcceleratorController::CanHandleAccelerators() const { | 901 bool AcceleratorController::CanHandleAccelerators() const { |
894 return true; | 902 return true; |
895 } | 903 } |
896 | 904 |
897 } // namespace ash | 905 } // namespace ash |
OLD | NEW |