| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 REMOTING_CLIENT_UI_DESKTOP_VIEWPORT_H_ | 5 #ifndef REMOTING_CLIENT_UI_DESKTOP_VIEWPORT_H_ |
| 6 #define REMOTING_CLIENT_UI_DESKTOP_VIEWPORT_H_ | 6 #define REMOTING_CLIENT_UI_DESKTOP_VIEWPORT_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "remoting/client/ui/view_matrix.h" | 9 #include "remoting/client/ui/view_matrix.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // Scales the desktop on the surface's reference frame at pivot point (px, py) | 47 // Scales the desktop on the surface's reference frame at pivot point (px, py) |
| 48 // by |scale|. | 48 // by |scale|. |
| 49 void ScaleDesktop(float px, float py, float scale); | 49 void ScaleDesktop(float px, float py, float scale); |
| 50 | 50 |
| 51 // Moves the viewport center by <x, y> on the desktop's coordinate. | 51 // Moves the viewport center by <x, y> on the desktop's coordinate. |
| 52 void MoveViewport(float dx, float dy); | 52 void MoveViewport(float dx, float dy); |
| 53 | 53 |
| 54 // Sets the viewport center to (x, y) on the desktop's coordinate. | 54 // Sets the viewport center to (x, y) on the desktop's coordinate. |
| 55 void SetViewportCenter(float x, float y); | 55 void SetViewportCenter(float x, float y); |
| 56 | 56 |
| 57 // Returns the current center of the viewport on the desktop's coordinate. |
| 58 ViewMatrix::Point GetViewportCenter() const; |
| 59 |
| 60 // Constrains |point| within the bounds of the desktop. Do nothing if the |
| 61 // desktop size is not set. |
| 62 ViewMatrix::Point ConstrainPointToDesktop( |
| 63 const ViewMatrix::Point& point) const; |
| 64 |
| 57 // Registers the callback to be called once the transformation has changed. | 65 // Registers the callback to be called once the transformation has changed. |
| 58 // run_immediately: If true and the viewport is ready to be used, the callback | 66 // run_immediately: If true and the viewport is ready to be used, the callback |
| 59 // will be called immedately with the transformation matrix. | 67 // will be called immedately with the transformation matrix. |
| 60 void RegisterOnTransformationChangedCallback( | 68 void RegisterOnTransformationChangedCallback( |
| 61 const TransformationCallback& callback, | 69 const TransformationCallback& callback, |
| 62 bool run_immediately); | 70 bool run_immediately); |
| 63 | 71 |
| 64 // Returns the reference to the desktop-to-surface transformation. | 72 // Returns the reference to the desktop-to-surface transformation. |
| 65 const ViewMatrix& GetTransformation() const; | 73 const ViewMatrix& GetTransformation() const; |
| 66 | 74 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 81 bool IsViewportReady() const; | 89 bool IsViewportReady() const; |
| 82 | 90 |
| 83 // Adjusts the size and position of the viewport so that the constrains always | 91 // Adjusts the size and position of the viewport so that the constrains always |
| 84 // hold, then feed the matrix to |on_transformation_changed_|. | 92 // hold, then feed the matrix to |on_transformation_changed_|. |
| 85 void UpdateViewport(); | 93 void UpdateViewport(); |
| 86 | 94 |
| 87 // Gets a rectangle of all possible positions where the viewport's center can | 95 // Gets a rectangle of all possible positions where the viewport's center can |
| 88 // locate. | 96 // locate. |
| 89 Bounds GetViewportCenterBounds() const; | 97 Bounds GetViewportCenterBounds() const; |
| 90 | 98 |
| 91 // Returns the current center of the viewport on the desktop's coordinate. | |
| 92 ViewMatrix::Point GetViewportCenter() const; | |
| 93 | |
| 94 // Translates the viewport on the desktop's reference frame by <dx, dy>, | 99 // Translates the viewport on the desktop's reference frame by <dx, dy>, |
| 95 // without calling UpdateViewport(). | 100 // without calling UpdateViewport(). |
| 96 void MoveViewportWithoutUpdate(float dx, float dy); | 101 void MoveViewportWithoutUpdate(float dx, float dy); |
| 97 | 102 |
| 98 // Moves the point inside the bounds with minimum displacement if it is out of | 103 // Moves the point inside the bounds with minimum displacement if it is out of |
| 99 // the bounds. | 104 // the bounds. |
| 100 static ViewMatrix::Point ConstrainPointToBounds( | 105 static ViewMatrix::Point ConstrainPointToBounds( |
| 101 const Bounds& bounds, | 106 const Bounds& bounds, |
| 102 const ViewMatrix::Point& point); | 107 const ViewMatrix::Point& point); |
| 103 | 108 |
| 104 ViewMatrix::Vector2D desktop_size_{0.f, 0.f}; | 109 ViewMatrix::Vector2D desktop_size_{0.f, 0.f}; |
| 105 ViewMatrix::Vector2D surface_size_{0.f, 0.f}; | 110 ViewMatrix::Vector2D surface_size_{0.f, 0.f}; |
| 106 | 111 |
| 107 ViewMatrix desktop_to_surface_transform_; | 112 ViewMatrix desktop_to_surface_transform_; |
| 108 | 113 |
| 109 TransformationCallback on_transformation_changed_; | 114 TransformationCallback on_transformation_changed_; |
| 110 | 115 |
| 111 // DesktopViewport is neither copyable nor movable. | 116 // DesktopViewport is neither copyable nor movable. |
| 112 DesktopViewport(const DesktopViewport&) = delete; | 117 DesktopViewport(const DesktopViewport&) = delete; |
| 113 DesktopViewport& operator=(const DesktopViewport&) = delete; | 118 DesktopViewport& operator=(const DesktopViewport&) = delete; |
| 114 }; | 119 }; |
| 115 | 120 |
| 116 } // namespace remoting | 121 } // namespace remoting |
| 117 #endif // REMOTING_CLIENT_UI_DESKTOP_VIEWPORT_H_ | 122 #endif // REMOTING_CLIENT_UI_DESKTOP_VIEWPORT_H_ |
| OLD | NEW |