| 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_MAGNIFICATION_CONTROLLER_H_ | 5 #ifndef ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_ |
| 6 #define ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_ | 6 #define ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/aura/event_filter.h" |
| 11 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 12 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 13 | 15 |
| 14 namespace aura { | 16 namespace aura { |
| 15 class RootWindow; | 17 class RootWindow; |
| 18 class EventFilter; |
| 16 } | 19 } |
| 17 | 20 |
| 18 namespace ash { | 21 namespace ash { |
| 19 namespace internal { | 22 namespace internal { |
| 20 | 23 |
| 21 class MagnificationController { | 24 class MagnificationController : public aura::EventFilter { |
| 22 public: | 25 public: |
| 23 MagnificationController(); | 26 MagnificationController() {} |
| 24 | 27 |
| 25 virtual ~MagnificationController() {} | 28 static MagnificationController* CreateInstance(); |
| 26 | 29 |
| 27 // Sets the magnification ratio. 1.0f means no magnification. | 30 // Sets the magnification ratio. 1.0f means no magnification. |
| 28 void SetScale(float scale); | 31 virtual void SetScale(float scale, bool animation) = 0; |
| 29 // Returns the current magnification ratio. | 32 // Returns the current magnification ratio. |
| 30 float GetScale() const { return scale_; } | 33 virtual float GetScale() const = 0; |
| 31 | 34 |
| 32 // Set the top-left point of the magnification window. | 35 // Set the top-left point of the magnification window. |
| 33 void MoveWindow(int x, int y); | 36 virtual void MoveWindow(int x, int y, bool animation) = 0; |
| 34 void MoveWindow(const gfx::Point& point); | 37 virtual void MoveWindow(const gfx::Point& point, bool animation) = 0; |
| 35 // Returns the current top-left point of the magnification window. | 38 // Returns the current top-left point of the magnification window. |
| 36 gfx::Point GetWindowPosition() const { return gfx::Point(x_, y_); } | 39 virtual gfx::Point GetWindowPosition() const = 0; |
| 37 | 40 |
| 38 // Ensures that the given point/rect is inside the magnification window. If | 41 // Ensures that the given point/rect is inside the magnification window. If |
| 39 // not, the controller moves the window to contain the given point/rect. | 42 // not, the controller moves the window to contain the given point/rect. |
| 40 void EnsureShowRect(const gfx::Rect& rect); | 43 virtual void EnsureShowRect(const gfx::Rect& rect, bool animation) = 0; |
| 41 void EnsureShowPoint(const gfx::Point& point, bool animation); | 44 virtual void EnsureShowPoint(const gfx::Point& point, bool animation) = 0; |
| 42 | 45 |
| 43 private: | 46 private: |
| 44 aura::RootWindow* root_window_; | |
| 45 | |
| 46 // Current scale, position of the magnification window. | |
| 47 float scale_; | |
| 48 int x_; | |
| 49 int y_; | |
| 50 | |
| 51 // Returns the rect of the magnification window. | |
| 52 gfx::Rect GetWindowRect(); | |
| 53 // Moves the magnification window to new scale and position. This method | |
| 54 // should be called internally just after the scale and/or the position are | |
| 55 // changed. | |
| 56 void RedrawScreen(bool animation); | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(MagnificationController); | 47 DISALLOW_COPY_AND_ASSIGN(MagnificationController); |
| 59 }; | 48 }; |
| 60 | 49 |
| 61 } // namespace internal | 50 } // namespace internal |
| 62 } // namespace ash | 51 } // namespace ash |
| 63 | 52 |
| 64 #endif // ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_ | 53 #endif // ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_ |
| OLD | NEW |