public void RowClippedPaint() { var styles = new AssembledStyles(); var box1 = new FgBlockBox(styles, Color.Red, 36000, 72000); var box2 = new FgBlockBox(styles, Color.Blue, 18000, 108000); var box3 = new FgBlockBox(styles, Color.Orange, 18000, 72000); var box4 = new FgBlockBox(styles, Color.Orange, 18000, 72000); var widths = new FixedColumnWidths(new[] { 34, 67, 99, 46 }); var row1 = new RowBox(styles, widths, false); row1.AddBox(box1); row1.AddBox(box2); row1.AddBox(box3); row1.AddBox(box4); RootBox root = new RootBox(styles); root.AddBox(row1); LayoutInfo layoutArgs = MakeLayoutInfo(); root.Layout(layoutArgs); var rect1 = new Rectangle(0, 0, 48, 96); var rect2 = new Rectangle(0, 0, 24, 144); rect2.Offset(rect1.Right, 0); var rect3 = new Rectangle(0, 0, 24, 96); rect3.Offset(rect2.Right, 0); var rect4 = new Rectangle(0, 0, 24, 96); rect4.Offset(rect3.Right, 0); var paintRects = new[] { rect1, rect2, rect3, rect4 }; VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 2000), 0, 0, paintRects); // Clipping off the left part, but not the whole, of a box does not prevent drawing it. VerifyPaint(root, new Rectangle(10, -1000, -10 + rect4.Right - 10, 2000), 0, 0, paintRects); // Even clipping all but one pixel does not prevent drawing. VerifyPaint(root, new Rectangle(47, -1000, -47 + rect3.Right + 1, 2000), 0, 0, paintRects); // However if we clip a bit more we should draw less var middleTwo = new[] { rect2, rect3 }; VerifyPaint(root, new Rectangle(48, -1000, -48 + rect3.Right - 2, 2000), 0, 0, middleTwo); // If the clip covers just a bit of the first box we paint just that. var firstOne = new[] { rect1 }; VerifyPaint(root, new Rectangle(-1000, -1000, 1000 + 10, 2000), 0, 0, firstOne); // If the clip covers just a bit of the last box we paint just that. var lastOne = new[] { rect4 }; VerifyPaint(root, new Rectangle(rect4.Right - 2, -1000, 1000, 2000), 0, 0, lastOne); // If the clip is entirely above the pile we draw nothing. VerifyPaint(root, new Rectangle(-1000, -1000, 990, 2000), 0, 0, null); // Likewise if entirely below. VerifyPaint(root, new Rectangle(rect4.Right + 10, -1000, 10, 2000), 0, 0, null); // Now try with simulated scrolling. Use a normal clip rectangle, but pretend the first two // and a bit boxes are scrolled off. var offset = rect2.Right + 10; var rect3Offset = rect3; rect3Offset.Offset(-offset, 0); var rect4Offset = rect4; rect4Offset.Offset(-offset, 0); var lastTwoOffset = new[] { rect3Offset, rect4Offset }; VerifyPaint(root, new Rectangle(0, -1000, 200, 2000), offset, 0, lastTwoOffset); }
public void DivClippedPaint() { var styles = new AssembledStyles(); var box1 = new FgBlockBox(styles, Color.Red, 72000, 36000); var box2 = new FgBlockBox(styles, Color.Blue, 108000, 18000); var box3 = new FgBlockBox(styles, Color.Orange, 72000, 18000); var box4 = new FgBlockBox(styles, Color.Orange, 72000, 18000); var div1 = new DivBox(styles); div1.AddBox(box1); div1.AddBox(box2); div1.AddBox(box3); div1.AddBox(box4); RootBox root = new RootBox(styles); root.AddBox(div1); LayoutInfo layoutArgs = MakeLayoutInfo(); root.Layout(layoutArgs); var rect1 = new Rectangle(0, 0, 96, 48); var rect2 = new Rectangle(0, 0, 144, 24); rect2.Offset(0, rect1.Bottom); var rect3 = new Rectangle(0, 0, 96, 24); rect3.Offset(0, rect2.Bottom); var rect4 = new Rectangle(0, 0, 96, 24); rect4.Offset(0, rect3.Bottom); var paintRects = new[] { rect1, rect2, rect3, rect4 }; VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 2000), 0, 0, paintRects); // Clipping off the top part, but not the whole, of a box does not prevent drawing it. VerifyPaint(root, new Rectangle(-1000, 10, 2000, -10 + rect4.Bottom - 10), 0, 0, paintRects); // Even clipping all but one pixel does not prevent drawing. VerifyPaint(root, new Rectangle(-1000, 47, 2000, -47 + rect3.Bottom + 1), 0, 0, paintRects); // However if we clip a bit more we should draw less var middleTwo = new[] {rect2, rect3}; VerifyPaint(root, new Rectangle(-1000, 48, 2000, -48 + rect3.Bottom - 2), 0, 0, middleTwo); // If the clip covers just a bit of the first box we paint just that. var firstOne = new[] {rect1}; VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 1000 + 10), 0, 0, firstOne); // If the clip covers just a bit of the last box we paint just that. var lastOne = new[] { rect4 }; VerifyPaint(root, new Rectangle(-1000, rect4.Bottom - 2, 2000, 1000), 0, 0, lastOne); // If the clip is entirely above the pile we draw nothing. VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 990), 0, 0, null); // Likewise if entirely below. VerifyPaint(root, new Rectangle(-1000, rect4.Bottom + 10, 2000, 10), 0, 0, null); // Now try with simulated scrolling. Use a normal clip rectangle, but pretend the first two // and a bit boxes are scrolled off. var offset = rect2.Bottom + 10; var rect3Offset = rect3; rect3Offset.Offset(0, -offset); var rect4Offset = rect4; rect4Offset.Offset(0, -offset); var lastTwoOffset = new[] {rect3Offset, rect4Offset}; VerifyPaint(root, new Rectangle(-1000, 0, 2000, 200), 0, offset, lastTwoOffset); }
public void DivClippedPaint() { var styles = new AssembledStyles(); var box1 = new FgBlockBox(styles, Color.Red, 72000, 36000); var box2 = new FgBlockBox(styles, Color.Blue, 108000, 18000); var box3 = new FgBlockBox(styles, Color.Orange, 72000, 18000); var box4 = new FgBlockBox(styles, Color.Orange, 72000, 18000); var div1 = new DivBox(styles); div1.AddBox(box1); div1.AddBox(box2); div1.AddBox(box3); div1.AddBox(box4); RootBox root = new RootBox(styles); root.AddBox(div1); LayoutInfo layoutArgs = MakeLayoutInfo(); root.Layout(layoutArgs); var rect1 = new Rectangle(0, 0, 96, 48); var rect2 = new Rectangle(0, 0, 144, 24); rect2.Offset(0, rect1.Bottom); var rect3 = new Rectangle(0, 0, 96, 24); rect3.Offset(0, rect2.Bottom); var rect4 = new Rectangle(0, 0, 96, 24); rect4.Offset(0, rect3.Bottom); var paintRects = new[] { rect1, rect2, rect3, rect4 }; VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 2000), 0, 0, paintRects); // Clipping off the top part, but not the whole, of a box does not prevent drawing it. VerifyPaint(root, new Rectangle(-1000, 10, 2000, -10 + rect4.Bottom - 10), 0, 0, paintRects); // Even clipping all but one pixel does not prevent drawing. VerifyPaint(root, new Rectangle(-1000, 47, 2000, -47 + rect3.Bottom + 1), 0, 0, paintRects); // However if we clip a bit more we should draw less var middleTwo = new[] { rect2, rect3 }; VerifyPaint(root, new Rectangle(-1000, 48, 2000, -48 + rect3.Bottom - 2), 0, 0, middleTwo); // If the clip covers just a bit of the first box we paint just that. var firstOne = new[] { rect1 }; VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 1000 + 10), 0, 0, firstOne); // If the clip covers just a bit of the last box we paint just that. var lastOne = new[] { rect4 }; VerifyPaint(root, new Rectangle(-1000, rect4.Bottom - 2, 2000, 1000), 0, 0, lastOne); // If the clip is entirely above the pile we draw nothing. VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 990), 0, 0, null); // Likewise if entirely below. VerifyPaint(root, new Rectangle(-1000, rect4.Bottom + 10, 2000, 10), 0, 0, null); // Now try with simulated scrolling. Use a normal clip rectangle, but pretend the first two // and a bit boxes are scrolled off. var offset = rect2.Bottom + 10; var rect3Offset = rect3; rect3Offset.Offset(0, -offset); var rect4Offset = rect4; rect4Offset.Offset(0, -offset); var lastTwoOffset = new[] { rect3Offset, rect4Offset }; VerifyPaint(root, new Rectangle(-1000, 0, 2000, 200), 0, offset, lastTwoOffset); }