/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { string[] layerNames = LayersAndTagsSettings.GetCurrentLayers(); int layersCount = Math.Max(4, layerNames.Length); _checkBoxes = new List <CheckBox>(); _layersCount = layersCount; float labelsWidth = 100.0f; float labelsHeight = 18; var panel = layout.Space(100).Spacer; var gridPanel = new GridPanel(0) { Parent = panel, }; var upperLeftCell = new Label { Parent = gridPanel, }; var upperRightCell = new VerticalPanel { ClipChildren = false, Pivot = new Vector2(0.0f, 0.0f), Offset = new Vector2(-labelsWidth, 0), Rotation = -90, Spacing = 0, TopMargin = 0, BottomMargin = 0, Parent = gridPanel, }; var bottomLeftCell = new VerticalPanel { Spacing = 0, TopMargin = 0, BottomMargin = 0, Parent = gridPanel, }; var grid = new UniformGridPanel(0) { SlotsHorizontally = layersCount, SlotsVertically = layersCount, Parent = gridPanel, }; // Set layer names int layerIndex = 0; for (; layerIndex < layerNames.Length; layerIndex++) { upperRightCell.AddChild(new Label { Height = labelsHeight, Text = layerNames[layerNames.Length - layerIndex - 1], HorizontalAlignment = TextAlignment.Near, }); bottomLeftCell.AddChild(new Label { Height = labelsHeight, Text = layerNames[layerIndex], HorizontalAlignment = TextAlignment.Far, }); } for (; layerIndex < layersCount; layerIndex++) { string name = "Layer " + layerIndex; upperRightCell.AddChild(new Label { Height = labelsHeight, Text = name, HorizontalAlignment = TextAlignment.Near, }); bottomLeftCell.AddChild(new Label { Height = labelsHeight, Text = name, HorizontalAlignment = TextAlignment.Far, }); } // Arrange panel.Height = gridPanel.Height = gridPanel.Width = labelsWidth + layersCount * 18; gridPanel.RowFill[0] = gridPanel.ColumnFill[0] = labelsWidth / gridPanel.Width; gridPanel.RowFill[1] = gridPanel.ColumnFill[1] = 1 - gridPanel.ColumnFill[0]; // Create matrix for (int row = 0; row < layersCount; row++) { int column = 0; for (; column < layersCount - row; column++) { var box = new CheckBox(0, 0, true) { Tag = new Vector2(_layersCount - column - 1, row), Parent = grid, Checked = GetBit(column, row), }; box.StateChanged += OnCheckBoxChanged; _checkBoxes.Add(box); } for (; column < layersCount; column++) { grid.AddChild(new Label()); } } }