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/screenshot_delegate.h" | 26 #include "ash/screenshot_delegate.h" |
26 #include "ash/shell.h" | 27 #include "ash/shell.h" |
27 #include "ash/shell_delegate.h" | 28 #include "ash/shell_delegate.h" |
28 #include "ash/shell_window_ids.h" | 29 #include "ash/shell_window_ids.h" |
29 #include "ash/system/brightness/brightness_control_delegate.h" | 30 #include "ash/system/brightness/brightness_control_delegate.h" |
30 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" | 31 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" |
31 #include "ash/system/tray/system_tray.h" | 32 #include "ash/system/tray/system_tray.h" |
32 #include "ash/system/tray/system_tray_delegate.h" | 33 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return true; | 219 return true; |
219 } | 220 } |
220 | 221 |
221 bool HandleToggleRootWindowFullScreen() { | 222 bool HandleToggleRootWindowFullScreen() { |
222 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); | 223 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); |
223 return true; | 224 return true; |
224 } | 225 } |
225 | 226 |
226 // Magnify the screen | 227 // Magnify the screen |
227 bool HandleMagnifyScreen(int delta_index) { | 228 bool HandleMagnifyScreen(int delta_index) { |
228 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and | 229 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { |
229 // move the following scale control to it. | 230 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and |
230 float scale = | 231 // move the following scale control to it. |
231 ash::Shell::GetInstance()->magnification_controller()->GetScale(); | 232 float scale = |
232 // Calculate rounded logarithm (base kMagnificationFactor) of scale. | 233 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
233 int scale_index = | 234 // Calculate rounded logarithm (base kMagnificationFactor) of scale. |
234 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); | 235 int scale_index = |
| 236 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); |
235 | 237 |
236 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); | 238 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
237 | 239 |
238 ash::Shell::GetInstance()->magnification_controller()-> | 240 ash::Shell::GetInstance()->magnification_controller()-> |
239 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); | 241 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); |
| 242 } else if (ash::Shell::GetInstance() |
| 243 ->partial_magnification_controller()->IsEnabled()) { |
| 244 float scale = delta_index > 0 ? internal::kDefaultPartialMagnifiedScale : 1; |
| 245 ash::Shell::GetInstance()->partial_magnification_controller()-> |
| 246 SetScale(scale); |
| 247 } |
240 | 248 |
241 return true; | 249 return true; |
242 } | 250 } |
243 | 251 |
244 bool HandleMediaNextTrack() { | 252 bool HandleMediaNextTrack() { |
245 Shell::GetInstance()->delegate()->HandleMediaNextTrack(); | 253 Shell::GetInstance()->delegate()->HandleMediaNextTrack(); |
246 return true; | 254 return true; |
247 } | 255 } |
248 | 256 |
249 bool HandleMediaPlayPause() { | 257 bool HandleMediaPlayPause() { |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 accelerators_.insert( | 788 accelerators_.insert( |
781 std::make_pair(accelerator, accelerators[i].action)); | 789 std::make_pair(accelerator, accelerators[i].action)); |
782 } | 790 } |
783 } | 791 } |
784 | 792 |
785 bool AcceleratorController::CanHandleAccelerators() const { | 793 bool AcceleratorController::CanHandleAccelerators() const { |
786 return true; | 794 return true; |
787 } | 795 } |
788 | 796 |
789 } // namespace ash | 797 } // namespace ash |
OLD | NEW |