diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 22:53:19 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 22:53:19 +0000 |
commit | eb93b619bebd38510f21d3f04d8f2641bf71af35 (patch) | |
tree | 8ddd55e7baddb7588074308b6ad6fc7504e7b25f /views/view_unittest.cc | |
parent | 85c6e92ecdd8a882377a460f8f2cac1b4ef69c51 (diff) | |
download | chromium_src-eb93b619bebd38510f21d3f04d8f2641bf71af35.zip chromium_src-eb93b619bebd38510f21d3f04d8f2641bf71af35.tar.gz chromium_src-eb93b619bebd38510f21d3f04d8f2641bf71af35.tar.bz2 |
views transformation: First cut.
This is a first cut at the transformable views. Skia transformation matrices are used to apply transformation (rotate, scale, translation). Support for clipping is also added (but not through the matrix). Currently, the transformation is applied only for painting. A future CL will apply the transformation for various events.
BUG=none
TEST=ViewTest.TransformPaint
Review URL: http://codereview.chromium.org/6500008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/view_unittest.cc')
-rw-r--r-- | views/view_unittest.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/views/view_unittest.cc b/views/view_unittest.cc index 8733ffe..a8ee7b6 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -1514,3 +1514,46 @@ TEST_F(ViewTest, ChangeNativeViewHierarchyChangeHierarchy) { test.CheckChangingHierarhy(); #endif } + +//////////////////////////////////////////////////////////////////////////////// +// Transformations +//////////////////////////////////////////////////////////////////////////////// +TEST_F(ViewTest, TransformPaint) { + TestView* v1 = new TestView(); + v1->SetBounds(0, 0, 500, 300); + + TestView* v2 = new TestView(); + v2->SetBounds(100, 100, 200, 100); + + Widget* widget = CreateWidget(); +#if defined(OS_WIN) + WidgetWin* window_win = static_cast<WidgetWin*>(widget); + window_win->set_window_style(WS_OVERLAPPEDWINDOW); + window_win->Init(NULL, gfx::Rect(50, 50, 650, 650)); +#endif + RootView* root = widget->GetRootView(); + + root->AddChildView(v1); + v1->AddChildView(v2); + + // At this moment, |v2| occupies (100, 100) to (300, 200) in |root|. + root->ClearPaintRect(); + v2->SchedulePaint(); + + gfx::Rect rect = root->GetScheduledPaintRect(); + EXPECT_EQ(gfx::Rect(100, 100, 200, 100), rect); + + // Rotate |v1| counter-clockwise. + v1->SetRotation(-90.0); + v1->SetTranslateY(500); + + // |v2| now occupies (100, 200) to (200, 400) in |root|. + + root->ClearPaintRect(); + v2->SchedulePaint(); + + rect = root->GetScheduledPaintRect(); + EXPECT_EQ(gfx::Rect(100, 200, 100, 200), rect); + + widget->CloseNow(); +} |