| 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; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace ash { | 20 namespace ash { |
| 19 namespace internal { | 21 namespace internal { |
| 20 | 22 |
| 21 class MagnificationController { | 23 class MagnificationController { |
| 22 public: | 24 public: |
| 23 MagnificationController(); | |
| 24 | |
| 25 virtual ~MagnificationController() {} | 25 virtual ~MagnificationController() {} |
| 26 | 26 |
| 27 // Creates a new MagnificationController. The caller takes ownership of the |
| 28 // returned object. |
| 29 static MagnificationController* CreateInstance(); |
| 30 |
| 27 // Sets the magnification ratio. 1.0f means no magnification. | 31 // Sets the magnification ratio. 1.0f means no magnification. |
| 28 void SetScale(float scale); | 32 virtual void SetScale(float scale, bool animate) = 0; |
| 29 // Returns the current magnification ratio. | 33 // Returns the current magnification ratio. |
| 30 float GetScale() const { return scale_; } | 34 virtual float GetScale() const = 0; |
| 31 | 35 |
| 32 // Set the top-left point of the magnification window. | 36 // Set the top-left point of the magnification window. |
| 33 void MoveWindow(int x, int y); | 37 virtual void MoveWindow(int x, int y, bool animate) = 0; |
| 34 void MoveWindow(const gfx::Point& point); | 38 virtual void MoveWindow(const gfx::Point& point, bool animate) = 0; |
| 35 // Returns the current top-left point of the magnification window. | 39 // Returns the current top-left point of the magnification window. |
| 36 gfx::Point GetWindowPosition() const { return gfx::Point(x_, y_); } | 40 virtual gfx::Point GetWindowPosition() const = 0; |
| 37 | 41 |
| 38 // Ensures that the given point/rect is inside the magnification window. If | 42 // 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. | 43 // not, the controller moves the window to contain the given point/rect. |
| 40 void EnsureShowRect(const gfx::Rect& rect); | 44 virtual void EnsureRectIsVisible(const gfx::Rect& rect, bool animate) = 0; |
| 41 void EnsureShowPoint(const gfx::Point& point, bool animation); | 45 virtual void EnsurePointIsVisible(const gfx::Point& point, bool animate) = 0; |
| 42 | 46 |
| 43 private: | 47 protected: |
| 44 aura::RootWindow* root_window_; | 48 MagnificationController() {} |
| 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); | |
| 59 }; | 49 }; |
| 60 | 50 |
| 61 } // namespace internal | 51 } // namespace internal |
| 62 } // namespace ash | 52 } // namespace ash |
| 63 | 53 |
| 64 #endif // ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_ | 54 #endif // ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_ |
| OLD | NEW |