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 <iostream> | 9 #include <iostream> |
10 #include <string> | 10 #include <string> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #if defined(OS_CHROMEOS) | 66 #if defined(OS_CHROMEOS) |
67 #include "ash/system/chromeos/keyboard_brightness_controller.h" | 67 #include "ash/system/chromeos/keyboard_brightness_controller.h" |
68 #include "base/chromeos/chromeos_version.h" | 68 #include "base/chromeos/chromeos_version.h" |
69 #endif // defined(OS_CHROMEOS) | 69 #endif // defined(OS_CHROMEOS) |
70 | 70 |
71 namespace ash { | 71 namespace ash { |
72 namespace { | 72 namespace { |
73 | 73 |
74 using internal::DisplayInfo; | 74 using internal::DisplayInfo; |
75 | 75 |
76 // Factor of magnification scale. For example, when this value is 1.189, scale | |
77 // value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ... | |
78 // Note: this value is 2.0 ^ (1 / 4). | |
79 const float kMagnificationFactor = 1.18920712f; | |
80 | |
81 bool DebugShortcutsEnabled() { | 76 bool DebugShortcutsEnabled() { |
82 #if defined(NDEBUG) | 77 #if defined(NDEBUG) |
83 return CommandLine::ForCurrentProcess()->HasSwitch( | 78 return CommandLine::ForCurrentProcess()->HasSwitch( |
84 switches::kAshDebugShortcuts); | 79 switches::kAshDebugShortcuts); |
85 #else | 80 #else |
86 return true; | 81 return true; |
87 #endif | 82 #endif |
88 } | 83 } |
89 | 84 |
90 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, | 85 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 216 } |
222 | 217 |
223 bool HandleToggleRootWindowFullScreen() { | 218 bool HandleToggleRootWindowFullScreen() { |
224 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); | 219 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); |
225 return true; | 220 return true; |
226 } | 221 } |
227 | 222 |
228 // Magnify the screen | 223 // Magnify the screen |
229 bool HandleMagnifyScreen(int delta_index) { | 224 bool HandleMagnifyScreen(int delta_index) { |
230 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { | 225 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { |
231 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and | 226 // TODO(yoshiki): Move the following logic to MagnificationController. |
232 // move the following scale control to it. | |
233 float scale = | 227 float scale = |
234 ash::Shell::GetInstance()->magnification_controller()->GetScale(); | 228 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
235 // Calculate rounded logarithm (base kMagnificationFactor) of scale. | 229 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale. |
236 int scale_index = | 230 int scale_index = |
237 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); | 231 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5); |
238 | 232 |
239 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); | 233 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
240 | 234 |
241 ash::Shell::GetInstance()->magnification_controller()-> | 235 ash::Shell::GetInstance()->magnification_controller()-> |
242 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); | 236 SetScale(std::pow(kMagnificationScaleFactor, new_scale_index), true); |
243 } else if (ash::Shell::GetInstance()-> | 237 } else if (ash::Shell::GetInstance()-> |
244 partial_magnification_controller()->is_enabled()) { | 238 partial_magnification_controller()->is_enabled()) { |
245 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1; | 239 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1; |
246 ash::Shell::GetInstance()->partial_magnification_controller()-> | 240 ash::Shell::GetInstance()->partial_magnification_controller()-> |
247 SetScale(scale); | 241 SetScale(scale); |
248 } | 242 } |
249 | 243 |
250 return true; | 244 return true; |
251 } | 245 } |
252 | 246 |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 keyboard_brightness_control_delegate) { | 906 keyboard_brightness_control_delegate) { |
913 keyboard_brightness_control_delegate_ = | 907 keyboard_brightness_control_delegate_ = |
914 keyboard_brightness_control_delegate.Pass(); | 908 keyboard_brightness_control_delegate.Pass(); |
915 } | 909 } |
916 | 910 |
917 bool AcceleratorController::CanHandleAccelerators() const { | 911 bool AcceleratorController::CanHandleAccelerators() const { |
918 return true; | 912 return true; |
919 } | 913 } |
920 | 914 |
921 } // namespace ash | 915 } // namespace ash |
OLD | NEW |