From 2f9ac9582db33ca8eb53261f19486abfa98b41c1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 19 May 2014 14:10:27 +0200 Subject: [PATCH] Transformation: add one more test * Add test for a translation that makes things that are out of view bounds to become visible * Fix the "rectangles" test to handle scrolling of the view. It seems that in some cases some of the rectangles are not drawn. The gradient and bitmap tests currently have problem with view scrolling, but I'm not sure why. --- src/tests/servers/app/transformation/main.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/tests/servers/app/transformation/main.cpp b/src/tests/servers/app/transformation/main.cpp index fc22f96133..b33ab7e64a 100644 --- a/src/tests/servers/app/transformation/main.cpp +++ b/src/tests/servers/app/transformation/main.cpp @@ -237,6 +237,8 @@ public: view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); BRect rect(view->Bounds()); + rect.OffsetTo(B_ORIGIN); + rect.InsetBy(rect.Width() / 3, rect.Height() / 3); BPoint center( rect.left + rect.Width() / 2, @@ -449,6 +451,35 @@ public: }; +// #pragma mark - Clipping + + +class ClippingTest : public Test { +public: + ClippingTest() + : + Test("View bounds clipping") + { + } + + virtual void Draw(BView* view, BRect updateRect) + { + BRect r (20, 20, 50, 50); + view->SetHighColor(ui_color(B_FAILURE_COLOR)); + view->FillRect(r); + + BAffineTransform transform; + transform.TranslateBy(400, 400); + view->SetTransform(transform); + + // Make sure this rectangle is drawn, even when the original one is out + // of the view bounds (for example because of scrolling). + view->SetHighColor(ui_color(B_SUCCESS_COLOR)); + view->FillRect(r); + } +}; + + // #pragma mark - @@ -463,6 +494,7 @@ main(int argc, char** argv) window->AddTest(new BitmapTest()); window->AddTest(new GradientTest()); window->AddTest(new NestedStatesTest()); + window->AddTest(new ClippingTest()); window->SetToTest(3); window->Show();