增加Serieinspector上可进行调整顺序、添加和删除操作

This commit is contained in:
monitor1394
2020-03-24 09:08:14 +08:00
parent 25941d2050
commit ca1e6957a8
5 changed files with 80 additions and 30 deletions

View File

@@ -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`参数设置忽略数据的支持

View File

@@ -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++)

View File

@@ -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);
}
}

View File

@@ -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--;

View File

@@ -1,25 +1,27 @@
# TODO
1. ~~06.30Pie增加选中~~
2. ~~06.30Pie增加Label~~
3. ~~06.30Pie增加动画~~
4. ~~07.02坐标轴的Label与轴线的偏移~~
5. ~~07.03PieChart支持多个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.17Tooltip和Label的文字显示增加自定义格式风林火山~~
15. ~~09.18单条堆叠柱状图123~~
16. ~~09.18)接口整理~~
17. ~~09.18Tooltip增加设置固定宽高幽默的笑意~~
18. ~~09.22Tooltip增加设置字体大小和样式FIRE ROAR~~
19. ~~09.22Value轴刻度显示支持自定义格式输出自燃~~
20. ~~09.22SerieLabel支持自定义Icon图片自燃~~
1. ~~2019.06.30Pie增加选中~~
2. ~~2019.06.30Pie增加Label~~
3. ~~2019.06.30Pie增加动画~~
4. ~~2019.07.02坐标轴的Label与轴线的偏移~~
5. ~~2019.07.03PieChart支持多个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.17Tooltip和Label的文字显示增加自定义格式风林火山~~
15. ~~2019.09.18单条堆叠柱状图123~~
16. ~~2019.09.18)接口整理~~
17. ~~2019.09.18Tooltip增加设置固定宽高幽默的笑意~~
18. ~~2019.09.22Tooltip增加设置字体大小和样式FIRE ROAR~~
19. ~~2019.09.22Value轴刻度显示支持自定义格式输出自燃~~
20. ~~2019.09.22SerieLabel支持自定义Icon图片自燃~~
21. 2020.03.09)柱状图圆角
22. 2020.03.09)可忽略不绘制指定数据
22. ~~2020.03.09)可忽略不绘制指定数据~~
23. ~~2020.03.21Series的inspector可以改变顺序和删除~~
24. 2020.03.21)圆角矩形