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/magnifier/magnification_controller.h" | 5 #include "ash/magnifier/magnification_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ui/aura/event.h" | 8 #include "ui/aura/event.h" |
9 #include "ui/aura/event_filter.h" | 9 #include "ui/aura/event_filter.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
11 #include "ui/aura/shared/compound_event_filter.h" | 11 #include "ui/aura/shared/compound_event_filter.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/aura/window_property.h" | 13 #include "ui/aura/window_property.h" |
14 #include "ui/gfx/point3.h" | 14 #include "ui/gfx/point3.h" |
15 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" |
16 #include "ui/compositor/dip_util.h" | 16 #include "ui/compositor/dip_util.h" |
17 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
18 #include "ui/compositor/layer_animation_observer.h" | 18 #include "ui/compositor/layer_animation_observer.h" |
19 #include "ui/compositor/scoped_layer_animation_settings.h" | 19 #include "ui/compositor/scoped_layer_animation_settings.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 const float kMaxMagnifiedScale = 4.0f; | 23 const float kMaxMagnifiedScale = 4.0f; |
24 const float kMaxMagnifiedScaleThreshold = 4.0f; | 24 const float kMaxMagnifiedScaleThreshold = 4.0f; |
25 const float kMinMagnifiedScaleThreshold = 1.1f; | 25 const float kMinMagnifiedScaleThreshold = 1.1f; |
26 const float kNonMagnifiedScale = 1.0f; | 26 const float kNonMagnifiedScale = 1.0f; |
27 | 27 |
28 const float kInitialMagnifiedScale = 2.0f; | 28 const float kInitialMagnifiedScale = 2.0f; |
| 29 const float kScrollScaleChangeFactor = 0.05f; |
29 | 30 |
30 } // namespace | 31 } // namespace |
31 | 32 |
32 namespace ash { | 33 namespace ash { |
33 namespace internal { | 34 namespace internal { |
34 | 35 |
35 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
36 // MagnificationControllerImpl: | 37 // MagnificationControllerImpl: |
37 | 38 |
38 class MagnificationControllerImpl : virtual public MagnificationController, | 39 class MagnificationControllerImpl : virtual public MagnificationController, |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 //////////////////////////////////////////////////////////////////////////////// | 415 //////////////////////////////////////////////////////////////////////////////// |
415 // MagnificationControllerImpl: aura::EventFilter implementation | 416 // MagnificationControllerImpl: aura::EventFilter implementation |
416 | 417 |
417 bool MagnificationControllerImpl::PreHandleKeyEvent(aura::Window* target, | 418 bool MagnificationControllerImpl::PreHandleKeyEvent(aura::Window* target, |
418 aura::KeyEvent* event) { | 419 aura::KeyEvent* event) { |
419 return false; | 420 return false; |
420 } | 421 } |
421 | 422 |
422 bool MagnificationControllerImpl::PreHandleMouseEvent(aura::Window* target, | 423 bool MagnificationControllerImpl::PreHandleMouseEvent(aura::Window* target, |
423 aura::MouseEvent* event) { | 424 aura::MouseEvent* event) { |
| 425 if (event->type() == ui::ET_SCROLL && event->IsAltDown()) { |
| 426 aura::ScrollEvent* scroll_event = static_cast<aura::ScrollEvent*>(event); |
| 427 float scale = GetScale(); |
| 428 scale += scroll_event->y_offset() * kScrollScaleChangeFactor; |
| 429 SetScale(scale, true); |
| 430 return true; |
| 431 } |
| 432 |
424 if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) { | 433 if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) { |
425 aura::RootWindow* current_root = target->GetRootWindow(); | 434 aura::RootWindow* current_root = target->GetRootWindow(); |
426 gfx::Rect root_bounds = current_root->bounds(); | 435 gfx::Rect root_bounds = current_root->bounds(); |
427 | 436 |
428 if (root_bounds.Contains(event->root_location())) { | 437 if (root_bounds.Contains(event->root_location())) { |
429 if (current_root != root_window_) | 438 if (current_root != root_window_) |
430 SwitchTargetRootWindow(current_root); | 439 SwitchTargetRootWindow(current_root); |
431 | 440 |
432 OnMouseMove(event->root_location()); | 441 OnMouseMove(event->root_location()); |
433 } | 442 } |
(...skipping 17 matching lines...) Expand all Loading... |
451 //////////////////////////////////////////////////////////////////////////////// | 460 //////////////////////////////////////////////////////////////////////////////// |
452 // MagnificationController: | 461 // MagnificationController: |
453 | 462 |
454 // static | 463 // static |
455 MagnificationController* MagnificationController::CreateInstance() { | 464 MagnificationController* MagnificationController::CreateInstance() { |
456 return new MagnificationControllerImpl(); | 465 return new MagnificationControllerImpl(); |
457 } | 466 } |
458 | 467 |
459 } // namespace internal | 468 } // namespace internal |
460 } // namespace ash | 469 } // namespace ash |
OLD | NEW |