38 lines
885 B
C#
38 lines
885 B
C#
using UnityEngine.UIElements;
|
|
|
|
namespace KitsuneCafe.UI
|
|
{
|
|
public class FixedLayout : ILayout
|
|
{
|
|
public FlowDirection Direction { get; set; }
|
|
public float ContentSize { get; private set; }
|
|
|
|
|
|
public float ItemSize { get; set; }
|
|
public float GutterSize { get; set; }
|
|
|
|
public FixedLayout(FlowDirection direction, float itemSize, float gutterSize)
|
|
{
|
|
Direction = direction;
|
|
ItemSize = itemSize;
|
|
GutterSize = gutterSize;
|
|
}
|
|
|
|
public FixedLayout(FlowDirection direction, float itemSize) : this(direction, itemSize, 0) { }
|
|
|
|
public float GetItemPosition(int index)
|
|
{
|
|
return index * (ItemSize + GutterSize);
|
|
}
|
|
|
|
public float GetItemSize(int _index)
|
|
{
|
|
return ItemSize;
|
|
}
|
|
|
|
public void Update(int itemCount, VisualElement _container)
|
|
{
|
|
ContentSize = itemCount * (ItemSize + GutterSize);
|
|
}
|
|
}
|
|
}
|