mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 22:10:11 +00:00
增加Tooltip的backgroundImage参数配置背景图
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
* (2020.02.11) 增加`Tooltip`的`backgroundImage`参数配置背景图
|
||||
* (2020.02.11) 增加`Tooltip`的`paddingLeftRight`和`paddingTopBottom`参数配置文字和边框的间距
|
||||
* (2020.02.11) 增加`Tooltip`的`lineStyle`参数配置指示线样式
|
||||
* (2020.02.11) 增加`Axis`的`splitLine`参数控制分割线,去掉`showSplitLine`和`splitLineType`参数(更新时需要重新设置分割线相关设置)
|
||||
|
||||
@@ -198,6 +198,7 @@
|
||||
* `paddingTopBottom`:文字和边框的上下边距。
|
||||
* `fontSize`:文字的字体大小。
|
||||
* `fontStyle`:文字的字体风格。
|
||||
* `backgroundImage`:提示框的背景图。
|
||||
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||
* `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace XCharts
|
||||
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
|
||||
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
|
||||
SerializedProperty m_BackgroundImage = prop.FindPropertyRelative("m_BackgroundImage");
|
||||
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
|
||||
@@ -64,6 +65,8 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BackgroundImage);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
@@ -75,7 +78,7 @@ namespace XCharts
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_TooltipModuleToggle)
|
||||
return 14 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing +
|
||||
return 15 * EditorGUIUtility.singleLineHeight + 14 * EditorGUIUtility.standardVerticalSpacing +
|
||||
EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
else
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
@@ -60,11 +60,13 @@ namespace XCharts
|
||||
[SerializeField] private bool m_ForceENotation = false;
|
||||
[SerializeField] private float m_PaddingLeftRight = 5f;
|
||||
[SerializeField] private float m_PaddingTopBottom = 5f;
|
||||
[SerializeField] private Sprite m_BackgroundImage;
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f);
|
||||
|
||||
private GameObject m_GameObject;
|
||||
private GameObject m_Content;
|
||||
private Text m_ContentText;
|
||||
private Image m_ContentImage;
|
||||
private RectTransform m_ContentRect;
|
||||
private RectTransform m_ContentTextRect;
|
||||
private List<int> lastDataIndex { get; set; }
|
||||
@@ -161,6 +163,11 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } }
|
||||
/// <summary>
|
||||
/// The image of icon.
|
||||
/// 图标的图片。
|
||||
/// </summary>
|
||||
public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } }
|
||||
/// <summary>
|
||||
/// 指示线样式。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } set { if (value != null) m_LineStyle = value; } }
|
||||
@@ -240,11 +247,13 @@ namespace XCharts
|
||||
{
|
||||
m_Content = content;
|
||||
m_ContentRect = m_Content.GetComponent<RectTransform>();
|
||||
m_ContentImage = m_Content.GetComponent<Image>();
|
||||
m_ContentText = m_Content.GetComponentInChildren<Text>();
|
||||
if (m_ContentText != null)
|
||||
{
|
||||
m_ContentTextRect = m_ContentText.gameObject.GetComponentInChildren<RectTransform>();
|
||||
}
|
||||
SetBackground(backgroundImage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -263,8 +272,21 @@ namespace XCharts
|
||||
/// <param name="color"></param>
|
||||
public void SetContentBackgroundColor(Color color)
|
||||
{
|
||||
if (m_Content != null && m_Content.GetComponent<Image>() != null)
|
||||
m_Content.GetComponent<Image>().color = color;
|
||||
if (m_ContentImage != null)
|
||||
m_ContentImage.color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本背景图片
|
||||
/// </summary>
|
||||
/// <param name="sprite"></param>
|
||||
public void SetBackground(Sprite sprite)
|
||||
{
|
||||
if (m_ContentImage != null)
|
||||
{
|
||||
m_ContentImage.type = Image.Type.Sliced;
|
||||
m_ContentImage.sprite = sprite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace XCharts
|
||||
public class XChartsMgr : MonoBehaviour
|
||||
{
|
||||
public const string version = "1.2.0";
|
||||
public const int date = 20200210;
|
||||
public const int date = 20200211;
|
||||
|
||||
[SerializeField] private string m_NowVersion;
|
||||
[SerializeField] private string m_NewVersion;
|
||||
|
||||
Reference in New Issue
Block a user