XCharts 2.0

This commit is contained in:
monitor1394
2021-01-17 11:44:47 +08:00
parent 7e4e046672
commit d2e96b4002
11 changed files with 68 additions and 128 deletions

View File

@@ -13,8 +13,6 @@ namespace XCharts
[CustomPropertyDrawer(typeof(Axis), true)]
public class AxisDrawer : BasePropertyDrawer
{
private string m_JsonDataAreaText;
public override string ClassName { get { return "Axis"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
@@ -84,16 +82,7 @@ namespace XCharts
if (type == Axis.AxisType.Category)
{
m_DrawRect.width = EditorGUIUtility.labelWidth + 10;
m_DataToggles[m_KeyName] = EditorGUI.Foldout(m_DrawRect, m_DataToggles[m_KeyName], "Data");
AddSingleLineHeight();
m_DrawRect.width = pos.width;
if (m_DataToggles[m_KeyName])
{
var height = m_Heights[m_KeyName];
ChartEditorHelper.MakeList(ref m_DrawRect, ref height, ref m_DataSize, m_Data);
m_Heights[m_KeyName] = height;
}
PropertyListField(prop, "m_Data", true);
}
EditorGUI.indentLevel--;
}

View File

@@ -86,6 +86,18 @@ namespace XCharts
m_DrawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
protected void PropertyListField(SerializedProperty prop, string relativePropName, bool showOrder = false)
{
if (IngorePropertys.Contains(relativePropName)) return;
var height = m_Heights[m_KeyName];
var toggleKeyName = m_KeyName + relativePropName;
m_DataToggles[toggleKeyName] = ChartEditorHelper.MakeListWithFoldout(ref m_DrawRect, ref height,
prop.FindPropertyRelative(relativePropName),
m_DataToggles.ContainsKey(toggleKeyName) && m_DataToggles[toggleKeyName], showOrder);
m_Heights[m_KeyName] = height;
}
protected void PropertyField(SerializedProperty prop, string relativePropName)
{
if (IngorePropertys.Contains(relativePropName)) return;

View File

@@ -49,14 +49,14 @@ namespace XCharts
PropertyField(prop, "m_Bottom");
PropertyField(prop, "m_LineStyle");
PropertyField(prop, "m_AreaStyle");
PropertyField(prop, "m_XAxisIndexs");
PropertyField(prop, "m_YAxisIndexs");
PropertyListField(prop, "m_XAxisIndexs", true);
PropertyListField(prop, "m_YAxisIndexs", true);
PropertyField(prop, "m_TextStyle");
}
else
{
PropertyField(prop, "m_XAxisIndexs");
PropertyField(prop, "m_YAxisIndexs");
PropertyListField(prop, "m_XAxisIndexs", true);
PropertyListField(prop, "m_YAxisIndexs", true);
}
--EditorGUI.indentLevel;
}

View File

@@ -34,7 +34,7 @@ namespace XCharts
PropertyField(prop, "m_Opacity");
PropertyField(prop, "m_TooltipFormatter");
PropertyField(prop, "m_NumericFormatter");
PropertyField(prop, "m_CornerRadius");
PropertyListField(prop, "m_CornerRadius", true);
--EditorGUI.indentLevel;
}
}

View File

@@ -13,9 +13,6 @@ namespace XCharts
[CustomPropertyDrawer(typeof(Series), true)]
public class SeriesDrawer : PropertyDrawer
{
private int m_DataSize = 0;
private bool m_ShowJsonDataArea = false;
private string m_JsonDataAreaText;
private bool m_SeriesModuleToggle = false;
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
@@ -23,15 +20,8 @@ namespace XCharts
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Series = prop.FindPropertyRelative("m_Series");
drawRect.width = EditorGUIUtility.labelWidth + 10;
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SeriesModuleToggle, "Series");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.width = pos.width;
if (m_SeriesModuleToggle)
{
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Series, true);
}
m_SeriesModuleToggle = ChartEditorHelper.MakeListWithFoldout(ref drawRect,
m_Series, m_SeriesModuleToggle, true, true);
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
@@ -46,10 +36,6 @@ namespace XCharts
height += EditorGUI.GetPropertyHeight(m_Data.GetArrayElementAtIndex(i)) + EditorGUIUtility.standardVerticalSpacing;
}
}
if (m_ShowJsonDataArea)
{
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
}
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
return height;
}

View File

@@ -78,7 +78,9 @@ namespace XCharts
if (newProp.name == "m_Script") continue;
if (newProp.name == "m_ThemeName") continue;
if (newProp.name == "m_Theme") continue;
AddPropertyField(pos, newProp, ref y);
} while (newProp.NextVisible(false));
}
if (GUI.changed)