/// <summary>Horizontal Divider</summary>
        public static void HorizontalDivider(Color?color = null, int height = 1, int topMargin = 5, int bottomMargin = 5)
        {
            GUILayout.Space(topMargin);
            Rect r = GUILayoutUtility.GetRect(0, height, GUILayout.ExpandWidth(true));

            DeGUI.DrawColoredSquare(r, color == null ? (Color)DeGUI.colors.bg.divider : (Color)color);
            GUILayout.Space(bottomMargin);
        }
        /// <summary>Button that can be toggled on and off</summary>
        public static bool ToggleButton(bool toggled, GUIContent content, Color bgOffColor, Color bgOnColor, Color contentOffColor, Color contenOnColor, GUIStyle guiStyle = null, params GUILayoutOption[] options)
        {
            Color prevBgColor      = GUI.backgroundColor;
            Color prevContentColor = GUI.contentColor;

            GUI.backgroundColor = toggled ? bgOnColor : bgOffColor;
            GUI.contentColor    = toggled ? contenOnColor : contentOffColor;
            if (guiStyle == null)
            {
                guiStyle = DeGUI.styles.button.bBlankBorder;
            }
            bool clicked = GUILayout.Button(content, guiStyle, options);

            if (clicked)
            {
                toggled     = !toggled;
                GUI.changed = true;
            }
            DeGUI.SetGUIColors(prevBgColor, prevContentColor, null);
            return(toggled);
        }
        /// <summary>
        /// Call this after each draggable GUI block, to calculate and draw the current drag state
        /// (or complete it if the mouse was released).
        /// </summary>
        /// <param name="dragId">ID for this drag operation (must be the same for both StartDrag and Drag</param>
        /// <param name="draggableList">List containing the draggable item and all other relative draggable items</param>
        /// <param name="currDraggableItemIndex">Current index of the draggable item being drawn</param>
        /// <param name="dragEvidenceColor">Color to use for drag divider and selection</param>
        /// <param name="lastGUIRect">If NULL will calculate this automatically using <see cref="GUILayoutUtility.GetLastRect"/>.
        /// Pass this if you're creating a drag between elements that don't use GUILayout</param>
        public static DeDragResult Drag(int dragId, IList draggableList, int currDraggableItemIndex, Color dragEvidenceColor, Rect?lastGUIRect = null)
        {
            if (_dragData == null || _dragId != dragId)
            {
                return(new DeDragResult(DeDragResultType.NoDrag));
            }
            if (_waitingToApplyDrag)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    Event.current.type = EventType.Used;
                }
                if (Event.current.type == EventType.Used)
                {
                    ApplyDrag();
                }
                return(new DeDragResult(DeDragResultType.Dragging, _dragData.draggedItemIndex, _dragData.currDragIndex));
            }

            _dragData.draggableList = draggableList; // Reassign in case of references that change every call (like with EditorBuildSettings.scenes)
            int listCount = _dragData.draggableList.Count;

            if (currDraggableItemIndex == 0 && Event.current.type == EventType.Repaint)
            {
                _dragData.currDragSet = false;
            }
            if (!_dragData.currDragSet)
            {
                // Find and store eventual drag position
                Rect lastRect = lastGUIRect == null?GUILayoutUtility.GetLastRect() : (Rect)lastGUIRect;

                float lastRectMiddleY = lastRect.yMin + lastRect.height * 0.5f;
                float mouseY          = Event.current.mousePosition.y;
                if (currDraggableItemIndex <= listCount - 1 && mouseY <= lastRectMiddleY)
                {
                    if (_dragDelayElapsed)
                    {
                        DeGUI.FlatDivider(new Rect(lastRect.xMin, lastRect.yMin - 1, lastRect.width, 2), dragEvidenceColor);
                    }
                    _dragData.currDragIndex = currDraggableItemIndex;
                    _dragData.currDragSet   = true;
                }
                else if (currDraggableItemIndex >= listCount - 1 && mouseY > lastRectMiddleY)
                {
                    if (_dragDelayElapsed)
                    {
                        DeGUI.FlatDivider(new Rect(lastRect.xMin, lastRect.yMax - 1, lastRect.width, 2), dragEvidenceColor);
                    }
                    _dragData.currDragIndex = listCount;
                    _dragData.currDragSet   = true;
                }
            }
            if (_dragData.draggedItemIndex == currDraggableItemIndex)
            {
                // Evidence dragged pool
                Color selectionColor = dragEvidenceColor;
                selectionColor.a = 0.35f;
                if (_dragDelayElapsed)
                {
                    DeGUI.FlatDivider(lastGUIRect == null ? GUILayoutUtility.GetLastRect() : (Rect)lastGUIRect, selectionColor);
                }
            }

            if (GUIUtility.hotControl < 1)
            {
                // End drag
                if (_dragDelayElapsed)
                {
                    return(EndDrag(true));
                }
                EndDrag(false);
                return(new DeDragResult(DeDragResultType.Click));
            }
            return(new DeDragResult(DeDragResultType.Dragging, _dragData.draggedItemIndex, _dragData.currDragIndex));
        }
        static string DoDoubleClickTextField(Editor editor, EditorWindow editorWindow, string id, string text, int dragId, IList draggableList, int draggedItemIndex, GUIStyle defaultStyle, GUIStyle editingStyle = null)
        {
            Rect r = GUILayoutUtility.GetRect(new GUIContent(""), defaultStyle, GUILayout.ExpandWidth(true));

            return(DeGUI.DoDoubleClickTextField(r, editor, editorWindow, id, text, dragId, draggableList, draggedItemIndex, defaultStyle, editingStyle));
        }