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.
This commit is contained in:
Adrien Destugues
2014-05-19 14:18:57 +02:00
parent 79eb23a82d
commit 2f9ac9582d
@@ -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();