mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 10:20:10 +00:00
优化Editor下编辑性能
This commit is contained in:
@@ -6,6 +6,15 @@ using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Editor
|
||||
{
|
||||
public class HeaderCallbackContext
|
||||
{
|
||||
public int fieldCount = 0;
|
||||
public SerializedProperty serieData;
|
||||
public bool showName;
|
||||
public int index;
|
||||
public int dimension;
|
||||
}
|
||||
|
||||
public class HeaderMenuInfo
|
||||
{
|
||||
public string name;
|
||||
@@ -586,6 +595,31 @@ namespace XCharts.Editor
|
||||
return state;
|
||||
}
|
||||
|
||||
public static bool DrawSerieDataHeader(string title, bool state, bool drawBackground, SerializedProperty activeField,
|
||||
HeaderCallbackContext context, Action<Rect, HeaderCallbackContext> drawCallback, params HeaderMenuInfo[] menus)
|
||||
{
|
||||
var rect = GUILayoutUtility.GetRect(1f, HEADER_HEIGHT);
|
||||
var labelRect = DrawHeaderInternal(rect, title, ref state, drawBackground, activeField);
|
||||
DrawMenu(rect, menus);
|
||||
if (drawCallback != null)
|
||||
{
|
||||
drawCallback(rect, context);
|
||||
}
|
||||
var e = Event.current;
|
||||
if (e.type == EventType.MouseDown)
|
||||
{
|
||||
if (labelRect.Contains(e.mousePosition))
|
||||
{
|
||||
if (e.button == 0)
|
||||
{
|
||||
state = !state;
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
internal static bool DrawHeader(string title, bool state, bool drawBackground, SerializedProperty activeField,
|
||||
Action<Rect> drawCallback, List<HeaderMenuInfo> menus)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user