using Annulus; using Azimuth; using Glass.Blacklight; using System; namespace Glass.Testbed { public class PanelsTestCase : TestCase { private readonly World world; private int clickCount; public PanelsTestCase(string name, World world) : base(name) { this.world = world; } protected override void Populate() { var panelSize = new Vector(150, 300); var textMaterial = new TextMaterial { Font = Fonts.Philosopher32, Text = "Á | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " + "incididunt ut labore et dolore magna aliqua. gy ᚠ", VerticalAlignment = Alignment.Vertical.Top, }; // Measured up front so the row can be as tall as the taller of the two columns, which is what keeps // ContentBounds covering the whole case. Panel label = textMaterial .BuildControl(Constraints.Loose(new Vector(300, Scalar.PositiveInfinity))) .WrapIn(UiPacksheetMaterials.GreenPanel with { TintColor = System.Drawing.Color.Red }); Vector labelSize = label.Bounds.Size; Rect topRow = ContentAggregator.NewRow(Math.Max(panelSize.Y, labelSize.Y)); Rect panelSlot = topRow.NewCol(panelSize.X, margin: 40); var panel = NewChild("panel"); panel.Material = UiPacksheetMaterials.RedFlatPanel; panel.Bounds = panelSlot.NewRow(panelSize.Y); Rect insidePanel = Rect.FromPositionAndSize(Vector.Zero, panel.ClientRect.Size) .Erode(new Rect.BorderSize { Left = 10, Top = 10, Right = 10, Bottom = 10 }); Rect counterRow = insidePanel.NewRow(60, margin: Gutter); var counterText = Widgets.ButtonLabel($"{clickCount}"); var button = new Panel { Material = counterText }.FillParent(new Button { ButtonMaterial = UiPacksheetMaterials.YellowButton, Bounds = counterRow, }); panel.ChildControls.Add(button); button.OnClick += delegate (in MouseState _, MouseButtonFlags __) { ++clickCount; counterText.Text = $"{clickCount}"; FontRenderer.TextLayoutDebug = !FontRenderer.TextLayoutDebug; world.window.Invalidate(); }; var disableButton = Widgets.ButtonLabel("Disable") .BuildControl(Constraints.Unbounded) .WrapIn(UiPacksheetMaterials.YellowButton, insidePanel.TopLeft); panel.ChildControls.Add(disableButton); disableButton.OnClick += delegate (in MouseState _, MouseButtonFlags __) { button.Enabled = !button.Enabled; world.window.Invalidate(); }; label.Bounds = Rect.FromPositionAndSize(topRow.TopLeft, labelSize); Add(label); } } }