Add margin to TilesPanel tile
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -10,9 +10,27 @@ namespace FlaxEngine.GUI
|
||||
/// <seealso cref="FlaxEngine.GUI.ContainerControl" />
|
||||
public class TilesPanel : ContainerControl
|
||||
{
|
||||
private Margin _tileMargin;
|
||||
private Vector2 _tileSize = new Vector2(64);
|
||||
private bool _autoResize = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the margin applied to each tile.
|
||||
/// </summary>
|
||||
[EditorOrder(0), Tooltip("The margin applied to each tile.")]
|
||||
public Margin TileMargin
|
||||
{
|
||||
get => _tileMargin;
|
||||
set
|
||||
{
|
||||
if (_tileMargin != value)
|
||||
{
|
||||
_tileMargin = value;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the tile.
|
||||
/// </summary>
|
||||
@@ -54,7 +72,17 @@ namespace FlaxEngine.GUI
|
||||
/// Initializes a new instance of the <see cref="TilesPanel"/> class.
|
||||
/// </summary>
|
||||
public TilesPanel()
|
||||
: this(2)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TilesPanel"/> class.
|
||||
/// </summary>
|
||||
/// <param name="tileMargin">The tile margin.</param>
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user