diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index 6a150f11..34a75c9a 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.03.24) 增加`Serie`在`inspector`上可进行调整顺序、添加和删除操作 * (2020.03.23) 修复`Title`的`textStyle`和`subTextStyle`无效的问题 * (2020.03.22) 增加`BarChart`通过`barType`参数设置`胶囊柱状图` * (2020.03.21) 增加`BarChart`和`HeatmapChart`可通过`ignore`参数设置忽略数据的支持 diff --git a/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs index b0c4184a..b2ed082e 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs @@ -81,8 +81,9 @@ namespace XCharts var toggle = ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieModuleToggle, prop, moduleName, show); if (!toggle) { + var orderButton = 47; drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2 + 20; - drawRect.width = pos.width - drawRect.x + 15; + drawRect.width = pos.width - drawRect.x + 15 - orderButton; EditorGUI.PropertyField(drawRect, type, GUIContent.none); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } @@ -249,7 +250,7 @@ namespace XCharts drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis); break; case SerieType.Heatmap: - EditorGUI.PropertyField(drawRect, m_Ignore); + EditorGUI.PropertyField(drawRect, m_Ignore); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_IgnoreValue); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; @@ -359,6 +360,7 @@ namespace XCharts DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width); } } + drawRect.y += EditorGUIUtility.standardVerticalSpacing; EditorGUI.indentLevel--; } --EditorGUI.indentLevel; @@ -460,7 +462,7 @@ namespace XCharts { float height = 0; int index = InitToggle(prop); - if (!m_SerieModuleToggle[prop.propertyPath]) + if (!m_SerieModuleToggle.ContainsKey(prop.propertyPath) || !m_SerieModuleToggle[prop.propertyPath]) { return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } @@ -553,6 +555,7 @@ namespace XCharts { height += (num) * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing; } + height += EditorGUIUtility.standardVerticalSpacing; if (prop.FindPropertyRelative("m_ShowDataIcon").boolValue) { for (int i = 0; i < num; i++) diff --git a/Assets/XCharts/Editor/PropertyDrawers/SeriesDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/SeriesDrawer.cs index 79f3cc05..b871fab0 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/SeriesDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/SeriesDrawer.cs @@ -27,11 +27,10 @@ namespace XCharts drawRect.width = EditorGUIUtility.labelWidth + 10; ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SeriesModuleToggle, "Series"); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - //ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop); drawRect.width = pos.width; if (m_SeriesModuleToggle) { - ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Series); + ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Series, true); } } diff --git a/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs b/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs index 6b1d7cd6..ede3996e 100644 --- a/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs +++ b/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs @@ -143,11 +143,27 @@ public class ChartEditorHelper return toggle; } - public static void MakeList(ref Rect drawRect, ref int listSize, SerializedProperty listProp, SerializedProperty large = null) + public static void MakeList(ref Rect drawRect, ref int listSize, SerializedProperty listProp, bool showOrder = false) { EditorGUI.indentLevel++; listSize = listProp.arraySize; - listSize = EditorGUI.IntField(drawRect, "Size", listSize); + if (showOrder) + { + var nameWid = 15; + var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - nameWid, drawRect.height); + //listSize = EditorGUI.IntField(elementRect, "Size", listSize); + var iconRect = new Rect(drawRect.width - nameWid + 14, drawRect.y, nameWid, drawRect.height); + if (GUI.Button(iconRect, new GUIContent("+", "add"))) + { + listProp.InsertArrayElementAtIndex(listProp.arraySize); + } + listSize = listProp.arraySize; + listSize = EditorGUI.IntField(elementRect, "Size", listSize); + } + else + { + listSize = EditorGUI.IntField(drawRect, "Size", listSize); + } if (listSize < 0) listSize = 0; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; @@ -182,8 +198,37 @@ public class ChartEditorHelper for (int i = 0; i < listProp.arraySize; i++) { SerializedProperty element = listProp.GetArrayElementAtIndex(i); - EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i)); - drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; + if (showOrder) + { + var nameWid = 15; + var isSerie = "Serie".Equals(element.type); + var elementRect = isSerie ? drawRect : new Rect(drawRect.x, drawRect.y, drawRect.width - 2 * 15, drawRect.height); + EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i)); + var iconRect = new Rect(drawRect.width - 3 * nameWid + 14, drawRect.y, nameWid, drawRect.height); + if (GUI.Button(iconRect, new GUIContent("↑", "up"))) + { + if (i > 0) listProp.MoveArrayElement(i, i - 1); + } + iconRect = new Rect(drawRect.width - 2 * nameWid + 14, drawRect.y, nameWid, drawRect.height); + if (GUI.Button(iconRect, new GUIContent("↓", "down"))) + { + if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); + } + iconRect = new Rect(drawRect.width - nameWid + 14, drawRect.y, nameWid, drawRect.height); + if (GUI.Button(iconRect, new GUIContent("-", "delete"))) + { + if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); + } + else + { + drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; + } + } + else + { + EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i)); + drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; + } } } EditorGUI.indentLevel--; diff --git a/Doc/TODO.md b/Doc/TODO.md index f36e0498..8d55dd46 100644 --- a/Doc/TODO.md +++ b/Doc/TODO.md @@ -1,25 +1,27 @@ # TODO -1. ~~(06.30)Pie增加选中~~ -2. ~~(06.30)Pie增加Label~~ -3. ~~(06.30)Pie增加动画~~ -4. ~~(07.02)坐标轴的Label与轴线的偏移~~ -5. ~~(07.03)PieChart支持多个Pie~~ -6. ~~(07.03)重构Series的data支持更多数据定义,大改动~~ -7. ~~(07.09)增加AxisLine~~ -8. ~~(07.09)支持多坐标轴~~ -9. ~~(07.09)支持XY轴都为value模式~~ -10. ~~(09.12)增加点画线(东方白)~~ -11. ~~(09.12)增加带箭头曲线(o . o)~~ -12. ~~(09.16)数值轴刻度固定,段数随最大值动态分配(风林火山)~~ -13. ~~(09.17)多图组合~~ -14. ~~(09.17)Tooltip和Label的文字显示增加自定义格式(风林火山)~~ -15. ~~(09.18)单条堆叠柱状图(123)~~ -16. ~~(09.18)接口整理~~ -17. ~~(09.18)Tooltip增加设置固定宽高(幽默的笑意)~~ -18. ~~(09.22)Tooltip增加设置字体大小和样式(FIRE ROAR)~~ -19. ~~(09.22)Value轴刻度显示支持自定义格式输出(自燃)~~ -20. ~~(09.22)SerieLabel支持自定义Icon图片(自燃)~~ +1. ~~(2019.06.30)Pie增加选中~~ +2. ~~(2019.06.30)Pie增加Label~~ +3. ~~(2019.06.30)Pie增加动画~~ +4. ~~(2019.07.02)坐标轴的Label与轴线的偏移~~ +5. ~~(2019.07.03)PieChart支持多个Pie~~ +6. ~~(2019.07.03)重构Series的data支持更多数据定义,大改动~~ +7. ~~(2019.07.09)增加AxisLine~~ +8. ~~(2019.07.09)支持多坐标轴~~ +9. ~~(2019.07.09)支持XY轴都为value模式~~ +10. ~~(2019.09.12)增加点画线(东方白)~~ +11. ~~(2019.09.12)增加带箭头曲线(o . o)~~ +12. ~~(2019.09.16)数值轴刻度固定,段数随最大值动态分配(风林火山)~~ +13. ~~(2019.09.17)多图组合~~ +14. ~~(2019.09.17)Tooltip和Label的文字显示增加自定义格式(风林火山)~~ +15. ~~(2019.09.18)单条堆叠柱状图(123)~~ +16. ~~(2019.09.18)接口整理~~ +17. ~~(2019.09.18)Tooltip增加设置固定宽高(幽默的笑意)~~ +18. ~~(2019.09.22)Tooltip增加设置字体大小和样式(FIRE ROAR)~~ +19. ~~(2019.09.22)Value轴刻度显示支持自定义格式输出(自燃)~~ +20. ~~(2019.09.22)SerieLabel支持自定义Icon图片(自燃)~~ 21. (2020.03.09)柱状图圆角 -22. (2020.03.09)可忽略不绘制指定数据 +22. ~~(2020.03.09)可忽略不绘制指定数据~~ +23. ~~(2020.03.21)Series的inspector可以改变顺序和删除~~ +24. (2020.03.21)圆角矩形