diff --git a/Source/Engine/UI/GUI/Panels/GridPanel.cs b/Source/Engine/UI/GUI/Panels/GridPanel.cs index 1a0e69338..65119d8d1 100644 --- a/Source/Engine/UI/GUI/Panels/GridPanel.cs +++ b/Source/Engine/UI/GUI/Panels/GridPanel.cs @@ -93,28 +93,28 @@ namespace FlaxEngine.GUI int i = 0; Vector2 upperLeft = Vector2.Zero; - float reamingHeight = Height; + float remainingHeight = Height; for (int rowIndex = 0; rowIndex < _cellsV.Length; rowIndex++) { upperLeft.X = 0; - float cellHeight = _cellsV[rowIndex] * reamingHeight; + float cellHeight = _cellsV[rowIndex] * remainingHeight; if (_cellsV[rowIndex] < 0) { cellHeight = -_cellsV[rowIndex]; - reamingHeight -= cellHeight; + remainingHeight -= cellHeight; } - float reamingWidth = Width; + float remainingWidth = Width; for (int columnIndex = 0; columnIndex < _cellsH.Length; columnIndex++) { if (i >= ChildrenCount) break; - float cellWidth = _cellsH[columnIndex] * reamingWidth; + float cellWidth = _cellsH[columnIndex] * remainingWidth; if (_cellsH[columnIndex] < 0) { cellWidth = -_cellsH[columnIndex]; - reamingWidth -= cellWidth; + remainingWidth -= cellWidth; } var slotBounds = new Rectangle(upperLeft, cellWidth, cellHeight); diff --git a/Source/Engine/UI/GUI/Panels/TilesPanel.cs b/Source/Engine/UI/GUI/Panels/TilesPanel.cs index c201c05ab..43fc59fee 100644 --- a/Source/Engine/UI/GUI/Panels/TilesPanel.cs +++ b/Source/Engine/UI/GUI/Panels/TilesPanel.cs @@ -10,9 +10,27 @@ namespace FlaxEngine.GUI /// public class TilesPanel : ContainerControl { + private Margin _tileMargin; private Vector2 _tileSize = new Vector2(64); private bool _autoResize = false; + /// + /// Gets or sets the margin applied to each tile. + /// + [EditorOrder(0), Tooltip("The margin applied to each tile.")] + public Margin TileMargin + { + get => _tileMargin; + set + { + if (_tileMargin != value) + { + _tileMargin = value; + PerformLayout(); + } + } + } + /// /// Gets or sets the size of the tile. /// @@ -54,7 +72,17 @@ namespace FlaxEngine.GUI /// Initializes a new instance of the class. /// public TilesPanel() + : this(2) { + } + + /// + /// Initializes a new instance of the class. + /// + /// The tile margin. + public TilesPanel(float tileMargin) + { + TileMargin = new Margin(tileMargin); AutoFocus = false; } @@ -83,15 +111,15 @@ namespace FlaxEngine.GUI c.Bounds = new Rectangle(x, y, itemsWidth, itemsHeight); - x += itemsWidth; - if (x + itemsWidth > width) + x += itemsWidth + TileMargin.Width; + if (x + itemsWidth + TileMargin.Width > width) { x = 0; - y += itemsHeight; + y += itemsHeight + TileMargin.Height; } } if (x > 0) - y += itemsHeight; + y += itemsHeight + TileMargin.Height; if (_autoResize) {