Add margin to TilesPanel tile
This commit is contained in:
@@ -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