mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 10:20:10 +00:00
增加Background的borderStyle,给图表默认设置圆角
This commit is contained in:
@@ -18,6 +18,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private Image.Type m_ImageType;
|
||||
[SerializeField] private Color m_ImageColor = Color.white;
|
||||
[SerializeField] private bool m_AutoColor = true;
|
||||
[SerializeField][Since("v3.10.0")] private BorderStyle m_BorderStyle = new BorderStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable the background component.
|
||||
@@ -67,6 +68,16 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the border style of background.
|
||||
/// ||背景边框样式。
|
||||
/// </summary>
|
||||
public BorderStyle borderStyle
|
||||
{
|
||||
get { return m_BorderStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public override void SetDefaultValue()
|
||||
{
|
||||
m_Show = true;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace XCharts.Runtime
|
||||
public override void InitComponent()
|
||||
{
|
||||
component.painter = chart.painter;
|
||||
component.refreshComponent = delegate()
|
||||
component.refreshComponent = delegate ()
|
||||
{
|
||||
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
@@ -27,7 +27,7 @@ namespace XCharts.Runtime
|
||||
backgroundImage.color = chart.theme.GetBackgroundColor(component);
|
||||
|
||||
backgroundObj.transform.SetSiblingIndex(0);
|
||||
backgroundObj.SetActive(component.show);
|
||||
backgroundObj.SetActive(component.show && component.image != null);
|
||||
};
|
||||
component.refreshComponent();
|
||||
}
|
||||
@@ -45,13 +45,13 @@ namespace XCharts.Runtime
|
||||
if (component.image != null)
|
||||
return;
|
||||
|
||||
var p1 = new Vector3(chart.chartX, chart.chartY + chart.chartHeight);
|
||||
var p2 = new Vector3(chart.chartX + chart.chartWidth, chart.chartY + chart.chartHeight);
|
||||
var p3 = new Vector3(chart.chartX + chart.chartWidth, chart.chartY);
|
||||
var p4 = new Vector3(chart.chartX, chart.chartY);
|
||||
var backgroundColor = chart.theme.GetBackgroundColor(component);
|
||||
var borderWidth = component.borderStyle.GetRuntimeBorderWidth();
|
||||
var borderColor = component.borderStyle.GetRuntimeBorderColor();
|
||||
var cornerRadius = component.borderStyle.GetRuntimeCornerRadius();
|
||||
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, backgroundColor);
|
||||
UGL.DrawRoundRectangleWithBorder(vh, chart.chartRect, backgroundColor, backgroundColor, cornerRadius,
|
||||
borderWidth, borderColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user