| 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 #ifndef ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ | 5 #ifndef ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ |
| 6 #define ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ | 6 #define ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ui/aura/window_observer.h" | 8 #include "ui/aura/window_observer.h" |
| 9 #include "ui/events/event_handler.h" | 9 #include "ui/events/event_handler.h" |
| 10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
| 11 #include "ui/views/widget/widget_observer.h" | 11 #include "ui/views/widget/widget_observer.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | 14 |
| 15 const float kDefaultPartialMagnifiedScale = 1.5f; | 15 const float kDefaultPartialMagnifiedScale = 1.5f; |
| 16 const float kNonPartialMagnifiedScale = 1.0f; | 16 const float kNonPartialMagnifiedScale = 1.0f; |
| 17 | 17 |
| 18 // Controls the partial screen magnifier, which is a small area of the screen | 18 // Controls the partial screen magnifier, which is a small area of the screen |
| 19 // which is zoomed in. The zoomed area follows the mouse cursor when enabled. | 19 // which is zoomed in. The zoomed area follows the mouse cursor when enabled. |
| 20 class PartialMagnificationController | 20 class PartialMagnificationController |
| 21 : public ui::EventHandler, | 21 : public ui::EventHandler, |
| 22 public aura::WindowObserver, | 22 public aura::WindowObserver, |
| 23 public views::WidgetObserver { | 23 public views::WidgetObserver { |
| 24 public: | 24 public: |
| 25 PartialMagnificationController(); | 25 PartialMagnificationController(); |
| 26 virtual ~PartialMagnificationController(); | 26 ~PartialMagnificationController() override; |
| 27 | 27 |
| 28 // Enables (or disables if |enabled| is false) partial screen magnifier | 28 // Enables (or disables if |enabled| is false) partial screen magnifier |
| 29 // feature. | 29 // feature. |
| 30 virtual void SetEnabled(bool enabled); | 30 virtual void SetEnabled(bool enabled); |
| 31 | 31 |
| 32 bool is_enabled() const { return is_enabled_; } | 32 bool is_enabled() const { return is_enabled_; } |
| 33 | 33 |
| 34 // Sets the magnification ratio. 1.0f means no magnification. | 34 // Sets the magnification ratio. 1.0f means no magnification. |
| 35 void SetScale(float scale); | 35 void SetScale(float scale); |
| 36 | 36 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 56 // Create the magnifier window. | 56 // Create the magnifier window. |
| 57 void CreateMagnifierWindow(); | 57 void CreateMagnifierWindow(); |
| 58 | 58 |
| 59 // Cleans up the window if needed. | 59 // Cleans up the window if needed. |
| 60 void CloseMagnifierWindow(); | 60 void CloseMagnifierWindow(); |
| 61 | 61 |
| 62 // Removes this as an observer of the zoom widget and the root window. | 62 // Removes this as an observer of the zoom widget and the root window. |
| 63 void RemoveZoomWidgetObservers(); | 63 void RemoveZoomWidgetObservers(); |
| 64 | 64 |
| 65 // ui::EventHandler overrides: | 65 // ui::EventHandler overrides: |
| 66 virtual void OnMouseEvent(ui::MouseEvent* event) override; | 66 void OnMouseEvent(ui::MouseEvent* event) override; |
| 67 | 67 |
| 68 // Overridden from WindowObserver: | 68 // Overridden from WindowObserver: |
| 69 virtual void OnWindowDestroying(aura::Window* window) override; | 69 void OnWindowDestroying(aura::Window* window) override; |
| 70 | 70 |
| 71 // Overridden from WidgetObserver: | 71 // Overridden from WidgetObserver: |
| 72 virtual void OnWidgetDestroying(views::Widget* widget) override; | 72 void OnWidgetDestroying(views::Widget* widget) override; |
| 73 | 73 |
| 74 // True if the magnified window is in motion of zooming or un-zooming effect. | 74 // True if the magnified window is in motion of zooming or un-zooming effect. |
| 75 // Otherwise, false. | 75 // Otherwise, false. |
| 76 bool is_on_zooming_; | 76 bool is_on_zooming_; |
| 77 | 77 |
| 78 bool is_enabled_; | 78 bool is_enabled_; |
| 79 | 79 |
| 80 // Current scale, origin (left-top) position of the magnification window. | 80 // Current scale, origin (left-top) position of the magnification window. |
| 81 float scale_; | 81 float scale_; |
| 82 gfx::Point origin_; | 82 gfx::Point origin_; |
| 83 | 83 |
| 84 views::Widget* zoom_widget_; | 84 views::Widget* zoom_widget_; |
| 85 | 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(PartialMagnificationController); | 86 DISALLOW_COPY_AND_ASSIGN(PartialMagnificationController); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace ash | 89 } // namespace ash |
| 90 | 90 |
| 91 #endif // ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ | 91 #endif // ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ |
| OLD | NEW |