diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-11 21:42:12 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-11 21:42:12 +0000 |
commit | f03bb566e25ace918f8fdda3cb8426626a00894c (patch) | |
tree | 6955fcccb33cdc4a3bb9a38a269351f98342ce24 /include/views | |
parent | 83ab49556ffc83fd3b2c1142db264362d21e6b19 (diff) |
land http://codereview.appspot.com/5244058/ - add matrix to SkView
git-svn-id: http://skia.googlecode.com/svn/trunk@2670 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/views')
-rw-r--r-- | include/views/SkView.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/views/SkView.h b/include/views/SkView.h index 5cb6e4aff5..a5349c21ba 100644 --- a/include/views/SkView.h +++ b/include/views/SkView.h @@ -14,6 +14,7 @@ #include "SkRect.h" #include "SkDOM.h" #include "SkTDict.h" +#include "SkMatrix.h" class SkCanvas; class SkLayerView; @@ -80,6 +81,12 @@ public: /** Return a rectangle set to [0, 0, width, height] */ void getLocalBounds(SkRect* bounds) const; + /** Loc - the view's offset with respect to its parent in its view hiearchy. + NOTE: For more complex transforms, use Local Matrix. The tranformations + are applied in the following order: + canvas->translate(fLoc.fX, fLoc.fY); + canvas->concat(fMatrix); + */ /** Return the view's left edge */ SkScalar locX() const { return fLoc.fX; } /** Return the view's top edge */ @@ -89,6 +96,18 @@ public: void setLoc(const SkPoint& loc) { this->setLoc(loc.fX, loc.fY); } void setLocX(SkScalar x) { this->setLoc(x, fLoc.fY); } void setLocY(SkScalar y) { this->setLoc(fLoc.fX, y); } + + /** Local Matrix - matrix used to tranform the view with respect to its + parent in its view hiearchy. Use setLocalMatrix to apply matrix + transformations to the current view and in turn affect its children. + NOTE: For simple offsets, use Loc. The transformations are applied in + the following order: + canvas->translate(fLoc.fX, fLoc.fY); + canvas->concat(fMatrix); + */ + const SkMatrix& getLocalMatrix() const { return fMatrix; } + void setLocalMatrix(const SkMatrix& matrix); + /** Offset (move) the view by the specified dx and dy. This does not affect the view's size */ void offset(SkScalar dx, SkScalar dy); @@ -338,6 +357,7 @@ protected: private: SkScalar fWidth, fHeight; + SkMatrix fMatrix; SkPoint fLoc; SkView* fParent; SkView* fFirstChild; @@ -354,6 +374,8 @@ private: bool setFocusView(SkView* fvOrNull); SkView* acceptFocus(FocusDirection); void detachFromParent_NoLayout(); + /** Compute the matrix to transform view-local coordinates into global ones */ + void localToGlobal(SkMatrix* matrix) const; }; #endif |