mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
增加Tooltip的FixedWidth、FixedHeight、MinWidth、MinHeight设置支持
This commit is contained in:
@@ -14,6 +14,10 @@ namespace XCharts
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty m_FixedWidth = prop.FindPropertyRelative("m_FixedWidth");
|
||||
SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight");
|
||||
SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth");
|
||||
SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
@@ -21,13 +25,21 @@ namespace XCharts
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, type);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FixedWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FixedHeight);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_MinWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_MinHeight);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_TooltipModuleToggle)
|
||||
return 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||
else
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace XCharts
|
||||
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Type m_Type;
|
||||
[SerializeField] private float m_FixedWidth = 0;
|
||||
[SerializeField] private float m_FixedHeight = 0;
|
||||
[SerializeField] private float m_MinWidth = 0;
|
||||
[SerializeField] private float m_MinHeight = 0;
|
||||
|
||||
private GameObject m_GameObject;
|
||||
private GameObject m_Content;
|
||||
@@ -60,6 +64,22 @@ namespace XCharts
|
||||
/// 提示框指示器类型。
|
||||
/// </summary>
|
||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// 固定宽度。比 minWidth 优先。
|
||||
/// </summary>
|
||||
public float fixedWidth { get { return m_FixedWidth; } set { m_FixedWidth = value; } }
|
||||
/// <summary>
|
||||
/// 固定高度。比 minHeight 优先。
|
||||
/// </summary>
|
||||
public float fixedHeight { get { return m_FixedHeight; } set { m_FixedHeight = value; } }
|
||||
/// <summary>
|
||||
/// 最小宽度。如若 fixedWidth 设有值,优先取 fixedWidth。
|
||||
/// </summary>
|
||||
public float minWidth { get { return m_MinWidth; } set { m_MinWidth = value; } }
|
||||
/// <summary>
|
||||
/// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。
|
||||
/// </summary>
|
||||
public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The data index currently indicated by Tooltip.
|
||||
@@ -179,8 +199,14 @@ namespace XCharts
|
||||
if (m_ContentText)
|
||||
{
|
||||
m_ContentText.text = txt;
|
||||
m_ContentRect.sizeDelta = new Vector2(m_ContentText.preferredWidth + 8,
|
||||
m_ContentText.preferredHeight + 8);
|
||||
float wid, hig;
|
||||
if (m_FixedWidth > 0) wid = m_FixedWidth;
|
||||
else if (m_MinWidth > 0 && m_ContentText.preferredWidth < m_MinWidth) wid = m_MinWidth;
|
||||
else wid = m_ContentText.preferredWidth + 8;
|
||||
if (m_FixedHeight > 0) hig = m_FixedHeight;
|
||||
else if (m_MinHeight > 0 && m_ContentText.preferredHeight < m_MinHeight) hig = m_MinHeight;
|
||||
else hig = m_ContentText.preferredHeight + 8;
|
||||
m_ContentRect.sizeDelta = new Vector2(wid, hig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user