Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TooltipTheme.cs 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using UnityEngine;
  3. namespace XCharts.Runtime
  4. {
  5. [Serializable]
  6. public class TooltipTheme : ComponentTheme
  7. {
  8. [SerializeField] protected LineStyle.Type m_LineType = LineStyle.Type.Solid;
  9. [SerializeField] protected float m_LineWidth = 1f;
  10. [SerializeField] protected Color32 m_LineColor;
  11. [SerializeField] protected Color32 m_AreaColor;
  12. [SerializeField] protected Color32 m_LabelTextColor;
  13. [SerializeField] protected Color32 m_LabelBackgroundColor;
  14. /// <summary>
  15. /// the type of line.
  16. /// |坐标轴线类型。
  17. /// </summary>
  18. public LineStyle.Type lineType
  19. {
  20. get { return m_LineType; }
  21. set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
  22. }
  23. /// <summary>
  24. /// the width of line.
  25. /// |指示线线宽。
  26. /// </summary>
  27. public float lineWidth
  28. {
  29. get { return m_LineWidth; }
  30. set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
  31. }
  32. /// <summary>
  33. /// the color of line.
  34. /// |指示线颜色。
  35. /// </summary>
  36. public Color32 lineColor
  37. {
  38. get { return m_LineColor; }
  39. set { if (PropertyUtil.SetColor(ref m_LineColor, value)) SetVerticesDirty(); }
  40. }
  41. /// <summary>
  42. /// the color of line.
  43. /// |区域指示的颜色。
  44. /// </summary>
  45. public Color32 areaColor
  46. {
  47. get { return m_AreaColor; }
  48. set { if (PropertyUtil.SetColor(ref m_AreaColor, value)) SetVerticesDirty(); }
  49. }
  50. /// <summary>
  51. /// the text color of tooltip cross indicator's axis label.
  52. /// |十字指示器坐标轴标签的文本颜色。
  53. /// </summary>
  54. public Color32 labelTextColor
  55. {
  56. get { return m_LabelTextColor; }
  57. set { if (PropertyUtil.SetColor(ref m_LabelTextColor, value)) SetComponentDirty(); }
  58. }
  59. /// <summary>
  60. /// the background color of tooltip cross indicator's axis label.
  61. /// |十字指示器坐标轴标签的背景颜色。
  62. /// </summary>
  63. public Color32 labelBackgroundColor
  64. {
  65. get { return m_LabelBackgroundColor; }
  66. set { if (PropertyUtil.SetColor(ref m_LabelBackgroundColor, value)) SetComponentDirty(); }
  67. }
  68. public TooltipTheme(ThemeType theme) : base(theme)
  69. {
  70. m_LineType = LineStyle.Type.Solid;
  71. m_LineWidth = XCSettings.tootipLineWidth;
  72. switch (theme)
  73. {
  74. case ThemeType.Default:
  75. m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
  76. m_TextColor = ColorUtil.GetColor("#000000FF");
  77. m_AreaColor = ColorUtil.GetColor("#51515120");
  78. m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
  79. m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
  80. m_LineColor = ColorUtil.GetColor("#29292964");
  81. break;
  82. case ThemeType.Light:
  83. m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
  84. m_TextColor = ColorUtil.GetColor("#000000FF");
  85. m_AreaColor = ColorUtil.GetColor("#51515120");
  86. m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
  87. m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
  88. m_LineColor = ColorUtil.GetColor("#29292964");
  89. break;
  90. case ThemeType.Dark:
  91. m_TextBackgroundColor = ColorUtil.GetColor("#FFFFFFFF");
  92. m_TextColor = ColorUtil.GetColor("#000000FF");
  93. m_AreaColor = ColorUtil.GetColor("#51515120");
  94. m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
  95. m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
  96. m_LineColor = ColorUtil.GetColor("#29292964");
  97. break;
  98. }
  99. }
  100. public void Copy(TooltipTheme theme)
  101. {
  102. base.Copy(theme);
  103. m_LineType = theme.lineType;
  104. m_LineWidth = theme.lineWidth;
  105. m_LineColor = theme.lineColor;
  106. m_AreaColor = theme.areaColor;
  107. m_LabelTextColor = theme.labelTextColor;
  108. m_LabelBackgroundColor = theme.labelBackgroundColor;
  109. }
  110. }
  111. }