private bool SvgInputAssetDraw(SVGBasicAtlas atlas, int index, out Rect rowRect)
    {
        bool          isDirty;
        SVGAssetInput svgAsset  = atlas.SvgAsset(index);
        bool          highlight = (this.m_DragInfo.Dragging && this.m_DragInfo.DraggedObject == svgAsset) ? true : false;

        if (this.m_DragInfo.InsertIdx == index && this.m_DragInfo.InsertBefore)
        {
            // draw a separator before the row
            GUILayout.Box(GUIContent.none, this.m_BlueLine, GUILayout.ExpandWidth(true), GUILayout.Height(2));
        }

        // if the SVG row is the dragged one, change colors
        if (highlight)
        {
            EditorGUILayout.BeginHorizontal(this.m_HighlightRow);
            // a row: asset name, separate groups checkbox, remove button, instantiate button
            EditorGUILayout.LabelField(svgAsset.TxtAsset.name, this.m_HighlightRow, GUILayout.MinWidth(10));
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            // a row: asset name, separate groups checkbox, remove button, instantiate button
            EditorGUILayout.LabelField(svgAsset.TxtAsset.name, GUILayout.MinWidth(10));
        }

        isDirty = this.SvgInputAssetDrawImplementation(atlas, svgAsset, index);

        EditorGUILayout.EndHorizontal();
        rowRect = GUILayoutUtility.GetLastRect();

        if (this.m_DragInfo.InsertIdx == index && (!this.m_DragInfo.InsertBefore))
        {
            // draw a separator after the row
            GUILayout.Box(GUIContent.none, this.m_BlueLine, GUILayout.ExpandWidth(true), GUILayout.Height(2));
        }

        return(isDirty);
    }
    protected bool HandleDragEvents(SVGBasicAtlas atlas, Event currentEvent, Rect scollRect)
    {
        int  i;
        bool isDirty = false;

        // events handler
        if (currentEvent.type != EventType.Layout)
        {
            bool needRepaint = false;
            // get mouse position relative to scollRect
            Vector2 mousePos = currentEvent.mousePosition - new Vector2(scollRect.xMin, scollRect.yMin);

            if (scollRect.Contains(currentEvent.mousePosition))
            {
                bool separatorInserted = false;

                for (i = 0; i < atlas.SvgAssetsCount(); ++i)
                {
                    // get the row rectangle relative to atlas.SvgList[i]
                    Rect rowRect = this.m_InputAssetsRects[i];
                    // expand the rectangle height
                    rowRect.yMin -= 3;
                    rowRect.yMax += 3;

                    if (rowRect.Contains(mousePos))
                    {
                        // a mousedown on a row, will stop an already started drag operation
                        if (currentEvent.type == EventType.MouseDown)
                        {
                            this.m_DragInfo.StopDrag();
                        }
                        // check if we are already dragging an object
                        if (this.m_DragInfo.Dragging)
                        {
                            if (!separatorInserted)
                            {
                                bool ok         = true;
                                bool dragBefore = (mousePos.y <= rowRect.yMin + rowRect.height / 2) ? true : false;
                                // if we are dragging a text (asset) file, all positions are ok
                                // if we are dragging an already present SVG row, we must perform additional checks
                                if (!(this.m_DragInfo.DraggedObject is TextAsset))
                                {
                                    if (this.m_DragInfo.DraggedObject == atlas.SvgAsset(i))
                                    {
                                        ok = false;
                                    }
                                    else
                                    {
                                        if (dragBefore)
                                        {
                                            if (i > 0 && this.m_DragInfo.DraggedObject == atlas.SvgAsset(i - 1))
                                            {
                                                ok = false;
                                            }
                                        }
                                        else
                                        {
                                            if (i < (atlas.SvgAssetsCount() - 1) && this.m_DragInfo.DraggedObject == atlas.SvgAsset(i + 1))
                                            {
                                                ok = false;
                                            }
                                        }
                                    }
                                }

                                if (ok)
                                {
                                    if (dragBefore)
                                    {
                                        this.m_DragInfo.InsertIdx    = i;
                                        this.m_DragInfo.InsertBefore = true;
                                        separatorInserted            = true;
                                    }
                                    else
                                    {
                                        this.m_DragInfo.InsertIdx    = i;
                                        this.m_DragInfo.InsertBefore = false;
                                        separatorInserted            = true;
                                    }
                                    needRepaint = true;
                                }
                            }
                        }
                        else
                        {
                            // initialize the drag of an already present SVG document
                            if (currentEvent.type == EventType.MouseDrag)
                            {
                                DragAndDrop.PrepareStartDrag();
                                DragAndDrop.StartDrag("Start drag");
                                this.m_DragInfo.StartDrag(atlas.SvgAsset(i));
                                needRepaint = true;
                            }
                        }
                    }
                }

                // mouse is dragging inside the drop box, but not under an already present row; insertion point is inside the last element
                if (this.m_DragInfo.Dragging && !separatorInserted && atlas.SvgAssetsCount() > 0 && mousePos.y > this.m_InputAssetsRects[atlas.SvgAssetsCount() - 1].yMax)
                {
                    bool ok = true;

                    if (!(this.m_DragInfo.DraggedObject is TextAsset))
                    {
                        if (this.m_DragInfo.DraggedObject == atlas.SvgAsset(atlas.SvgAssetsCount() - 1))
                        {
                            ok = false;
                        }
                    }

                    if (ok)
                    {
                        this.m_DragInfo.InsertIdx    = atlas.SvgAssetsCount() - 1;
                        this.m_DragInfo.InsertBefore = false;
                        needRepaint = true;
                    }
                }
            }
            else
            {
                this.m_DragInfo.InsertIdx = -1;
            }

            if (needRepaint)
            {
                Repaint();
            }
        }

        if (currentEvent.type == EventType.DragExited)
        {
            this.m_DragInfo.StopDrag();
            DragAndDrop.objectReferences = new UnityEngine.Object[0];
        }
        else
        {
            switch (currentEvent.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (this.m_DragInfo.Dragging)
                {
                    bool dragValid = true;

                    if (scollRect.Contains(currentEvent.mousePosition) && dragValid)
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                        if (currentEvent.type == EventType.DragPerform)
                        {
                            int index;

                            // accept drag&drop operation
                            DragAndDrop.AcceptDrag();
                            // check if we are dropping a text asset
                            if (this.m_DragInfo.DraggedObject is TextAsset)
                            {
                                // if a valid inter-position has not been selected, append the new asset at the end of list
                                if (this.m_DragInfo.InsertIdx < 0)
                                {
                                    index = atlas.SvgAssetsCount();
                                }
                                else
                                {
                                    index = (this.m_DragInfo.InsertBefore) ? this.m_DragInfo.InsertIdx : (this.m_DragInfo.InsertIdx + 1);
                                }
                                // add the text asset to the SVG list
                                if (atlas.SvgAssetAdd(this.m_DragInfo.DraggedObject as TextAsset, index))
                                {
                                    isDirty = true;
                                }
                            }
                            else
                            {
                                // we are dropping an already present SVG row
                                index = (this.m_DragInfo.InsertBefore) ? this.m_DragInfo.InsertIdx : (this.m_DragInfo.InsertIdx + 1);
                                if (atlas.SvgAssetMove(this.m_DragInfo.DraggedObject as SVGAssetInput, index))
                                {
                                    isDirty = true;
                                }
                            }
                            // now we can close the drag operation
                            this.m_DragInfo.StopDrag();
                        }
                    }
                    else
                    {
                        // if we are dragging outside of the allowed drop region, simply reject the drag&drop
                        DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                    }
                }
                else
                {
                    if (scollRect.Contains(currentEvent.mousePosition))
                    {
                        if (DragAndDrop.objectReferences != null && DragAndDrop.objectReferences.Length > 0)
                        {
                            UnityEngine.Object draggedObject = DragAndDrop.objectReferences[0];
                            // check object type, only TextAssets are allowed
                            if (draggedObject is TextAsset)
                            {
                                this.m_DragInfo.StartDrag(DragAndDrop.objectReferences[0]);
                                Repaint();
                            }
                            else
                            {
                                // acceptance is not confirmed (e.g. we are dragging a binary file)
                                DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                            }
                        }
                    }
                }
                break;

            default:
                break;
            }
        }

        return(isDirty);
    }