using Annulus;
using Azimuth;
namespace Glass.Testbed
{
///
/// ClipsChildren dropping one rect from the accumulation: the badge clears its icon, but the region above
/// still cuts it.
///
public class ClipEscapeTestCase : TestCase
{
public ClipEscapeTestCase(string name) : base(name) { }
protected override void Populate()
{
var regionSize = new Vector(150, 110);
var iconSize = new Vector(60, 60);
var badgeSize = new Vector(44, 30);
var badgeOverhang = new Vector(28, -14);
AddCaption("Left: the icon clips its children, so the badge is cut off at its edge");
AddCaption("Right: the icon stops clipping, so the badge overhangs it and the region still trims it");
Rect stage = ContentAggregator.NewRow(regionSize.Y);
void AddRegion(string name, bool badgeEscapes)
{
var region = NewChild(name);
region.Material = UiPacksheetMaterials.GreenFlatPanel;
region.Bounds = stage.NewCol(regionSize.X, margin: 90);
// Parked near the region's right edge, so an escaping badge runs into the region's own clip rather
// than merely clearing the icon.
Rect insideRegion = Rect.FromPositionAndSize(Vector.Zero, region.ClientRect.Size)
.Erode(new Rect.BorderSize { Top = 20, Right = 10 });
Rect iconColumn = insideRegion.NewCol(iconSize.X, HorizontalJustification.Right);
var icon = region.ChildControls.NewChild("icon");
icon.Material = UiPacksheetMaterials.RedFlatPanel;
icon.Bounds = iconColumn.NewRow(iconSize.Y);
icon.ClipsChildren = !badgeEscapes;
// Taken from the icon's own right edge and then pushed back out, since overhanging two sides is
// what gives the clip something to cut.
Rect insideIcon = Rect.FromPositionAndSize(Vector.Zero, icon.ClientRect.Size);
Rect badgeSlot = insideIcon.NewCol(badgeSize.X, HorizontalJustification.Right);
var badge = icon.ChildControls.NewChild("badge");
badge.Material = UiPacksheetMaterials.YellowFlatPanel;
badge.Bounds = Rect.FromPositionAndSize(badgeSlot.TopLeft + badgeOverhang, badgeSize);
}
AddRegion("confining region", badgeEscapes: false);
AddRegion("escaping region", badgeEscapes: true);
}
}
}