using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
{
///
/// The style of border.
/// ||边框样式。
///
[System.Serializable]
[Since("v3.10.0")]
public class BorderStyle : ChildComponent
{
[SerializeField] private bool m_Show = false;
[SerializeField] private float m_BorderWidth;
[SerializeField] private Color32 m_BorderColor;
[SerializeField] private bool m_RoundedCorner = true;
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
///
/// whether the border is visible.
/// ||是否显示边框。
///
public bool show
{
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
///
/// the width of border.
/// ||边框宽度。
///
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); }
}
///
/// the color of border.
/// ||边框颜色。
///
public Color32 borderColor
{
get { return m_BorderColor; }
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetAllDirty(); }
}
///
/// whether the border is rounded corner.
/// ||是否显示圆角。
///
public bool roundedCorner
{
get { return m_RoundedCorner; }
set { if (PropertyUtil.SetStruct(ref m_RoundedCorner, value)) SetAllDirty(); }
}
///
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left,
/// upper right, bottom right and bottom left)). When is set to (1,1,1,1), all corners are rounded.
/// ||圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。当为(1,1,1,1)时为全圆角。
///
public float[] cornerRadius
{
get { return m_CornerRadius; }
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value)) SetAllDirty(); }
}
public float GetRuntimeBorderWidth()
{
return m_Show ? m_BorderWidth : 0;
}
public Color32 GetRuntimeBorderColor()
{
return m_Show ? m_BorderColor : ColorUtil.clearColor32;
}
public float[] GetRuntimeCornerRadius()
{
return m_Show && roundedCorner ? m_CornerRadius : null;
}
}
}