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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return true; | 251 return true; |
251 } | 252 } |
252 | 253 |
253 bool HandleToggleRootWindowFullScreen() { | 254 bool HandleToggleRootWindowFullScreen() { |
254 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); | 255 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); |
255 return true; | 256 return true; |
256 } | 257 } |
257 | 258 |
258 // Magnify the screen | 259 // Magnify the screen |
259 bool HandleMagnifyScreen(int delta_index) { | 260 bool HandleMagnifyScreen(int delta_index) { |
260 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and | 261 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { |
261 // move the following scale control to it. | 262 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and |
262 float scale = | 263 // move the following scale control to it. |
263 ash::Shell::GetInstance()->magnification_controller()->GetScale(); | 264 float scale = |
264 // Calculate rounded logarithm (base kMagnificationFactor) of scale. | 265 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
265 int scale_index = | 266 // Calculate rounded logarithm (base kMagnificationFactor) of scale. |
266 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); | 267 int scale_index = |
| 268 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); |
267 | 269 |
268 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); | 270 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
269 | 271 |
270 ash::Shell::GetInstance()->magnification_controller()-> | 272 ash::Shell::GetInstance()->magnification_controller()-> |
271 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); | 273 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); |
| 274 } else if (ash::Shell::GetInstance() |
| 275 ->partial_magnification_controller()->IsEnabled()) { |
| 276 float scale = delta_index > 0 ? internal::kDefaultPartialMagnifiedScale : 1; |
| 277 ash::Shell::GetInstance()->partial_magnification_controller()-> |
| 278 SetScale(scale); |
| 279 } |
272 | 280 |
273 return true; | 281 return true; |
274 } | 282 } |
275 | 283 |
276 bool HandleMediaNextTrack() { | 284 bool HandleMediaNextTrack() { |
277 Shell::GetInstance()->delegate()->HandleMediaNextTrack(); | 285 Shell::GetInstance()->delegate()->HandleMediaNextTrack(); |
278 return true; | 286 return true; |
279 } | 287 } |
280 | 288 |
281 bool HandleMediaPlayPause() { | 289 bool HandleMediaPlayPause() { |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 accelerators_.insert( | 890 accelerators_.insert( |
883 std::make_pair(accelerator, accelerators[i].action)); | 891 std::make_pair(accelerator, accelerators[i].action)); |
884 } | 892 } |
885 } | 893 } |
886 | 894 |
887 bool AcceleratorController::CanHandleAccelerators() const { | 895 bool AcceleratorController::CanHandleAccelerators() const { |
888 return true; | 896 return true; |
889 } | 897 } |
890 | 898 |
891 } // namespace ash | 899 } // namespace ash |
OLD | NEW |