Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: ash/accelerators/accelerator_controller.cc

Issue 10915140: Add the partial screen magnifier to Chrome OS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Code review fixes Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | ash/magnifier/magnification_controller.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 return true; 234 return true;
234 } 235 }
235 236
236 bool HandleToggleRootWindowFullScreen() { 237 bool HandleToggleRootWindowFullScreen() {
237 Shell::GetPrimaryRootWindow()->ToggleFullScreen(); 238 Shell::GetPrimaryRootWindow()->ToggleFullScreen();
238 return true; 239 return true;
239 } 240 }
240 241
241 // Magnify the screen 242 // Magnify the screen
242 bool HandleMagnifyScreen(int delta_index) { 243 bool HandleMagnifyScreen(int delta_index) {
243 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and 244 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) {
244 // move the following scale control to it. 245 // TODO(yoshiki): Create the class like MagnifierStepScaleController, and
245 float scale = 246 // move the following scale control to it.
246 ash::Shell::GetInstance()->magnification_controller()->GetScale(); 247 float scale =
247 // Calculate rounded logarithm (base kMagnificationFactor) of scale. 248 ash::Shell::GetInstance()->magnification_controller()->GetScale();
248 int scale_index = 249 // Calculate rounded logarithm (base kMagnificationFactor) of scale.
249 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); 250 int scale_index =
251 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5);
250 252
251 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); 253 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index));
oshima 2012/09/13 16:35:31 I probably would create a small function to get sc
252 254
253 ash::Shell::GetInstance()->magnification_controller()-> 255 ash::Shell::GetInstance()->magnification_controller()->
254 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); 256 SetScale(std::pow(kMagnificationFactor, new_scale_index), true);
257 } else if (ash::Shell::GetInstance()
258 ->partial_magnification_controller()->IsEnabled()) {
259 float scale = delta_index > 0 ? internal::kDefaultPartialMagnifiedScale : 1;
260 ash::Shell::GetInstance()->partial_magnification_controller()->
261 SetScale(scale);
262 }
255 263
256 return true; 264 return true;
257 } 265 }
258 266
259 bool HandleMediaNextTrack() { 267 bool HandleMediaNextTrack() {
260 Shell::GetInstance()->delegate()->HandleMediaNextTrack(); 268 Shell::GetInstance()->delegate()->HandleMediaNextTrack();
261 return true; 269 return true;
262 } 270 }
263 271
264 bool HandleMediaPlayPause() { 272 bool HandleMediaPlayPause() {
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 accelerators_.insert( 801 accelerators_.insert(
794 std::make_pair(accelerator, accelerators[i].action)); 802 std::make_pair(accelerator, accelerators[i].action));
795 } 803 }
796 } 804 }
797 805
798 bool AcceleratorController::CanHandleAccelerators() const { 806 bool AcceleratorController::CanHandleAccelerators() const {
799 return true; 807 return true;
800 } 808 }
801 809
802 } // namespace ash 810 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | ash/magnifier/magnification_controller.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698