/// <summary> /// Draw content for empty list (layout version). /// </summary> /// <param name="adaptor">Reorderable list adaptor.</param> /// <param name="drawEmpty">Callback to draw empty content.</param> /// <returns> /// Position of list container area in GUI (excludes footer area). /// </returns> private Rect DrawLayoutEmptyList(IReorderableListAdaptor adaptor, DrawEmpty drawEmpty) { Rect position = EditorGUILayout.BeginVertical(ContainerStyle); { if (drawEmpty != null) drawEmpty(); else Debug.LogError("Unexpected call to 'DrawLayoutEmptyList'"); s_CurrentListStack.Push(new ListInfo(_controlID, position)); try { adaptor.BeginGUI(); _insertionIndex = 0; _insertionPosition = position.y + 2; HandleDropInsertion(position, adaptor); adaptor.EndGUI(); } finally { s_CurrentListStack.Pop(); } } EditorGUILayout.EndVertical(); // Allow room for footer buttons? if (HasFooterButtons) GUILayoutUtility.GetRect(0, FooterButtonStyle.fixedHeight - 1); return position; }
/// <summary> /// Draw list control with absolute positioning. /// </summary> /// <param name="position">Position of list control in GUI.</param> /// <param name="controlID">Unique ID of list control.</param> /// <param name="adaptor">Reorderable list adaptor.</param> /// <param name="drawEmpty">Delegate for drawing empty list.</param> private void Draw(Rect position, int controlID, IReorderableListAdaptor adaptor, DrawEmptyAbsolute drawEmpty) { FixStyles(); PrepareState(controlID, adaptor); // Allow for footer area. if (HasFooterButtons) position.height -= FooterButtonStyle.fixedHeight; s_CurrentListStack.Push(new ListInfo(_controlID, position)); try { adaptor.BeginGUI(); DrawListContainerAndItems(position, adaptor); HandleDropInsertion(position, adaptor); CheckForAutoFocusControl(); if (adaptor.Count == 0) { ReorderableListGUI.IndexOfChangedItem = -1; DrawEmptyListControl(position, drawEmpty); } adaptor.EndGUI(); } finally { s_CurrentListStack.Pop(); } DrawFooterControls(position, adaptor); }
/// <summary> /// Do layout version of list field. /// </summary> /// <param name="adaptor">Reorderable list adaptor.</param> /// <param name="padding">Padding in pixels.</param> /// <returns> /// Position of list container area in GUI (excludes footer area). /// </returns> private Rect DrawLayoutListField(IReorderableListAdaptor adaptor, float padding) { Rect position = GetListRectWithAutoLayout(adaptor, padding); // Make room for footer buttons? if (HasFooterButtons) position.height -= FooterButtonStyle.fixedHeight; s_CurrentListStack.Push(new ListInfo(_controlID, position)); try { // Draw list as normal. adaptor.BeginGUI(); DrawListContainerAndItems(position, adaptor); HandleDropInsertion(position, adaptor); adaptor.EndGUI(); } finally { s_CurrentListStack.Pop(); } CheckForAutoFocusControl(); return position; }