[email protected] | 36df22b | 2011-02-24 21:47:56 | [diff] [blame^] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_GFX_TRANSFORM_H_ |
| 6 | #define UI_GFX_TRANSFORM_H_ |
| 7 | #pragma once |
| 8 | |
| 9 | namespace gfx { |
| 10 | class Point; |
| 11 | class Rect; |
| 12 | } |
| 13 | |
| 14 | namespace ui { |
| 15 | |
| 16 | // Transformation interface. |
| 17 | // Classes implement this interface to apply transformations (e.g. rotation, |
| 18 | // scaling etc.) on UI components. |
| 19 | class Transform { |
| 20 | public: |
| 21 | // Create an object that implements this interface (e.g. using skia |
| 22 | // transformation matrices). |
| 23 | static Transform* Create(); |
| 24 | |
| 25 | // Set the rotation of the transformation. |
| 26 | virtual void SetRotate(float degree) = 0; |
| 27 | |
| 28 | // Set the scaling parameters. |
| 29 | virtual void SetScaleX(float x) = 0; |
| 30 | virtual void SetScaleY(float y) = 0; |
| 31 | virtual void SetScale(float x, float y) = 0; |
| 32 | |
| 33 | // Set the translation parameters. |
| 34 | virtual void SetTranslateX(float x) = 0; |
| 35 | virtual void SetTranslateY(float y) = 0; |
| 36 | virtual void SetTranslate(float x, float y) = 0; |
| 37 | |
| 38 | // Apply rotation on the current transformation. |
| 39 | virtual void ConcatRotate(float degree) = 0; |
| 40 | |
| 41 | // Apply scaling on current transform. |
| 42 | virtual void ConcatScale(float x, float y) = 0; |
| 43 | |
| 44 | // Apply translation on current transform. |
| 45 | virtual void ConcatTranslate(float x, float y) = 0; |
| 46 | |
| 47 | // Apply a transformation on the current transformation |
| 48 | // (i.e. 'this = this * transform;') |
| 49 | virtual bool ConcatTransform(const Transform& transform) = 0; |
| 50 | |
| 51 | // Does the transformation change anything? |
| 52 | virtual bool HasChange() const = 0; |
| 53 | |
| 54 | // Apply the transformation on the point. |
| 55 | virtual bool TransformPoint(gfx::Point* point) = 0; |
| 56 | |
| 57 | // Apply the reverse transformation on the point. |
| 58 | virtual bool TransformPointReverse(gfx::Point* point) = 0; |
| 59 | |
| 60 | // Apply transformatino on the rectangle. |
| 61 | virtual bool TransformRect(gfx::Rect* rect) = 0; |
| 62 | }; |
| 63 | |
| 64 | } // namespace ui |
| 65 | |
| 66 | #endif // UI_GFX_TRANSFORM_H_ |