Files
XCharts/Scripts/UI/Internal/Title.cs

112 lines
3.5 KiB
C#
Raw Normal View History

using UnityEngine;
using System;
namespace XCharts
{
[Serializable]
2019-06-21 09:34:33 +08:00
public class Title : IPropertyChanged, IEquatable<Title>
{
[SerializeField] private bool m_Show;
[SerializeField] private string m_Text;
[SerializeField] private int m_TextFontSize;
[SerializeField] private string m_SubText;
[SerializeField] private int m_SubTextFontSize;
[SerializeField] private float m_ItemGap;
[SerializeField] private Location m_Location;
public bool show { get { return m_Show; } set { m_Show = value; } }
public string text { get { return m_Text; } set { m_Text = value; } }
2019-06-21 09:34:33 +08:00
public int textFontSize { get { return m_TextFontSize; } set { m_TextFontSize = value; } }
public string subText { get { return m_SubText; } set { m_Text = value; } }
public int subTextFontSize { get { return m_SubTextFontSize; } set { m_SubTextFontSize = value; } }
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
public Location location { get { return m_Location; } set { m_Location = value; } }
public static Title defaultTitle
{
get
{
var title = new Title
{
m_Show = true,
m_Text = "Chart Title",
m_TextFontSize = 16,
m_SubText = "",
m_SubTextFontSize = 14,
m_ItemGap = 14,
m_Location = Location.defaultTop
};
return title;
}
}
public void Copy(Title title)
{
m_Show = title.show;
m_Text = title.text;
m_TextFontSize = title.textFontSize;
m_SubText = title.subText;
m_SubTextFontSize = title.subTextFontSize;
m_ItemGap = title.itemGap;
m_Location.Copy(title.location);
}
public override bool Equals(object obj)
{
2019-06-17 04:29:19 +08:00
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Title)
{
return Equals((Title)obj);
}
else
{
return false;
}
}
public bool Equals(Title other)
{
2019-06-17 04:29:19 +08:00
if (ReferenceEquals(null, other))
{
return false;
}
return m_Show == other.show &&
m_Text.Equals(other.text) &&
m_TextFontSize == other.textFontSize &&
m_SubText.Equals(other.subText) &&
m_SubTextFontSize == other.subTextFontSize &&
m_ItemGap == other.itemGap &&
m_Location.Equals(other.location);
}
2019-06-17 04:29:19 +08:00
public static bool operator ==(Title left, Title right)
{
2019-06-17 04:29:19 +08:00
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
2019-06-17 04:29:19 +08:00
public static bool operator !=(Title left, Title right)
{
2019-06-17 04:29:19 +08:00
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public void OnChanged()
{
m_Location.OnChanged();
}
}
}