mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 07:50:16 +00:00
3.0 - unitypackage
This commit is contained in:
106
Runtime/Component/Title/Title.cs
Normal file
106
Runtime/Component/Title/Title.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Title component, including main title and subtitle.
|
||||
/// 标题组件,包含主标题和副标题。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(TitleHander), true)]
|
||||
public class Title : MainComponent, IPropertyChanged
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Text = "Chart Title";
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
[SerializeField] private string m_SubText = "";
|
||||
[SerializeField] private TextStyle m_SubTextStyle = new TextStyle();
|
||||
[SerializeField] private float m_ItemGap = 0;
|
||||
[SerializeField] private Location m_Location = Location.defaultTop;
|
||||
|
||||
/// <summary>
|
||||
/// [default:true]
|
||||
/// Set this to false to prevent the title from showing.
|
||||
/// 是否显示标题组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The main title text, supporting \n for newlines.
|
||||
/// 主标题文本,支持使用 \n 换行。
|
||||
/// </summary>
|
||||
public string text { get { return m_Text; } set { if (PropertyUtil.SetClass(ref m_Text, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The text style of main title.
|
||||
/// 主标题文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtitle text, supporting for \n for newlines.
|
||||
/// 副标题文本,支持使用 \n 换行。
|
||||
/// </summary>
|
||||
public string subText
|
||||
{
|
||||
get { return m_SubText; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SubText, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The text style of sub title.
|
||||
/// 副标题文本样式。
|
||||
/// </summary>
|
||||
public TextStyle subTextStyle
|
||||
{
|
||||
get { return m_SubTextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SubTextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// [default:8]
|
||||
/// The gap between the main title and subtitle.
|
||||
/// 主副标题之间的间距。
|
||||
/// </summary>
|
||||
public float itemGap
|
||||
{
|
||||
get { return m_ItemGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The location of title component.
|
||||
/// 标题显示位置。
|
||||
/// </summary>
|
||||
public Location location
|
||||
{
|
||||
get { return m_Location; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty { get { return false; } }
|
||||
public override bool componentDirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ComponentDirty
|
||||
|| location.componentDirty
|
||||
|| textStyle.componentDirty
|
||||
|| subTextStyle.componentDirty;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ClearComponentDirty()
|
||||
{
|
||||
base.ClearComponentDirty();
|
||||
location.ClearComponentDirty();
|
||||
textStyle.ClearComponentDirty();
|
||||
subTextStyle.ClearComponentDirty();
|
||||
}
|
||||
|
||||
public void OnChanged()
|
||||
{
|
||||
m_Location.OnChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user