// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using FlaxEngine;
namespace FlaxEditor.GUI
{
///
/// Table column descriptor.
///
[HideInEditor]
public class ColumnDefinition
{
///
/// Converts raw cell value to the string used by the column formatting policy.
///
/// The value.
/// The value string.
public delegate string ValueFormatDelegate(object value);
///
/// True if use expand/collapse rows feature for this column. See property which is used to describe the rows hierarchy.
///
public bool UseExpandCollapseMode;
///
/// The cell text alignment horizontally.
///
public TextAlignment CellAlignment = TextAlignment.Far;
///
/// The column title.
///
public string Title;
///
/// The title font.
///
public Font TitleFont;
///
/// The column title text color.
///
public Color TitleColor = Color.White;
///
/// The column title background background.
///
public Color TitleBackgroundColor = Color.Brown;
///
/// The minimum size (in pixels) of the column.
///
public float MinSize = 10.0f;
///
/// The minimum size percentage of the column (in range 0-100).
///
public float MinSizePercentage = 0.0f;
///
/// The maximum size (in pixels) of the column.
///
public float MaxSize = float.MaxValue;
///
/// The maximum size percentage of the column (in range 0-100).
///
public float MaxSizePercentage = 1.0f;
///
/// The value formatting delegate.
///
public ValueFormatDelegate FormatValue;
///
/// Clamps the size of the column (in percentage size of the table).
///
/// The percentage size of the column (split value).
/// Size of the table (width in pixels).
/// The clamped percentage size of the column (split value).
public float ClampColumnSize(float value, float tableSize)
{
float width = Mathf.Clamp(value, MinSizePercentage, MaxSizePercentage) * tableSize;
return Mathf.Clamp(width, MinSize, MaxSize) / tableSize;
}
}
}