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 "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 const float kMaxMagnifiedScaleThreshold = 4.0f; | 26 const float kMaxMagnifiedScaleThreshold = 4.0f; |
27 const float kMinMagnifiedScaleThreshold = 1.1f; | 27 const float kMinMagnifiedScaleThreshold = 1.1f; |
28 const float kNonMagnifiedScale = 1.0f; | 28 const float kNonMagnifiedScale = 1.0f; |
29 | 29 |
30 const float kInitialMagnifiedScale = 2.0f; | 30 const float kInitialMagnifiedScale = 2.0f; |
31 const float kScrollScaleChangeFactor = 0.05f; | 31 const float kScrollScaleChangeFactor = 0.05f; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 namespace ash { | 35 namespace ash { |
36 namespace internal { | |
37 | 36 |
38 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
39 // MagnificationControllerImpl: | 38 // MagnificationControllerImpl: |
40 | 39 |
41 class MagnificationControllerImpl : virtual public MagnificationController, | 40 class MagnificationControllerImpl : virtual public MagnificationController, |
42 public ui::EventHandler, | 41 public ui::EventHandler, |
43 public ui::ImplicitAnimationObserver { | 42 public ui::ImplicitAnimationObserver { |
44 public: | 43 public: |
45 MagnificationControllerImpl(); | 44 MagnificationControllerImpl(); |
46 virtual ~MagnificationControllerImpl(); | 45 virtual ~MagnificationControllerImpl(); |
47 | 46 |
48 // MagnificationController overrides: | 47 // MagnificationController overrides: |
49 virtual void SetEnabled(bool enabled) OVERRIDE; | 48 virtual void SetEnabled(bool enabled) OVERRIDE; |
| 49 virtual bool IsEnabled() const OVERRIDE; |
50 virtual void SetScale(float scale, bool animate) OVERRIDE; | 50 virtual void SetScale(float scale, bool animate) OVERRIDE; |
51 virtual float GetScale() const OVERRIDE { return scale_; } | 51 virtual float GetScale() const OVERRIDE { return scale_; } |
52 virtual void MoveWindow(int x, int y, bool animate) OVERRIDE; | 52 virtual void MoveWindow(int x, int y, bool animate) OVERRIDE; |
53 virtual void MoveWindow(const gfx::Point& point, bool animate) OVERRIDE; | 53 virtual void MoveWindow(const gfx::Point& point, bool animate) OVERRIDE; |
54 virtual gfx::Point GetWindowPosition() const OVERRIDE { return origin_; } | 54 virtual gfx::Point GetWindowPosition() const OVERRIDE { return origin_; } |
55 virtual void EnsureRectIsVisible(const gfx::Rect& rect, | 55 virtual void EnsureRectIsVisible(const gfx::Rect& rect, |
56 bool animate) OVERRIDE; | 56 bool animate) OVERRIDE; |
57 virtual void EnsurePointIsVisible(const gfx::Point& point, | 57 virtual void EnsurePointIsVisible(const gfx::Point& point, |
58 bool animate) OVERRIDE; | 58 bool animate) OVERRIDE; |
59 | 59 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 scale = GetDefaultZoomScale(); | 436 scale = GetDefaultZoomScale(); |
437 ValidateScale(&scale); | 437 ValidateScale(&scale); |
438 RedrawKeepingMousePosition(scale, true); | 438 RedrawKeepingMousePosition(scale, true); |
439 is_enabled_ = enabled; | 439 is_enabled_ = enabled; |
440 } else { | 440 } else { |
441 RedrawKeepingMousePosition(kNonMagnifiedScale, true); | 441 RedrawKeepingMousePosition(kNonMagnifiedScale, true); |
442 is_enabled_ = enabled; | 442 is_enabled_ = enabled; |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
| 446 bool MagnificationControllerImpl::IsEnabled() const { |
| 447 return is_enabled_; |
| 448 } |
| 449 |
446 //////////////////////////////////////////////////////////////////////////////// | 450 //////////////////////////////////////////////////////////////////////////////// |
447 // MagnificationControllerImpl: aura::EventFilter implementation | 451 // MagnificationControllerImpl: aura::EventFilter implementation |
448 | 452 |
449 ui::EventResult MagnificationControllerImpl::OnKeyEvent(ui::KeyEvent* event) { | 453 ui::EventResult MagnificationControllerImpl::OnKeyEvent(ui::KeyEvent* event) { |
450 return ui::ER_UNHANDLED; | 454 return ui::ER_UNHANDLED; |
451 } | 455 } |
452 | 456 |
453 ui::EventResult MagnificationControllerImpl::OnMouseEvent( | 457 ui::EventResult MagnificationControllerImpl::OnMouseEvent( |
454 ui::MouseEvent* event) { | 458 ui::MouseEvent* event) { |
455 if (event->IsAltDown() && event->IsControlDown()) { | 459 if (event->IsAltDown() && event->IsControlDown()) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 503 } |
500 | 504 |
501 //////////////////////////////////////////////////////////////////////////////// | 505 //////////////////////////////////////////////////////////////////////////////// |
502 // MagnificationController: | 506 // MagnificationController: |
503 | 507 |
504 // static | 508 // static |
505 MagnificationController* MagnificationController::CreateInstance() { | 509 MagnificationController* MagnificationController::CreateInstance() { |
506 return new MagnificationControllerImpl(); | 510 return new MagnificationControllerImpl(); |
507 } | 511 } |
508 | 512 |
509 } // namespace internal | |
510 } // namespace ash | 513 } // namespace ash |
OLD | NEW |